From d4ceaf4430789386b775c46a155e8b331d912ff7 Mon Sep 17 00:00:00 2001 From: Aleksandr Gladskoy Date: Tue, 12 Mar 2024 18:13:11 +0300 Subject: [PATCH] #36: fix tests --- .../java/ru/saneci/booklibrary/BaseControllerTest.java | 5 ++++- .../saneci/booklibrary/controller/HomeControllerTest.java | 4 ++-- .../sql/book_controller/create-book-with-linked-person.sql | 7 +++++-- .../sql/people_controller/create-not-overdue-book.sql | 3 ++- .../sql/people_controller/create-overdue-book.sql | 3 ++- src/test/resources/sql/people_controller/create-person.sql | 3 ++- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/test/java/ru/saneci/booklibrary/BaseControllerTest.java b/src/test/java/ru/saneci/booklibrary/BaseControllerTest.java index 33aeec2..9cd53e9 100644 --- a/src/test/java/ru/saneci/booklibrary/BaseControllerTest.java +++ b/src/test/java/ru/saneci/booklibrary/BaseControllerTest.java @@ -38,7 +38,10 @@ public abstract class BaseControllerTest { getContainerInitDatabasePath("deploy-23-2.sql")) .withCopyFileToContainer( getDatabaseMigrationFile("r-2024-1/deploy-24-1.sql"), - getContainerInitDatabasePath("deploy-24-1.sql")); + getContainerInitDatabasePath("deploy-24-1.sql")) + .withCopyFileToContainer( + getDatabaseMigrationFile("r-2024-2/deploy-24-2.sql"), + getContainerInitDatabasePath("deploy-24-2.sql")); } private static MountableFile getDatabaseMigrationFile(String fileName) { diff --git a/src/test/java/ru/saneci/booklibrary/controller/HomeControllerTest.java b/src/test/java/ru/saneci/booklibrary/controller/HomeControllerTest.java index 0cb8989..f789627 100644 --- a/src/test/java/ru/saneci/booklibrary/controller/HomeControllerTest.java +++ b/src/test/java/ru/saneci/booklibrary/controller/HomeControllerTest.java @@ -37,8 +37,8 @@ void whenGetIndex_thenIndexViewShouldContainMainMenu() throws Exception { mockMvc.perform(get("/")) .andExpect(xpath("//*[@id='mainMenu']/nav/div[1]/h4").string("Основные разделы приложения")) .andExpect(xpath("//*[@id='mainMenu']/nav/div[2]/a/strong").string("Книги")) - .andExpect(xpath("//*[@id='mainMenu']/nav/div[3]/a/strong").string("Новая книга")) - .andExpect(xpath("//*[@id='mainMenu']/nav/div[4]/a/strong").string("Читатели")) + .andExpect(xpath("//*[@id='mainMenu']/nav/div[3]/a/strong").string("Читатели")) + .andExpect(xpath("//*[@id='mainMenu']/nav/div[4]/a/strong").string("Новая книга")) .andExpect(xpath("//*[@id='mainMenu']/nav/div[5]/a/strong").string("Новый читатель")); } diff --git a/src/test/resources/sql/book_controller/create-book-with-linked-person.sql b/src/test/resources/sql/book_controller/create-book-with-linked-person.sql index 2225742..006f257 100644 --- a/src/test/resources/sql/book_controller/create-book-with-linked-person.sql +++ b/src/test/resources/sql/book_controller/create-book-with-linked-person.sql @@ -1,4 +1,7 @@ truncate book, person; -insert into person (id, name, birthday_year) values (1, 'Test User Name', 2020); -insert into book (id, person_id, title, author, publish_year) values (1, 1, 'Test Book', 'Test Author', 1234); \ No newline at end of file +insert into person (id, name, birthday_year, username, password, role) +values (1, 'Test User Name', 2020, 'username', 'password', 'ROLE_READER'); + +insert into book (id, person_id, title, author, publish_year) +values (1, 1, 'Test Book', 'Test Author', 1234); \ No newline at end of file diff --git a/src/test/resources/sql/people_controller/create-not-overdue-book.sql b/src/test/resources/sql/people_controller/create-not-overdue-book.sql index 2452eaf..634c79f 100644 --- a/src/test/resources/sql/people_controller/create-not-overdue-book.sql +++ b/src/test/resources/sql/people_controller/create-not-overdue-book.sql @@ -1,6 +1,7 @@ truncate book, person; -insert into person (id, name, birthday_year) values (1, 'Test User Name', 2020); +insert into person (id, name, birthday_year, username, password, role) +values (1, 'Test User Name', 2020, 'username', 'password', 'ROLE_READER'); insert into book (id, person_id, title, author, publish_year, given_at) values (1, 1, 'Test Book', 'Test Author', 1234, now() - interval '9 days'); \ No newline at end of file diff --git a/src/test/resources/sql/people_controller/create-overdue-book.sql b/src/test/resources/sql/people_controller/create-overdue-book.sql index a553dd5..1e3e898 100644 --- a/src/test/resources/sql/people_controller/create-overdue-book.sql +++ b/src/test/resources/sql/people_controller/create-overdue-book.sql @@ -1,6 +1,7 @@ truncate book, person; -insert into person (id, name, birthday_year) values (1, 'Test User Name', 2020); +insert into person (id, name, birthday_year, username, password, role) +values (1, 'Test User Name', 2020, 'username', 'password', 'ROLE_READER'); insert into book (id, person_id, title, author, publish_year, given_at) values (1, 1, 'Test Book', 'Test Author', 1234, now() - interval '10 days'); \ No newline at end of file diff --git a/src/test/resources/sql/people_controller/create-person.sql b/src/test/resources/sql/people_controller/create-person.sql index f5787d7..ead0aba 100644 --- a/src/test/resources/sql/people_controller/create-person.sql +++ b/src/test/resources/sql/people_controller/create-person.sql @@ -1,3 +1,4 @@ truncate person cascade; -insert into person (id, name, birthday_year) values (1, 'Test User', 1990); \ No newline at end of file +insert into person (id, name, birthday_year, username, password, role) +values (1, 'Test User', 1990, 'username', 'password', 'ROLE_READER'); \ No newline at end of file