emailAddress = emailDatabase.getUserEmailAddress(userId + 1124);
diff --git a/src/test/java/io/wkrzywiec/hexagonal/library/domain/user/infrastructure/UserDatabaseAdapterITCase.java b/src/test/java/io/wkrzywiec/hexagonal/library/domain/user/infrastructure/UserDatabaseAdapterITCase.java
index 3be7c72..2697947 100644
--- a/src/test/java/io/wkrzywiec/hexagonal/library/domain/user/infrastructure/UserDatabaseAdapterITCase.java
+++ b/src/test/java/io/wkrzywiec/hexagonal/library/domain/user/infrastructure/UserDatabaseAdapterITCase.java
@@ -1,5 +1,6 @@
package io.wkrzywiec.hexagonal.library.domain.user.infrastructure;
+import io.wkrzywiec.hexagonal.library.DatabaseHelper;
import io.wkrzywiec.hexagonal.library.UserTestData;
import io.wkrzywiec.hexagonal.library.domain.user.core.model.EmailAddress;
import io.wkrzywiec.hexagonal.library.domain.user.core.model.User;
@@ -20,6 +21,7 @@ public class UserDatabaseAdapterITCase {
@Autowired
private JdbcTemplate jdbcTemplate;
+ private DatabaseHelper databaseHelper;
@Autowired
private UserRepository userRepository;
@@ -29,6 +31,7 @@ public class UserDatabaseAdapterITCase {
@BeforeEach
public void init(){
userDatabase = new UserDatabaseAdapter(userRepository);
+ databaseHelper = new DatabaseHelper(jdbcTemplate);
}
@Test
@@ -45,10 +48,7 @@ public class UserDatabaseAdapterITCase {
UserIdentifier userIdentifier = userDatabase.save(user);
//then
- Long savedUserId = jdbcTemplate.queryForObject(
- "SELECT id FROM user WHERE email = ?",
- Long.class,
- UserTestData.johnDoeEmail());
+ Long savedUserId = databaseHelper.getJohnDoeUserId();
assertEquals(userIdentifier.getAsLong(), savedUserId);
}
diff --git a/src/test/resources/book-and-user.sql b/src/test/resources/book-and-user.sql
index be03a02..231fd34 100644
--- a/src/test/resources/book-and-user.sql
+++ b/src/test/resources/book-and-user.sql
@@ -1,17 +1,17 @@
-INSERT INTO public.author (name) VALUES
+INSERT INTO author (name) VALUES
('Yuval Noah Harari')
;
-INSERT INTO public.book (book_external_id,isbn_10,isbn_13,title,publisher,published_date,description,page_count,image_link) VALUES
+INSERT INTO book (book_external_id,isbn_10,isbn_13,title,publisher,published_date,description,page_count,image_link) VALUES
('dWYyCwAAQBAJ','1473545374','9781473545373','Homo Deus','Random House','2016-09-08','**THE MILLION COPY BESTSELLER**
Sapiens showed us where we came from. In uncertain times, Homo Deus shows us where we’re going.
Yuval Noah Harari envisions a near future in which we face a new set of challenges. Homo Deus explores the projects, dreams and nightmares that will shape the twenty-first century and beyond – from overcoming death to creating artificial life.
It asks the fundamental questions: how can we protect this fragile world from our own destructive power? And what does our future hold?
''Homo Deus will shock you. It will entertain you. It will make you think in ways you had not thought before’ Daniel Kahneman, bestselling author of Thinking, Fast and Slow
',528,'http://books.google.com/books/content?id=dWYyCwAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&imgtk=AFLRE73PkLs4TNB-W2uhDvXJkIB4-9G9AJ_L1iYTYLEXa3zi2kahdsN9-_0tL7WRWgujNpjMA5ZuJO7_ykFUlCWAyLzcQVcGkqUS-NOkUkEcJ_ZRrgq48URpcfBrJWQCwSWtHo5pEGkp&source=gbs_api')
;
-INSERT INTO public.book_author (book_id, author_id)
+INSERT INTO book_author (book_id, author_id)
SELECT b.id, a.id
FROM public.book b, public.author a
WHERE b.title = 'Homo deus' AND a.name = 'Yuval Noah Harari'
;
-INSERT INTO public.user (first_name, last_name, email) VALUES
+INSERT INTO library_user (first_name, last_name, email) VALUES
('John','Doe','john.doe@test.com')
;
\ No newline at end of file
diff --git a/src/test/resources/borrowed-book.sql b/src/test/resources/borrowed-book.sql
new file mode 100644
index 0000000..0e0195a
--- /dev/null
+++ b/src/test/resources/borrowed-book.sql
@@ -0,0 +1,5 @@
+INSERT INTO public.borrowed (book_id, user_id)
+ VALUES (
+ (SELECT id FROM book WHERE title = 'Homo Deus'),
+ (SELECT id FROM library_user WHERE email = 'john.doe@test.com')
+);
\ No newline at end of file
diff --git a/src/test/resources/clean-database.sql b/src/test/resources/clean-database.sql
index 09869c9..ca17c47 100644
--- a/src/test/resources/clean-database.sql
+++ b/src/test/resources/clean-database.sql
@@ -2,6 +2,6 @@ DELETE FROM public.borrowed;
DELETE FROM public.reserved;
DELETE FROM public.available;
DELETE FROM public.book_author;
-DELETE FROM public.user;
+DELETE FROM public.library_user;
DELETE FROM public.book;
DELETE FROM public.author;
\ No newline at end of file
diff --git a/src/test/resources/reserved-book.sql b/src/test/resources/reserved-book.sql
new file mode 100644
index 0000000..b339904
--- /dev/null
+++ b/src/test/resources/reserved-book.sql
@@ -0,0 +1,5 @@
+INSERT INTO public.reserved (book_id, user_id)
+ VALUES (
+ (SELECT id FROM book WHERE title = 'Homo Deus'),
+ (SELECT id FROM library_user WHERE email = 'john.doe@test.com')
+);
\ No newline at end of file