From 2506acc531bcee6b3118f79eaaea00cbbe988705 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 13 Oct 2022 09:02:09 +0200 Subject: [PATCH] add audit journal log for hs_office_debitor --- .../db/changelog/270-hs-office-debitor.sql | 8 +++++++ ...fficeDebitorRepositoryIntegrationTest.java | 23 +++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main/resources/db/changelog/270-hs-office-debitor.sql b/src/main/resources/db/changelog/270-hs-office-debitor.sql index 6831a301..10da431e 100644 --- a/src/main/resources/db/changelog/270-hs-office-debitor.sql +++ b/src/main/resources/db/changelog/270-hs-office-debitor.sql @@ -17,3 +17,11 @@ create table hs_office_debitor -- TODO.impl: SEPA-mandate ); --// + + +-- ============================================================================ +--changeset hs-office-debitor-MAIN-TABLE-JOURNAL:1 endDelimiter:--// +-- ---------------------------------------------------------------------------- + +call create_journal('hs_office_debitor'); +--// diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java index 1e276893..3294a216 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java @@ -24,10 +24,7 @@ import org.springframework.test.annotation.DirtiesContext; import javax.persistence.EntityManager; import javax.servlet.http.HttpServletRequest; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; +import java.util.*; import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; @@ -435,6 +432,24 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest { } } + @Test + public void auditJournalLogIsAvailable() { + // given + final var query = em.createNativeQuery(""" + select c.currenttask, j.targettable, j.targetop + from tx_journal j + join tx_context c on j.txid = c.txid + where targettable = 'hs_office_debitor'; + """); + + // when + @SuppressWarnings("unchecked") final List customerLogEntries = query.getResultList(); + + // then + assertThat(customerLogEntries).map(Arrays::toString) + .contains("[creating RBAC test debitor FirstGmbH-firstcontact, hs_office_debitor, INSERT]"); + } + private HsOfficePartnerEntity rawReference(final HsOfficePartnerEntity givenPartner) { return em.getReference(HsOfficePartnerEntity.class, givenPartner.getUuid()); }