From 1fdac282b4a5b7a06cc72566b633b1f2e3f87ef8 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Tue, 9 Apr 2024 15:46:23 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=20=D0=B4=D0=BE=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B2=20=D1=82?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/NewsServiceTest.java | 27 +++++++++++++++++++ .../com/example/demo/UserServiceTest.java | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lab2/src/test/java/com/example/demo/NewsServiceTest.java b/lab2/src/test/java/com/example/demo/NewsServiceTest.java index 45b5a39..39403e1 100644 --- a/lab2/src/test/java/com/example/demo/NewsServiceTest.java +++ b/lab2/src/test/java/com/example/demo/NewsServiceTest.java @@ -10,10 +10,37 @@ class NewsServiceTest { } @Test + @Order(1) void createTest() { newsService.create(new NewsEntity(null, "Название", "2024-02-10", "тэг", "текст новости")); final NewsEntity last = newsService.create(new NewsEntity(null, "9 апреля", "2024-04-09", "весна", "просто наступил апрель")); Assertions.assertEquals(1, newsService.getAll().size()); Assertions.assertEquals(last, newsService.get(1L)); } + + @Test + @Order(2) + void updateTest() { + final String test = "TEST"; + final NewsEntity entity = newsService.get(3L); + final String oldName = entity.getName(); + final NewsEntity newEntity = newsService.update(1, new NewsEntity(1L, test, new Date(), test, test)); + Assertions.assertEquals(2, newsService.getAll().size()); + Assertions.assertEquals(newEntity, newsService.get(1L)); + Assertions.assertEquals(test, newEntity.getName()); + Assertions.assertEquals(oldName, newEntity.getName()); + } + + @Test + @Order(3) + void deleteTest() { + newsService.delete(1L); + Assertions.assertEquals(2, newsService.getAll().size()); + final NewsEntity last = NewsService.get(2L); + Assertions.assertEquals(2L, last.getId()); + + final NewsEntity newEntity = newsService.create(new NewsEntity(null, "9 апреля", "2024-04-09", "весна", "просто наступил апрель")); + Assertions.assertEquals(2, newsService.getAll().size()); + Assertions.assertEquals(2L, newEntity.getId()); + } } \ 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 a747193..61e3b7e 100644 --- a/lab2/src/test/java/com/example/demo/UserServiceTest.java +++ b/lab2/src/test/java/com/example/demo/UserServiceTest.java @@ -15,7 +15,7 @@ class UserServiceTest { @Order(1) void createTest() { userService.create(new UserEntity(null, "beko", "111", "ddwwdd", "beko@mail.ru", "2004-04-04")); - userService.create(new UserEntity(null, "rara", "rara", "dererere", "rara@mail.ru", "2001-01-01")); + userService.create(new UserEntity(null, "lambda", "lambda", "Лямбда Дельта", "lambda@mail.ru", "2001-01-01")); Assertions.assertEquals(1, userService.getAll().size()); }