historic-view (#92)
Co-authored-by: Michael Hoennig <michael@hoennig.de> Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/92 Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
This commit is contained in:
+50
-19
@@ -20,7 +20,9 @@ import org.springframework.orm.jpa.JpaSystemException;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -62,6 +64,54 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup
|
||||
@MockBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'caption'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_booking_item';
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating booking-item test-data, hs_booking_item, INSERT, prod CloudServer]",
|
||||
"[creating booking-item test-data, hs_booking_item, INSERT, separate ManagedServer]",
|
||||
"[creating booking-item test-data, hs_booking_item, INSERT, separate ManagedWebspace]",
|
||||
"[creating booking-item test-data, hs_booking_item, INSERT, some ManagedServer]",
|
||||
"[creating booking-item test-data, hs_booking_item, INSERT, some ManagedWebspace]",
|
||||
"[creating booking-item test-data, hs_booking_item, INSERT, some PrivateCloud]",
|
||||
"[creating booking-item test-data, hs_booking_item, INSERT, test CloudServer]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void historizationIsAvailable() {
|
||||
// given
|
||||
final String nativeQuerySql = """
|
||||
select count(*)
|
||||
from hs_booking_item_hv ha;
|
||||
""";
|
||||
|
||||
// when
|
||||
historicalContext(Timestamp.from(ZonedDateTime.now().minusDays(1).toInstant()));
|
||||
final var query = em.createNativeQuery(nativeQuerySql, Integer.class);
|
||||
@SuppressWarnings("unchecked") final var countBefore = (Integer) query.getSingleResult();
|
||||
|
||||
// then
|
||||
assertThat(countBefore).as("hs_booking_item should not contain rows for a timestamp in the past").isEqualTo(0);
|
||||
|
||||
// and when
|
||||
historicalContext(Timestamp.from(ZonedDateTime.now().plusHours(1).toInstant()));
|
||||
em.createNativeQuery(nativeQuerySql, Integer.class);
|
||||
@SuppressWarnings("unchecked") final var countAfter = (Integer) query.getSingleResult();
|
||||
|
||||
// then
|
||||
assertThat(countAfter).as("hs_booking_item should contain rows for a timestamp in the future").isGreaterThan(1);
|
||||
}
|
||||
|
||||
@Nested
|
||||
class CreateBookingItem {
|
||||
|
||||
@@ -304,25 +354,6 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_booking_item';
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating booking-item test-data 1000111, hs_booking_item, INSERT]",
|
||||
"[creating booking-item test-data 1000212, hs_booking_item, INSERT]",
|
||||
"[creating booking-item test-data 1000313, hs_booking_item, INSERT]");
|
||||
}
|
||||
|
||||
private HsBookingItem givenSomeTemporaryBookingItem(final String projectCaption) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
|
||||
+46
-19
@@ -20,6 +20,8 @@ import org.springframework.orm.jpa.JpaSystemException;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -57,6 +59,50 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
@MockBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'caption'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_booking_project';
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating booking-project test-data, hs_booking_project, INSERT, D-1000111 default project]",
|
||||
"[creating booking-project test-data, hs_booking_project, INSERT, D-1000212 default project]",
|
||||
"[creating booking-project test-data, hs_booking_project, INSERT, D-1000313 default project]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void historizationIsAvailable() {
|
||||
// given
|
||||
final String nativeQuerySql = """
|
||||
select count(*)
|
||||
from hs_booking_project_hv ha;
|
||||
""";
|
||||
|
||||
// when
|
||||
historicalContext(Timestamp.from(ZonedDateTime.now().minusDays(1).toInstant()));
|
||||
final var query = em.createNativeQuery(nativeQuerySql, Integer.class);
|
||||
@SuppressWarnings("unchecked") final var countBefore = (Integer) query.getSingleResult();
|
||||
|
||||
// then
|
||||
assertThat(countBefore).as("hs_booking_project_hv should not contain rows for a timestamp in the past").isEqualTo(0);
|
||||
|
||||
// and when
|
||||
historicalContext(Timestamp.from(ZonedDateTime.now().plusHours(1).toInstant()));
|
||||
em.createNativeQuery(nativeQuerySql, Integer.class);
|
||||
@SuppressWarnings("unchecked") final var countAfter = (Integer) query.getSingleResult();
|
||||
|
||||
// then
|
||||
assertThat(countAfter).as("hs_booking_project_hv should contain rows for a timestamp in the future").isGreaterThan(1);
|
||||
}
|
||||
|
||||
@Nested
|
||||
class CreateBookingProject {
|
||||
|
||||
@@ -283,25 +329,6 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_booking_project';
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating booking-project test-data 1000111, hs_booking_project, INSERT]",
|
||||
"[creating booking-project test-data 1000212, hs_booking_project, INSERT]",
|
||||
"[creating booking-project test-data 1000313, hs_booking_project, INSERT]");
|
||||
}
|
||||
|
||||
private HsBookingProjectRealEntity givenSomeTemporaryBookingProject(final int debitorNumber) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
|
||||
+62
-19
@@ -23,6 +23,8 @@ import org.springframework.orm.jpa.JpaSystemException;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -70,6 +72,66 @@ class HsHostingAssetRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
@MockBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'caption'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_hosting_asset';
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, another CloudServer]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some Domain-DNS-Setup]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some Domain-HTTP-Setup]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some Domain-MBOX-Setup]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some Domain-SMTP-Setup]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some Domain-Setup]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some E-Mail-Address]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some E-Mail-Alias]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some ManagedServer]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some UnixUser for E-Mail]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some UnixUser for Website]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some Webspace]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some default MariaDB instance]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some default MariaDB user]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some default MariaDB database]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some default Postgresql instance]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some default Postgresql user]",
|
||||
"[creating hosting-asset test-data, hs_hosting_asset, INSERT, some default Postgresql database]"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void historizationIsAvailable() {
|
||||
// given
|
||||
final String nativeQuerySql = """
|
||||
select count(*)
|
||||
from hs_hosting_asset_hv ha;
|
||||
""";
|
||||
|
||||
// when
|
||||
historicalContext(Timestamp.from(ZonedDateTime.now().minusDays(1).toInstant()));
|
||||
final var query = em.createNativeQuery(nativeQuerySql, Integer.class);
|
||||
@SuppressWarnings("unchecked") final var countBefore = (Integer) query.getSingleResult();
|
||||
|
||||
// then
|
||||
assertThat(countBefore).as("hs_hosting_asset_hv should not contain rows for a timestamp in the past").isEqualTo(0);
|
||||
|
||||
// and when
|
||||
historicalContext(Timestamp.from(ZonedDateTime.now().plusHours(1).toInstant()));
|
||||
em.createNativeQuery(nativeQuerySql, Integer.class);
|
||||
@SuppressWarnings("unchecked") final var countAfter = (Integer) query.getSingleResult();
|
||||
|
||||
// then
|
||||
assertThat(countAfter).as("hs_hosting_asset_hv should contain rows for a timestamp in the future").isGreaterThan(1);
|
||||
}
|
||||
|
||||
@Nested
|
||||
class CreateAsset {
|
||||
|
||||
@@ -391,25 +453,6 @@ class HsHostingAssetRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_hosting_asset';
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating hosting-asset test-data D-1000111 default project, hs_hosting_asset, INSERT]",
|
||||
"[creating hosting-asset test-data D-1000212 default project, hs_hosting_asset, INSERT]",
|
||||
"[creating hosting-asset test-data D-1000313 default project, hs_hosting_asset, INSERT]");
|
||||
}
|
||||
|
||||
private HsHostingAssetRealEntity givenSomeTemporaryAsset(final String projectCaption, final String identifier) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net"); // needed to determine creator
|
||||
|
||||
@@ -610,7 +610,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
deleteTestDataFromHsOfficeTables();
|
||||
resetHsOfficeSequences();
|
||||
deleteFromTestTables();
|
||||
deleteFromRbacTables();
|
||||
deleteFromCommonTables();
|
||||
|
||||
jpaAttempt.transacted(() -> {
|
||||
context(rbacSuperuser);
|
||||
|
||||
@@ -249,8 +249,11 @@ public class CsvDataImport extends ContextBasedTest {
|
||||
context(rbacSuperuser);
|
||||
// TODO.perf: could we instead skip creating test-data based on an env var?
|
||||
em.createNativeQuery("delete from hs_hosting_asset where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_hosting_asset_ex where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_booking_item where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_booking_item_ex where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_booking_project where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_booking_project_ex where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_coopassetstransaction where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_coopassetstransaction_legacy_id where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_coopsharestransaction where true").executeUpdate();
|
||||
@@ -292,7 +295,7 @@ public class CsvDataImport extends ContextBasedTest {
|
||||
}).assertSuccessful();
|
||||
}
|
||||
|
||||
protected void deleteFromRbacTables() {
|
||||
protected void deleteFromCommonTables() {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context(rbacSuperuser);
|
||||
em.createNativeQuery("delete from rbacuser_rv where name not like 'superuser-%'").executeUpdate();
|
||||
|
||||
+4
-3
@@ -271,7 +271,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'iban'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_bankaccount';
|
||||
""");
|
||||
@@ -281,8 +281,9 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating bankaccount test-data First GmbH, hs_office_bankaccount, INSERT]",
|
||||
"[creating bankaccount test-data Second e.K., hs_office_bankaccount, INSERT]");
|
||||
"[creating bankaccount test-data, hs_office_bankaccount, INSERT, DE02120300000000202051]",
|
||||
"[creating bankaccount test-data, hs_office_bankaccount, INSERT, DE02500105170137075030]",
|
||||
"[creating bankaccount test-data, hs_office_bankaccount, INSERT, DE02100500000054540402]");
|
||||
}
|
||||
|
||||
private HsOfficeBankAccountEntity givenSomeTemporaryBankAccount(final String createdByUser) {
|
||||
|
||||
+4
-3
@@ -256,7 +256,7 @@ class HsOfficeContactRbacRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'caption'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_contact';
|
||||
""");
|
||||
@@ -266,8 +266,9 @@ class HsOfficeContactRbacRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating contact test-data first contact, hs_office_contact, INSERT]",
|
||||
"[creating contact test-data second contact, hs_office_contact, INSERT]");
|
||||
"[creating contact test-data, hs_office_contact, INSERT, first contact]",
|
||||
"[creating contact test-data, hs_office_contact, INSERT, second contact]",
|
||||
"[creating contact test-data, hs_office_contact, INSERT, third contact]");
|
||||
}
|
||||
|
||||
private HsOfficeContactRbacEntity givenSomeTemporaryContact(
|
||||
|
||||
+13
-3
@@ -220,7 +220,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'reference'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_coopassetstransaction';
|
||||
""");
|
||||
@@ -230,8 +230,18 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating coopAssetsTransaction test-data 1000101, hs_office_coopassetstransaction, INSERT]",
|
||||
"[creating coopAssetsTransaction test-data 1000202, hs_office_coopassetstransaction, INSERT]");
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000101-1]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000101-2]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000101-3]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000101-3]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000202-1]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000202-2]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000202-3]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000202-3]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000303-1]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000303-2]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000303-3]",
|
||||
"[creating coopAssetsTransaction test-data, hs_office_coopassetstransaction, INSERT, ref 1000303-3]");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
||||
+13
-3
@@ -219,7 +219,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'reference'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_coopsharestransaction';
|
||||
""");
|
||||
@@ -229,8 +229,18 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating coopSharesTransaction test-data 1000101, hs_office_coopsharestransaction, INSERT]",
|
||||
"[creating coopSharesTransaction test-data 1000202, hs_office_coopsharestransaction, INSERT]");
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000101-1]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000101-2]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000101-3]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000101-4]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000202-1]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000202-2]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000202-3]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000202-4]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000303-1]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000303-2]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000303-3]",
|
||||
"[creating coopSharesTransaction test-data, hs_office_coopsharestransaction, INSERT, ref 1000303-4]");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
||||
+4
-3
@@ -589,7 +589,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'defaultprefix'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_debitor';
|
||||
""");
|
||||
@@ -599,8 +599,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating debitor test-data FirstGmbH-firstcontact, hs_office_debitor, INSERT]",
|
||||
"[creating debitor test-data Seconde.K.-secondcontact, hs_office_debitor, INSERT]");
|
||||
"[creating debitor test-data, hs_office_debitor, INSERT, fir]",
|
||||
"[creating debitor test-data, hs_office_debitor, INSERT, sec]",
|
||||
"[creating debitor test-data, hs_office_debitor, INSERT, thi]");
|
||||
}
|
||||
|
||||
private HsOfficeDebitorEntity givenSomeTemporaryDebitor(
|
||||
|
||||
+4
-4
@@ -336,7 +336,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'membernumbersuffix'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_membership';
|
||||
""");
|
||||
@@ -346,9 +346,9 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating Membership test-data P-10001M-...01, hs_office_membership, INSERT]",
|
||||
"[creating Membership test-data P-10002M-...02, hs_office_membership, INSERT]",
|
||||
"[creating Membership test-data P-10003M-...03, hs_office_membership, INSERT]");
|
||||
"[creating Membership test-data, hs_office_membership, INSERT, 01]",
|
||||
"[creating Membership test-data, hs_office_membership, INSERT, 02]",
|
||||
"[creating Membership test-data, hs_office_membership, INSERT, 03]");
|
||||
}
|
||||
|
||||
private HsOfficeMembershipEntity givenSomeTemporaryMembership(final String partnerTradeName, final String memberNumberSuffix) {
|
||||
|
||||
+6
-3
@@ -433,7 +433,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'partnernumber'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_partner';
|
||||
""");
|
||||
@@ -443,8 +443,11 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating partner test-data FirstGmbH-firstcontact, hs_office_partner, INSERT]",
|
||||
"[creating partner test-data Seconde.K.-secondcontact, hs_office_partner, INSERT]");
|
||||
"[creating partner test-data , hs_office_partner, INSERT, 10001]",
|
||||
"[creating partner test-data , hs_office_partner, INSERT, 10002]",
|
||||
"[creating partner test-data , hs_office_partner, INSERT, 10003]",
|
||||
"[creating partner test-data , hs_office_partner, INSERT, 10004]",
|
||||
"[creating partner test-data , hs_office_partner, INSERT, 10010]");
|
||||
}
|
||||
|
||||
private HsOfficePartnerEntity givenSomeTemporaryHostsharingPartner(
|
||||
|
||||
+5
-3
@@ -260,7 +260,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'tradename', targetdelta->>'lastname'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_person';
|
||||
""");
|
||||
@@ -270,8 +270,10 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating person test-data First GmbH, hs_office_person, INSERT]",
|
||||
"[creating person test-data Second e.K., Smith, Peter, hs_office_person, INSERT]");
|
||||
"[creating person test-data, hs_office_person, INSERT, Hostsharing eG, null]",
|
||||
"[creating person test-data, hs_office_person, INSERT, First GmbH, null]",
|
||||
"[creating person test-data, hs_office_person, INSERT, Second e.K., null]",
|
||||
"[creating person test-data, hs_office_person, INSERT, Third OHG, null]");
|
||||
}
|
||||
|
||||
private HsOfficePersonEntity givenSomeTemporaryPerson(
|
||||
|
||||
+2
-3
@@ -394,7 +394,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'mark'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_relation';
|
||||
""");
|
||||
@@ -404,8 +404,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating relation test-data HostsharingeG-FirstGmbH, hs_office_relation, INSERT]",
|
||||
"[creating relation test-data FirstGmbH-Firby, hs_office_relation, INSERT]");
|
||||
"[creating relation test-data, hs_office_relation, INSERT, members-announce]");
|
||||
}
|
||||
|
||||
private HsOfficeRelationRbacEntity givenSomeTemporaryRelationBessler(final String holderPerson, final String contact) {
|
||||
|
||||
+4
-4
@@ -379,7 +379,7 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'reference'
|
||||
from tx_journal_v
|
||||
where targettable = 'hs_office_sepamandate';
|
||||
""");
|
||||
@@ -389,9 +389,9 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating SEPA-mandate test-data 1000111, hs_office_sepamandate, INSERT]",
|
||||
"[creating SEPA-mandate test-data 1000212, hs_office_sepamandate, INSERT]",
|
||||
"[creating SEPA-mandate test-data 1000313, hs_office_sepamandate, INSERT]");
|
||||
"[creating SEPA-mandate test-data, hs_office_sepamandate, INSERT, ref-10001-11]",
|
||||
"[creating SEPA-mandate test-data, hs_office_sepamandate, INSERT, ref-10002-12]",
|
||||
"[creating SEPA-mandate test-data, hs_office_sepamandate, INSERT, ref-10003-13]");
|
||||
}
|
||||
|
||||
private HsOfficeSepaMandateEntity givenSomeTemporarySepaMandate(final String iban) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Import(RbacGrantsDiagramService.class)
|
||||
public abstract class ContextBasedTest {
|
||||
@@ -47,4 +48,26 @@ public abstract class ContextBasedTest {
|
||||
protected void context(final String currentUser) {
|
||||
context(currentUser, null);
|
||||
}
|
||||
|
||||
protected void historicalContext(final Long txId) {
|
||||
// set local cannot be used with query parameters
|
||||
em.createNativeQuery("""
|
||||
set local hsadminng.tx_history_txid to ':txid';
|
||||
""".replace(":txid", txId.toString())).executeUpdate();
|
||||
em.createNativeQuery("""
|
||||
set local hsadminng.tx_history_timestamp to '';
|
||||
""").executeUpdate();
|
||||
}
|
||||
|
||||
|
||||
protected void historicalContext(final Timestamp txTimestamp) {
|
||||
// set local cannot be used with query parameters
|
||||
em.createNativeQuery("""
|
||||
set local hsadminng.tx_history_timestamp to ':timestamp';
|
||||
""".replace(":timestamp", txTimestamp.toString())).executeUpdate();
|
||||
em.createNativeQuery("""
|
||||
set local hsadminng.tx_history_txid to '';
|
||||
""").executeUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user