From 17214648a297fdcc5534f8a6d47d50138e7f8d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=AF=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=B2?= Date: Sun, 12 May 2024 18:28:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/DemoApplication.java | 43 ++++++++++--------- .../com/example/demo/TypeServiceTests.java | 15 +++---- 2 files changed, 30 insertions(+), 28 deletions(-) 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()); } }