Skip to content

Commit

Permalink
Merge pull request #400 from pagopa/develop
Browse files Browse the repository at this point in the history
Promote to PROD
  • Loading branch information
lucaconsalvi authored Jun 10, 2024
2 parents 0730b2e + 8912492 commit 0a1da8d
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -141,6 +140,8 @@ public class TransactionFilterBatchFileReportTest {
@SpyBean
StoreService storeServiceSpy;

private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;

@Rule
public TemporaryFolder tempFolder = new TemporaryFolder(
new File(getClass().getResource("/test-encrypt").getFile()));
Expand Down Expand Up @@ -181,7 +182,7 @@ public void cleanUp() {
@SneakyThrows
@Test
public void jobExecutionProducesExpectedFiles() {
LocalDateTime currentDate = LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
LocalDateTime currentDate = LocalDateTime.now();
String publicKey = createPublicKey();
BDDMockito.doReturn(publicKey).when(storeServiceSpy).getKey("pagopa");
BDDMockito.doReturn(getStubFileReport(currentDate)).when(fileReportRestClient).getFileReport();
Expand Down Expand Up @@ -314,21 +315,21 @@ public void jobExecutionProducesExpectedFiles() {
.orElse(new File("")).toPath());
assertThat(fileReportContent).isNotNull().containsExactly("[",
" {\"name\":\"file1\",\"size\":200,\"status\":\"RECEIVED\",\"transmissionDate\":\""
+ currentDate
+ currentDate.format(dateFormatter)
+ "\",\"dataSummary\":{}},",
" {\"name\":\"file2\",\"size\":300,\"status\":\"RECEIVED\",\"transmissionDate\":\""
+ currentDate.minusDays(4)
+ currentDate.minusDays(4).format(dateFormatter)
+ "\",\"dataSummary\":{}},",
" {\"name\":\"file3\",\"size\":400,\"status\":\"RECEIVED\",\"transmissionDate\":\""
+ currentDate.minusDays(10)
+ currentDate.minusDays(10).format(dateFormatter)
+ "\",\"dataSummary\":{}}",
"]");
}

@Test
@SneakyThrows
public void givenAReportWhenLaunchFileReportStepThenSaveTheReportOnFile() {
LocalDateTime currentDate = LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
LocalDateTime currentDate = LocalDateTime.now();
BDDMockito.doReturn(getStubFileReport(currentDate)).when(fileReportRestClient).getFileReport();

jobLauncherTestUtils.launchStep("file-report-recovery-step",
Expand All @@ -342,17 +343,16 @@ public void givenAReportWhenLaunchFileReportStepThenSaveTheReportOnFile() {
List<String> fileReportContent = Files.readAllLines(fileReportSaved.stream().findAny()
.orElse(new File("")).toPath());


assertThat(fileReportContent).isNotNull().containsExactly("[",
" {\"name\":\"file1\",\"size\":200,\"status\":\"RECEIVED\",\"transmissionDate\":\""
+ currentDate
+ currentDate.format(dateFormatter)
+ "\",\"dataSummary\":{}},",
" {\"name\":\"file2\",\"size\":300,\"status\":\"RECEIVED\",\"transmissionDate\":\""
+ currentDate.minusDays(4)
+ currentDate.minusDays(4).format(dateFormatter)
+ "\",\"dataSummary\":{}},",

" {\"name\":\"file3\",\"size\":400,\"status\":\"RECEIVED\",\"transmissionDate\":\""
+ currentDate.minusDays(10)
+ currentDate.minusDays(10).format(dateFormatter)
+ "\",\"dataSummary\":{}}",

"]");
Expand Down

0 comments on commit 0a1da8d

Please sign in to comment.