Skip to content

Commit

Permalink
[PAGOPA-2113] test(Recovery): Add testRecoverReceiptKOAll_notEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-ang committed Sep 17, 2024
1 parent 0382dd1 commit 858096e
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.junit.jupiter.api.Test;
import org.mockito.*;

import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -77,7 +78,6 @@ public void testRecoverReceiptKO() throws Exception {
verify(cacheRepository, times(2)).insert(anyString(), anyString(), anyLong(), any(ChronoUnit.class), anyBoolean());
}


@Test
public void testRecoverReceiptKOAll() {
// Arrange
Expand All @@ -94,6 +94,32 @@ public void testRecoverReceiptKOAll() {
assertEquals(0, recoveredReceipt);
}

@Test
public void testRecoverReceiptKOAll_notEmpty() {
// Arrange
ZonedDateTime dateFrom = ZonedDateTime.now(ZoneOffset.UTC).minusHours(5);
ZonedDateTime dateTo = ZonedDateTime.now(ZoneOffset.UTC).minusHours(4);
List<RTEntity> mockRTEntities = List.of(RTEntity.builder()
.iuv("iuv")
.ccp("ccp")
.idDominio("idDominio")
.build());
List<ReEventEntity> mockReEventEntities = List.of(ReEventEntity.builder()
.status("GENERATED_CACHE_ABOUT_RPT_FOR_RT_GENERATION")
.ccp("ccp2")
.insertedTimestamp(Instant.now())
.build());

when(rtRepository.findPendingRT(anyString(), anyString())).thenReturn(mockRTEntities);
when(reRepository.findByIuvAndOrganizationId(anyString(), anyString(), anyString(), anyString())).thenReturn(mockReEventEntities);

// Act
int recoveredReceipt = recoveryService.recoverReceiptKOAll(dateFrom, dateTo);

// Assert
assertEquals(1, recoveredReceipt);
}

@Test
public void testRecoverMissingRedirect() {
// Arrange
Expand Down

0 comments on commit 858096e

Please sign in to comment.