lab2 fixed updateBookTest

This commit is contained in:
Zakharov_Rostislav 2024-03-20 19:15:49 +04:00
parent f01db20edf
commit f25171e835

View File

@ -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