From f25171e835fd0e9a3faee9b4eea0c1ef9d2e19a6 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Wed, 20 Mar 2024 19:15:49 +0400 Subject: [PATCH] lab2 fixed updateBookTest --- .../src/test/java/com/ip/library/BooksTests.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SpringApp/library/src/test/java/com/ip/library/BooksTests.java b/SpringApp/library/src/test/java/com/ip/library/BooksTests.java index 5260770..88fc6ca 100644 --- a/SpringApp/library/src/test/java/com/ip/library/BooksTests.java +++ b/SpringApp/library/src/test/java/com/ip/library/BooksTests.java @@ -51,11 +51,19 @@ class BooksTests { final BookEntity entity = bookService.get(3L); final String oldName = entity.getName(); final String test = oldName + "TEST"; - final BookEntity newEntity = bookService.update(3L, new BookEntity(1L, test, entity.getType(), entity.getAuthor())); + final var oldType = entity.getType(); + var testType = typeService.create(new TypeEntity(null, oldType.getName() + "test")); + final var oldAuthor = entity.getAuthor(); + var testAuthor = authorService.create(new AuthorEntity(null, oldAuthor.getName() + "test")); + final BookEntity newEntity = bookService.update(3L, new BookEntity(1L, test, testType, testAuthor)); Assertions.assertEquals(3, bookService.getAll().size()); Assertions.assertEquals(newEntity, bookService.get(3L)); Assertions.assertEquals(test, newEntity.getName()); Assertions.assertNotEquals(oldName, newEntity.getName()); + Assertions.assertEquals(testType, newEntity.getType()); + Assertions.assertNotEquals(oldType, newEntity.getType()); + Assertions.assertEquals(testAuthor, newEntity.getAuthor()); + Assertions.assertNotEquals(oldAuthor, newEntity.getAuthor()); } @Test