From 871bbd357e40d13682147f14141c3af8820fb424 Mon Sep 17 00:00:00 2001 From: Krishna Bottla <40598480+kbottla@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:07:36 +0000 Subject: [PATCH] PP-11205 Archive services - Archive services without any transactions in the last 7 years (or based on config number of days). - Criteria for archiving service is - transaction exists (for any linked gateway account) and is older than 7 years - OR no transactions exist and the created date is older than 7 years - It is possible that the service doesn't have any transactions and created_date is null. These will be dealt with separately. --- .../config/ExpungeAndArchiveDataConfig.java | 7 + .../LedgerSearchTransactionsResponse.java | 4 + .../ledger/model/LedgerTransaction.java | 4 +- ...xpungeAndArchiveHistoricalDataService.java | 79 +++++++- src/main/resources/config/config.yaml | 1 + ...geAndArchiveHistoricalDataServiceTest.java | 180 +++++++++++++++++- ...dgerSearchTransactionsResponseFixture.java | 24 +++ .../fixtures/LedgerTransactionFixture.java | 11 +- src/test/resources/config/test-it-config.yaml | 1 + 9 files changed, 302 insertions(+), 9 deletions(-) create mode 100644 src/test/java/uk/gov/pay/adminusers/fixtures/LedgerSearchTransactionsResponseFixture.java diff --git a/src/main/java/uk/gov/pay/adminusers/app/config/ExpungeAndArchiveDataConfig.java b/src/main/java/uk/gov/pay/adminusers/app/config/ExpungeAndArchiveDataConfig.java index 87d67777e..fc4d50412 100644 --- a/src/main/java/uk/gov/pay/adminusers/app/config/ExpungeAndArchiveDataConfig.java +++ b/src/main/java/uk/gov/pay/adminusers/app/config/ExpungeAndArchiveDataConfig.java @@ -10,6 +10,9 @@ public class ExpungeAndArchiveDataConfig { @NotNull private int expungeUserDataAfterDays; + @NotNull + private int archiveServicesAfterDays; + public boolean isExpungeAndArchiveHistoricalDataEnabled() { return expungeAndArchiveHistoricalDataEnabled; } @@ -17,4 +20,8 @@ public boolean isExpungeAndArchiveHistoricalDataEnabled() { public int getExpungeUserDataAfterDays() { return expungeUserDataAfterDays; } + + public int getArchiveServicesAfterDays() { + return archiveServicesAfterDays; + } } diff --git a/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerSearchTransactionsResponse.java b/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerSearchTransactionsResponse.java index 8dfdec5a4..e288ded91 100644 --- a/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerSearchTransactionsResponse.java +++ b/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerSearchTransactionsResponse.java @@ -14,6 +14,10 @@ public class LedgerSearchTransactionsResponse { @JsonProperty("results") private List transactions; + public LedgerSearchTransactionsResponse(List transactions) { + this.transactions = transactions; + } + public List getTransactions() { return transactions; } diff --git a/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerTransaction.java b/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerTransaction.java index 451560bb4..88f848c6b 100644 --- a/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerTransaction.java +++ b/src/main/java/uk/gov/pay/adminusers/client/ledger/model/LedgerTransaction.java @@ -22,12 +22,12 @@ public LedgerTransaction() { // empty constructor } - public LedgerTransaction(String transactionId, String reference) { + public LedgerTransaction(String transactionId, String reference, ZonedDateTime createdDate) { this.transactionId = transactionId; this.reference = reference; + this.createdDate = createdDate; } - public String getReference() { return reference; } diff --git a/src/main/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataService.java b/src/main/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataService.java index cf082b5e7..074861e66 100644 --- a/src/main/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataService.java +++ b/src/main/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataService.java @@ -6,12 +6,21 @@ import org.slf4j.LoggerFactory; import uk.gov.pay.adminusers.app.config.AdminUsersConfig; import uk.gov.pay.adminusers.app.config.ExpungeAndArchiveDataConfig; +import uk.gov.pay.adminusers.client.ledger.model.LedgerSearchTransactionsResponse; +import uk.gov.pay.adminusers.client.ledger.service.LedgerService; import uk.gov.pay.adminusers.persistence.dao.ForgottenPasswordDao; import uk.gov.pay.adminusers.persistence.dao.InviteDao; +import uk.gov.pay.adminusers.persistence.dao.ServiceDao; import uk.gov.pay.adminusers.persistence.dao.UserDao; +import uk.gov.pay.adminusers.persistence.entity.ServiceEntity; import java.time.Clock; import java.time.ZonedDateTime; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; import static java.time.ZoneOffset.UTC; import static java.time.temporal.ChronoUnit.DAYS; @@ -23,6 +32,8 @@ public class ExpungeAndArchiveHistoricalDataService { private final UserDao userDao; private final InviteDao inviteDao; private final ForgottenPasswordDao forgottenPasswordDao; + private final ServiceDao serviceDao; + private final LedgerService ledgerService; private final ExpungeAndArchiveDataConfig expungeAndArchiveDataConfig; private final Clock clock; @@ -35,11 +46,15 @@ public class ExpungeAndArchiveHistoricalDataService { @Inject public ExpungeAndArchiveHistoricalDataService(UserDao userDao, InviteDao inviteDao, ForgottenPasswordDao forgottenPasswordDao, + ServiceDao serviceDao, + LedgerService ledgerService, AdminUsersConfig adminUsersConfig, Clock clock) { this.userDao = userDao; this.inviteDao = inviteDao; this.forgottenPasswordDao = forgottenPasswordDao; + this.serviceDao = serviceDao; + this.ledgerService = ledgerService; expungeAndArchiveDataConfig = adminUsersConfig.getExpungeAndArchiveDataConfig(); this.clock = clock; } @@ -55,10 +70,14 @@ public void expungeAndArchiveHistoricalData() { int noOfInvitesDeleted = inviteDao.deleteInvites(deleteUsersAndRelatedDataBeforeDate); int noOfForgottenPasswordsDeleted = forgottenPasswordDao.deleteForgottenPasswords(deleteUsersAndRelatedDataBeforeDate); + int noOfServicesArchived = archiveServices(); + LOGGER.info("Completed expunging and archiving historical data", kv("no_of_users_deleted", noOfUsersDeleted), kv("no_of_forgotten_passwords_deleted", noOfForgottenPasswordsDeleted), - kv("no_of_invites_deleted", noOfInvitesDeleted)); + kv("no_of_invites_deleted", noOfInvitesDeleted), + kv("no_of_services_archived", noOfServicesArchived) + ); } else { LOGGER.info("Expunging and archiving historical data is not enabled"); } @@ -67,10 +86,64 @@ public void expungeAndArchiveHistoricalData() { } } + private int archiveServices() { + ZonedDateTime archiveServicesBeforeDate = getArchiveServicesBeforeDate(); + List servicesToCheckForArchiving = serviceDao.findServicesToCheckForArchiving(archiveServicesBeforeDate); + + AtomicInteger numberOfServicesArchived = new AtomicInteger(); + servicesToCheckForArchiving.forEach(serviceEntity -> { + + if (canArchiveService(serviceEntity)) { + numberOfServicesArchived.getAndIncrement(); + serviceEntity.setArchived(true); + + serviceDao.merge(serviceEntity); + } + }); + + return numberOfServicesArchived.get(); + } + + private boolean canArchiveService(ServiceEntity serviceEntity) { + Optional mayBeLastTransactionDateForService = getLastTransactionDateForService(serviceEntity); + ZonedDateTime archiveServicesBeforeDate = getArchiveServicesBeforeDate(); + + if (mayBeLastTransactionDateForService.isPresent()) { + return mayBeLastTransactionDateForService.get().isBefore(archiveServicesBeforeDate); + } else if (serviceEntity.getCreatedDate() != null) { + return serviceEntity.getCreatedDate().isBefore(archiveServicesBeforeDate); + } + + return false; + } + + private Optional getLastTransactionDateForService(ServiceEntity serviceEntity) { + return serviceEntity.getGatewayAccountIds() + .stream() + .map(gatewayAccountIdEntity -> getLastTransactionDateForGatewayAccount(gatewayAccountIdEntity.getGatewayAccountId())) + .filter(Objects::nonNull) + .max(Comparator.comparing(ZonedDateTime::toEpochSecond)); + } + + private ZonedDateTime getLastTransactionDateForGatewayAccount(String gatewayAccountId) { + LedgerSearchTransactionsResponse searchTransactions = ledgerService.searchTransactions(gatewayAccountId, 1); + + if (searchTransactions != null && !searchTransactions.getTransactions().isEmpty()) { + return searchTransactions.getTransactions().get(0).getCreatedDate(); + } + + return null; + } + + private ZonedDateTime getArchiveServicesBeforeDate() { + return clock.instant() + .minus(expungeAndArchiveDataConfig.getArchiveServicesAfterDays(), DAYS) + .atZone(UTC); + } + private ZonedDateTime getDeleteUsersAndRelatedDataBeforeDate() { - ZonedDateTime expungeAndArchiveDateBeforeDate = clock.instant() + return clock.instant() .minus(expungeAndArchiveDataConfig.getExpungeUserDataAfterDays(), DAYS) .atZone(UTC); - return expungeAndArchiveDateBeforeDate; } } diff --git a/src/main/resources/config/config.yaml b/src/main/resources/config/config.yaml index b66d9fe96..4ca8c3d3c 100644 --- a/src/main/resources/config/config.yaml +++ b/src/main/resources/config/config.yaml @@ -142,3 +142,4 @@ ecsContainerMetadataUriV4: ${ECS_CONTAINER_METADATA_URI_V4:-} expungeAndArchiveDataConfig: expungeAndArchiveHistoricalDataEnabled: ${EXPUNGE_AND_ARCHIVE_HISTORICAL_DATA_ENABLED:-false} expungeUserDataAfterDays: ${EXPUNGE_USER_DATA_AFTER_DAYS:-1460} + archiveServicesAfterDays: ${EXPUNGE_ARCHIVE_SERVICES_AFTER_DAYS:-2555} diff --git a/src/test/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataServiceTest.java b/src/test/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataServiceTest.java index 5013d0283..5a6080ce2 100644 --- a/src/test/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataServiceTest.java +++ b/src/test/java/uk/gov/pay/adminusers/expungeandarchive/service/ExpungeAndArchiveHistoricalDataServiceTest.java @@ -6,6 +6,7 @@ import ch.qos.logback.core.Appender; import io.prometheus.client.CollectorRegistry; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; @@ -15,12 +16,20 @@ import org.slf4j.LoggerFactory; import uk.gov.pay.adminusers.app.config.AdminUsersConfig; import uk.gov.pay.adminusers.app.config.ExpungeAndArchiveDataConfig; +import uk.gov.pay.adminusers.client.ledger.model.LedgerSearchTransactionsResponse; +import uk.gov.pay.adminusers.client.ledger.model.LedgerTransaction; +import uk.gov.pay.adminusers.client.ledger.service.LedgerService; +import uk.gov.pay.adminusers.fixtures.ServiceEntityFixture; import uk.gov.pay.adminusers.persistence.dao.ForgottenPasswordDao; import uk.gov.pay.adminusers.persistence.dao.InviteDao; +import uk.gov.pay.adminusers.persistence.dao.ServiceDao; import uk.gov.pay.adminusers.persistence.dao.UserDao; +import uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity; +import uk.gov.pay.adminusers.persistence.entity.ServiceEntity; import java.time.Clock; import java.time.Instant; +import java.time.ZonedDateTime; import java.util.List; import java.util.Optional; @@ -29,9 +38,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import static uk.gov.pay.adminusers.app.util.RandomIdGenerator.randomUuid; +import static uk.gov.pay.adminusers.fixtures.LedgerSearchTransactionsResponseFixture.aLedgerSearchTransactionsResponseFixture; +import static uk.gov.pay.adminusers.fixtures.LedgerTransactionFixture.aLedgerTransactionFixture; @ExtendWith(MockitoExtension.class) class ExpungeAndArchiveHistoricalDataServiceTest { @@ -42,6 +57,12 @@ class ExpungeAndArchiveHistoricalDataServiceTest { @Mock InviteDao mockInviteDao; + @Mock + ServiceDao mockServiceDao; + + @Mock + LedgerService mockLedgerService; + @Mock ForgottenPasswordDao mockForgottenPasswordDao; @@ -69,7 +90,7 @@ void setUp() { clock = Clock.fixed(Instant.parse(SYSTEM_INSTANT), UTC); when(mockAdminUsersConfig.getExpungeAndArchiveDataConfig()).thenReturn(mockExpungeAndArchiveConfig); expungeAndArchiveHistoricalDataService = new ExpungeAndArchiveHistoricalDataService(mockUserDao, - mockInviteDao, mockForgottenPasswordDao, mockAdminUsersConfig, clock); + mockInviteDao, mockForgottenPasswordDao, mockServiceDao, mockLedgerService, mockAdminUsersConfig, clock); } @Test @@ -84,6 +105,7 @@ void shouldNotDeleteHistoricalDataIfFlagIsNotEnabled() { verifyNoInteractions(mockUserDao); verifyNoInteractions(mockInviteDao); verifyNoInteractions(mockForgottenPasswordDao); + verifyNoInteractions(mockServiceDao); verify(mockAppender).doAppend(loggingEventArgumentCaptor.capture()); List loggingEvents = loggingEventArgumentCaptor.getAllValues(); @@ -91,7 +113,7 @@ void shouldNotDeleteHistoricalDataIfFlagIsNotEnabled() { } @Test - void shouldDeleteHistoricalDataIfFlagIsEnabled() { + void shouldDeleteHistoricalUserDataIfFlagIsEnabled() { Logger root = (Logger) LoggerFactory.getLogger(ExpungeAndArchiveHistoricalDataService.class); root.addAppender(mockAppender); root.setLevel(INFO); @@ -118,4 +140,158 @@ void shouldObserveJobDurationForMetrics() { Double duration = collectorRegistry.getSampleValue("expunge_and_archive_historical_data_job_duration_seconds_sum"); assertThat(duration, greaterThan(initialDuration)); } + + @Nested + class TestArchivingServices { + + ServiceEntity serviceEntity; + String gatewayAccountId1 = randomUuid(); + String gatewayAccountId2 = randomUuid(); + ZonedDateTime systemDate; + + GatewayAccountIdEntity gatewayAccountIdEntity1; + GatewayAccountIdEntity gatewayAccountIdEntity2; + + @BeforeEach + void setUp() { + when(mockExpungeAndArchiveConfig.isExpungeAndArchiveHistoricalDataEnabled()).thenReturn(true); + when(mockExpungeAndArchiveConfig.getArchiveServicesAfterDays()).thenReturn(7); + + gatewayAccountIdEntity1 = new GatewayAccountIdEntity(); + gatewayAccountIdEntity1.setGatewayAccountId(gatewayAccountId1); + + gatewayAccountIdEntity2 = new GatewayAccountIdEntity(); + gatewayAccountIdEntity2.setGatewayAccountId(gatewayAccountId2); + + serviceEntity = ServiceEntityFixture + .aServiceEntity() + .withArchived(false) + .withGatewayAccounts(List.of(gatewayAccountIdEntity1, gatewayAccountIdEntity2)) + .build(); + + systemDate = clock.instant().atZone(UTC); + } + + @Test + void shouldArchiveService_WhenTheLastTransactionDateIsBeforeTheServicesEligibleForArchivingDate() { + when(mockExpungeAndArchiveConfig.getArchiveServicesAfterDays()).thenReturn(7); + + LedgerTransaction ledgerTransaction1 = aLedgerTransactionFixture() + .withCreatedDate(systemDate.minusDays(10)) + .build(); + LedgerSearchTransactionsResponse searchTransactionsResponse1 = aLedgerSearchTransactionsResponseFixture() + .withTransactionList(List.of(ledgerTransaction1)) + .build(); + + LedgerTransaction ledgerTransaction2 = aLedgerTransactionFixture() + .withCreatedDate(systemDate.minusDays(20)) + .build(); + LedgerSearchTransactionsResponse searchTransactionsResponse2 = aLedgerSearchTransactionsResponseFixture() + .withTransactionList(List.of(ledgerTransaction2)) + .build(); + + when(mockLedgerService.searchTransactions(gatewayAccountId1, 1)).thenReturn(searchTransactionsResponse1); + when(mockLedgerService.searchTransactions(gatewayAccountId2, 1)).thenReturn(searchTransactionsResponse2); + when(mockServiceDao.findServicesToCheckForArchiving(systemDate.minusDays(7))).thenReturn(List.of(serviceEntity)); + + expungeAndArchiveHistoricalDataService.expungeAndArchiveHistoricalData(); + + assertTrue(serviceEntity.isArchived()); + verify(mockServiceDao).merge(serviceEntity); + } + + @Test + void shouldArchiveServiceWithoutTransactionsButCreatedBeforeTheServicesEligibleForArchivingDate() { + when(mockExpungeAndArchiveConfig.getArchiveServicesAfterDays()).thenReturn(7); + + LedgerSearchTransactionsResponse searchTransactionsResponse1 = aLedgerSearchTransactionsResponseFixture() + .withTransactionList(List.of()) + .build(); + when(mockLedgerService.searchTransactions(gatewayAccountId1, 1)).thenReturn(searchTransactionsResponse1); + + serviceEntity = ServiceEntityFixture + .aServiceEntity() + .withArchived(false) + .withCreatedDate(systemDate.minusDays(8)) + .withGatewayAccounts(List.of(gatewayAccountIdEntity1)) + .build(); + when(mockServiceDao.findServicesToCheckForArchiving(systemDate.minusDays(7))).thenReturn(List.of(serviceEntity)); + + expungeAndArchiveHistoricalDataService.expungeAndArchiveHistoricalData(); + + assertTrue(serviceEntity.isArchived()); + verify(mockServiceDao).merge(serviceEntity); + } + + @Test + void shouldNotArchiveService_WhenTheLastTransactionDateIsAfterTheServicesEligibleForArchivingDate() { + when(mockExpungeAndArchiveConfig.getArchiveServicesAfterDays()).thenReturn(7); + + LedgerSearchTransactionsResponse searchTransactionsResponse1 = aLedgerSearchTransactionsResponseFixture() + .withTransactionList(List.of()) + .build(); + + LedgerTransaction ledgerTransaction2 = aLedgerTransactionFixture() + .withCreatedDate(systemDate.plusDays(1)) + .build(); + LedgerSearchTransactionsResponse searchTransactionsResponse2 = aLedgerSearchTransactionsResponseFixture() + .withTransactionList(List.of(ledgerTransaction2)) + .build(); + + when(mockLedgerService.searchTransactions(gatewayAccountId1, 1)).thenReturn(searchTransactionsResponse1); + when(mockLedgerService.searchTransactions(gatewayAccountId2, 1)).thenReturn(searchTransactionsResponse2); + when(mockServiceDao.findServicesToCheckForArchiving(systemDate.minusDays(7))).thenReturn(List.of(serviceEntity)); + + expungeAndArchiveHistoricalDataService.expungeAndArchiveHistoricalData(); + + assertFalse(serviceEntity.isArchived()); + verifyNoMoreInteractions(mockServiceDao); + } + + @Test + void shouldNotArchiveServiceWithoutTransactionsAndCreatedIsAfterTheServicesEligibleForArchivingDate() { + when(mockExpungeAndArchiveConfig.getArchiveServicesAfterDays()).thenReturn(7); + + LedgerSearchTransactionsResponse searchTransactionsResponse1 = aLedgerSearchTransactionsResponseFixture() + .withTransactionList(List.of()) + .build(); + when(mockLedgerService.searchTransactions(gatewayAccountId1, 1)).thenReturn(searchTransactionsResponse1); + + serviceEntity = ServiceEntityFixture + .aServiceEntity() + .withArchived(false) + .withCreatedDate(systemDate) + .withGatewayAccounts(List.of(gatewayAccountIdEntity1)) + .build(); + when(mockServiceDao.findServicesToCheckForArchiving(systemDate.minusDays(7))).thenReturn(List.of(serviceEntity)); + + expungeAndArchiveHistoricalDataService.expungeAndArchiveHistoricalData(); + + assertFalse(serviceEntity.isArchived()); + verifyNoMoreInteractions(mockServiceDao); + } + + @Test + void shouldNotArchiveServiceWhenLedgerReturnsNoTransactionsAndCreatedDateIsNotAvailableOnService() { + when(mockExpungeAndArchiveConfig.getArchiveServicesAfterDays()).thenReturn(7); + + LedgerSearchTransactionsResponse searchTransactionsResponse1 = aLedgerSearchTransactionsResponseFixture() + .withTransactionList(List.of()) + .build(); + when(mockLedgerService.searchTransactions(gatewayAccountId1, 1)).thenReturn(searchTransactionsResponse1); + + serviceEntity = ServiceEntityFixture + .aServiceEntity() + .withArchived(false) + .withCreatedDate(null) + .withGatewayAccounts(List.of(gatewayAccountIdEntity1)) + .build(); + when(mockServiceDao.findServicesToCheckForArchiving(systemDate.minusDays(7))).thenReturn(List.of(serviceEntity)); + + expungeAndArchiveHistoricalDataService.expungeAndArchiveHistoricalData(); + + assertFalse(serviceEntity.isArchived()); + verifyNoMoreInteractions(mockServiceDao); + } + } } diff --git a/src/test/java/uk/gov/pay/adminusers/fixtures/LedgerSearchTransactionsResponseFixture.java b/src/test/java/uk/gov/pay/adminusers/fixtures/LedgerSearchTransactionsResponseFixture.java new file mode 100644 index 000000000..b637462c3 --- /dev/null +++ b/src/test/java/uk/gov/pay/adminusers/fixtures/LedgerSearchTransactionsResponseFixture.java @@ -0,0 +1,24 @@ +package uk.gov.pay.adminusers.fixtures; + +import uk.gov.pay.adminusers.client.ledger.model.LedgerSearchTransactionsResponse; +import uk.gov.pay.adminusers.client.ledger.model.LedgerTransaction; + +import java.util.List; + +public class LedgerSearchTransactionsResponseFixture { + + List transactionList; + + public static LedgerSearchTransactionsResponseFixture aLedgerSearchTransactionsResponseFixture() { + return new LedgerSearchTransactionsResponseFixture(); + } + + public LedgerSearchTransactionsResponseFixture withTransactionList(List transactions) { + this.transactionList = transactions; + return this; + } + + public LedgerSearchTransactionsResponse build() { + return new LedgerSearchTransactionsResponse(transactionList); + } +} diff --git a/src/test/java/uk/gov/pay/adminusers/fixtures/LedgerTransactionFixture.java b/src/test/java/uk/gov/pay/adminusers/fixtures/LedgerTransactionFixture.java index 9ccd35ac1..9f19500b1 100644 --- a/src/test/java/uk/gov/pay/adminusers/fixtures/LedgerTransactionFixture.java +++ b/src/test/java/uk/gov/pay/adminusers/fixtures/LedgerTransactionFixture.java @@ -2,10 +2,13 @@ import uk.gov.pay.adminusers.client.ledger.model.LedgerTransaction; +import java.time.ZonedDateTime; + public class LedgerTransactionFixture { private String transactionId; private String reference; + private ZonedDateTime createdDate; private LedgerTransactionFixture() { } @@ -25,13 +28,17 @@ public LedgerTransactionFixture withReference(String reference) { return this; } + public LedgerTransactionFixture withCreatedDate(ZonedDateTime createdDate) { + this.createdDate = createdDate; + return this; + } public LedgerTransaction build() { return new LedgerTransaction( transactionId, - reference + reference, + createdDate ); } - } diff --git a/src/test/resources/config/test-it-config.yaml b/src/test/resources/config/test-it-config.yaml index 3988f32a9..123dd5e01 100644 --- a/src/test/resources/config/test-it-config.yaml +++ b/src/test/resources/config/test-it-config.yaml @@ -134,3 +134,4 @@ ecsContainerMetadataUriV4: ${ECS_CONTAINER_METADATA_URI_V4:-} expungeAndArchiveDataConfig: expungeAndArchiveHistoricalDataEnabled: ${EXPUNGE_AND_ARCHIVE_HISTORICAL_DATA_ENABLED:-false} expungeUserDataAfterDays: ${EXPUNGE_USER_DATA_AFTER_DAYS:-1460} + archiveServicesAfterDays: ${EXPUNGE_ARCHIVE_SERVICES_AFTER_DAYS:-2555}