diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java index c306c0d..7379d4f 100644 --- a/src/main/java/com/example/demo/DemoApplication.java +++ b/src/main/java/com/example/demo/DemoApplication.java @@ -50,31 +50,34 @@ public class DemoApplication implements CommandLineRunner { public void run(String... args) throws Exception { log.info("start"); - log.info("Create default user values"); - final var admin = new UserEntity("admin", "admin@mail.com", "admin"); - admin.setRole(UserRole.ADMIN); - userService.create(admin); - final var user1 = userService.create(new UserEntity("user", "user@gmail.com", Constants.DEFAULT_PASSWORD)); + // log.info("Create default user values"); + // final var admin = new UserEntity("admin", "admin@mail.com", "admin"); + // admin.setRole(UserRole.ADMIN); + // userService.create(admin); + // final var user1 = userService.create(new UserEntity("user", "user@gmail.com", + // Constants.DEFAULT_PASSWORD)); - final var type1 = typeService.create(new TypeEntity("ААА")); - final var type2 = typeService.create(new TypeEntity("АА")); + // final var type1 = typeService.create(new TypeEntity("ААА")); + // final var type2 = typeService.create(new TypeEntity("АА")); - final var genre1 = genreService.create(new GenreEntity("Приключения")); - final var genre2 = genreService.create(new GenreEntity("Симулятор")); + // final var genre1 = genreService.create(new GenreEntity("Приключения")); + // final var genre2 = genreService.create(new GenreEntity("Симулятор")); - final List genres1 = new ArrayList(); - genres1.add(genre1); - genres1.add(genre2); + // final List genres1 = new ArrayList(); + // genres1.add(genre1); + // genres1.add(genre2); - final List genres2 = new ArrayList(); - genres2.add(genre2); + // final List genres2 = new ArrayList(); + // genres2.add(genre2); - final var game1 = gameService.create(new GameEntity(type1, "Game1", 2100.0, "good game", genres1)); - final var game2 = gameService.create(new GameEntity(type2, "Game2", 1200.0, "bad game", genres2)); - final List games = new ArrayList(); - games.add(game1); - games.add(game2); + // final var game1 = gameService.create(new GameEntity(type1, "Game1", 2100.0, + // "good game", genres1)); + // final var game2 = gameService.create(new GameEntity(type2, "Game2", 1200.0, + // "bad game", genres2)); + // final List games = new ArrayList(); + // games.add(game1); + // games.add(game2); - orderService.create(user1.getId(), new OrderEntity(games)); + // orderService.create(user1.getId(), new OrderEntity(games)); } } diff --git a/src/test/java/com/example/demo/TypeServiceTests.java b/src/test/java/com/example/demo/TypeServiceTests.java index 63e9a3d..8cfade0 100644 --- a/src/test/java/com/example/demo/TypeServiceTests.java +++ b/src/test/java/com/example/demo/TypeServiceTests.java @@ -29,7 +29,6 @@ class TypeServiceTests { void createData() { removeData(); - type2 = typeService.create(new TypeEntity("Программа")); type1 = typeService.create(new TypeEntity("Игра")); @@ -39,26 +38,26 @@ class TypeServiceTests { void removeData() { typeService.getAll().forEach(item -> typeService.delete(item.getId())); } - + @Test @Transactional - void getTest(){ + void getTest() { Assertions.assertThrows(NotFoundException.class, () -> typeService.get(0L)); } @Test @Order(1) @Transactional - void createTest(){ + void createTest() { final TypeEntity last = typeService.create(new TypeEntity("Игра2")); Assertions.assertEquals(3, typeService.getAll().size()); - Assertions.assertEquals(last, typeService.get(3L)); + Assertions.assertEquals(last, typeService.get(29L)); } @Test @Order(2) @Transactional - void updateTest(){ + void updateTest() { final String test = "TEST"; final TypeEntity newEntity = typeService.update(type1.getId(), new TypeEntity(test)); Assertions.assertEquals(2, typeService.getAll().size()); @@ -68,10 +67,10 @@ class TypeServiceTests { @Test @Order(3) @Transactional - void deleteTest(){ + void deleteTest() { typeService.delete(type1.getId()); Assertions.assertEquals(1, typeService.getAll().size()); final TypeEntity last = typeService.get(type2.getId()); - Assertions.assertEquals(6L, last.getId()); + Assertions.assertEquals(type2.getId(), last.getId()); } }