From a56af5af258f9c141d718ff043fb9b9484ffdce6 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 13 Oct 2022 07:57:19 +0200 Subject: [PATCH] add audit journal log for hs_office_contact --- .../db/changelog/200-hs-office-contact.sql | 8 ++++++++ ...fficeContactRepositoryIntegrationTest.java | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/resources/db/changelog/200-hs-office-contact.sql b/src/main/resources/db/changelog/200-hs-office-contact.sql index 0feb7926..4bbf0bee 100644 --- a/src/main/resources/db/changelog/200-hs-office-contact.sql +++ b/src/main/resources/db/changelog/200-hs-office-contact.sql @@ -13,3 +13,11 @@ create table if not exists hs_office_contact phoneNumbers text -- TODO.feat: change to json ); --// + + +-- ============================================================================ +--changeset hs-office-contact-MAIN-TABLE-JOURNAL:1 endDelimiter:--// +-- ---------------------------------------------------------------------------- + +call create_journal('hs_office_contact'); +--// diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java index 396b88dd..40cd8628 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java @@ -20,6 +20,7 @@ import org.testcontainers.junit.jupiter.Container; import javax.persistence.EntityManager; import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; import java.util.List; import java.util.function.Supplier; @@ -264,6 +265,24 @@ class HsOfficeContactRepositoryIntegrationTest 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_contact'; + """); + + // when + @SuppressWarnings("unchecked") final List customerLogEntries = query.getResultList(); + + // then + assertThat(customerLogEntries).map(Arrays::toString) + .contains("[creating RBAC test contact first contact, hs_office_contact, INSERT]"); + } + private HsOfficeContactEntity givenSomeTemporaryContact( final String createdByUser, Supplier entitySupplier) {