From 1307b44b950612fa6c3d0dd7b32dcdefa4910a1d Mon Sep 17 00:00:00 2001
From: Michael Hoennig <michael@hoennig.de>
Date: Sun, 30 Oct 2022 09:38:46 +0100
Subject: [PATCH] use test database

---
 src/test/resources/application.yml                                                      |    4 ++--
 src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportBusinessPartners.java |   22 ++++++++++++----------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportBusinessPartners.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportBusinessPartners.java
index 16a3570..ad4ee56 100644
--- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportBusinessPartners.java
+++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportBusinessPartners.java
@@ -24,6 +24,7 @@
 import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
 import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.context.annotation.Import;
+import org.springframework.transaction.annotation.Transactional;
 
 import jakarta.persistence.EntityManager;
 import jakarta.persistence.PersistenceContext;
@@ -170,18 +171,19 @@
 
     @Test
     @Order(10)
+    @Transactional
     void persistEntities() {
-        jpaAttempt.transacted(() -> {
-            context("superuser-alex@hostsharing.net"); // TODO: use real user
+        context("superuser-alex@hostsharing.net"); // TODO: use real user for actual import
 
-            contacts.forEach((id, contact) -> em.persist(contact));
-            persons.forEach((id, person) -> em.persist(person));
-            partners.forEach((id, partner) -> em.persist(partner));
-            debitors.forEach((id, debitor) -> em.persist(debitor));
-            memberships.forEach((id, membership) -> em.persist(membership));
-            bankAccounts.forEach((id, account) -> em.persist(account));
-            sepaMandates.forEach((id, mandate) -> em.persist(mandate));
-        }).assertSuccessful();
+        contacts.forEach((id, contact) -> em.persist(contact));
+        persons.forEach((id, person) -> em.persist(person));
+        partners.forEach((id, partner) -> em.persist(partner));
+        debitors.forEach((id, debitor) -> em.persist(debitor));
+        memberships.forEach((id, membership) -> em.persist(membership));
+        bankAccounts.forEach((id, account) -> em.persist(account));
+        sepaMandates.forEach((id, mandate) -> em.persist(mandate));
+
+        em.flush();
     }
 
     public List<String[]> readAllLines(Reader reader) throws Exception {
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index 410e118..9915854 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -4,8 +4,8 @@
             platform: postgres
 
     datasource:
-        url-tc: jdbc:tc:postgresql:13.7-bullseye:///spring_boot_testcontainers
-        url: jdbc:postgresql://localhost:5432/postgres
+        url: jdbc:tc:postgresql:13.7-bullseye:///spring_boot_testcontainers
+        url-local: jdbc:postgresql://localhost:5432/postgres
         username: postgres
         password: password
 

--
Gitblit v1.9.3