From 3b96048f903ca3c78e8798aa5fdd0ee5bad7aeba Mon Sep 17 00:00:00 2001 From: bekodeg Date: Tue, 16 Apr 2024 12:24:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20=D0=BC?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/NewsServiceTest.java | 4 ++-- .../com/example/demo/UserServiceTest.java | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lab2/src/test/java/com/example/demo/NewsServiceTest.java b/lab2/src/test/java/com/example/demo/NewsServiceTest.java index 550b4eb..8c880df 100644 --- a/lab2/src/test/java/com/example/demo/NewsServiceTest.java +++ b/lab2/src/test/java/com/example/demo/NewsServiceTest.java @@ -28,7 +28,7 @@ class NewsServiceTest { newsService.create(new NewEntity(null, "Название", new Date(), "тэг", "текст новости")); final NewEntity last = newsService .create(new NewEntity(null, "9 апреля", new Date(), "весна", "просто наступил апрель")); - Assertions.assertEquals(1, newsService.getAll().size()); - Assertions.assertEquals(last, newsService.get(1L)); + Assertions.assertEquals(2L, newsService.getAll().size()); + Assertions.assertEquals(last, newsService.get(2L)); } } \ No newline at end of file diff --git a/lab2/src/test/java/com/example/demo/UserServiceTest.java b/lab2/src/test/java/com/example/demo/UserServiceTest.java index cfaef71..b8f664f 100644 --- a/lab2/src/test/java/com/example/demo/UserServiceTest.java +++ b/lab2/src/test/java/com/example/demo/UserServiceTest.java @@ -28,35 +28,34 @@ class UserServiceTest { @Test @Order(1) void createTest() { - userService.create(new UserEntity(null, "beko", "111", "ddwwdd", "beko@mail.ru", new Date())); - userService.create(new UserEntity(null, "rara", "rara", "dererere", "rara@mail.ru", new Date())); - Assertions.assertEquals(1, userService.getAll().size()); + userService.create(new UserEntity(null, "beko", "111", "ddwwdd", + "beko@mail.ru", new Date())); + userService.create(new UserEntity(null, "rara", "rara", "dererere", + "rara@mail.ru", new Date())); + Assertions.assertEquals(2, userService.getAll().size()); } @Test @Order(2) void updateTest() { final String test = "TEST"; - final UserEntity entity = userService.get(3L); - final String oldName = entity.getName(); final UserEntity newEntity = userService.update(1L, new UserEntity(1L, test, test, test, "test@mail.ru", new Date())); - Assertions.assertEquals(2, userService.getAll().size()); + Assertions.assertEquals(2L, userService.getAll().size()); Assertions.assertEquals(newEntity, userService.get(1L)); Assertions.assertEquals(test, newEntity.getName()); - Assertions.assertEquals(oldName, newEntity.getName()); } @Test @Order(3) void deleteTest() { userService.delete(1L); - Assertions.assertEquals(2, userService.getAll().size()); + Assertions.assertEquals(1L, userService.getAll().size()); final UserEntity last = userService.get(2L); Assertions.assertEquals(2L, last.getId()); final UserEntity newEntity = userService.create(new UserEntity(null, "1", "1", "1", "1@mail.ru", new Date())); - Assertions.assertEquals(2, userService.getAll().size()); - Assertions.assertEquals(2L, newEntity.getId()); + Assertions.assertEquals(2L, userService.getAll().size()); + Assertions.assertEquals(3L, newEntity.getId()); } } \ No newline at end of file