diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImpl.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImpl.java index 33360f03..373b3548 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImpl.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImpl.java @@ -111,7 +111,7 @@ private IngestionFlowFileDTO findIngestionFlowFileRecord(Long ingestionFlowFileI */ private File retrieveFile(IngestionFlowFileDTO ingestionFlowFileDTO) throws IOException { List paths = ingestionFlowFileRetrieverService - .retrieveAndUnzipFile(Path.of(ingestionFlowFileDTO.getFilePath()), ingestionFlowFileDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(ingestionFlowFileDTO.getFilePathName()), ingestionFlowFileDTO.getFileName()); return paths.getFirst().toFile(); } @@ -142,8 +142,8 @@ private Pair> parseData(File ingestionFlowFil * @throws IOException if an error occurs during file movement or directory creation. */ private void archive(IngestionFlowFileDTO ingestionFlowFileDTO) throws IOException { - Path originalFilePath = Paths.get(ingestionFlowFileDTO.getFilePath(), ingestionFlowFileDTO.getFileName()); - Path targetDirectory = Paths.get(ingestionFlowFileDTO.getFilePath(), archiveDirectory); + Path originalFilePath = Paths.get(ingestionFlowFileDTO.getFilePathName(), ingestionFlowFileDTO.getFileName()); + Path targetDirectory = Paths.get(ingestionFlowFileDTO.getFilePathName(), archiveDirectory); ingestionFlowFileArchiverService.archive(List.of(originalFilePath), targetDirectory); } diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityImpl.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityImpl.java index 042c907b..65c758a0 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityImpl.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityImpl.java @@ -79,6 +79,6 @@ private IngestionFlowFileDTO findIngestionFlowFileRecord(Long ingestionFlowFileI private List retrieveFiles(IngestionFlowFileDTO ingestionFlowFileDTO) throws IOException { return ingestionFlowFileRetrieverService - .retrieveAndUnzipFile(Path.of(ingestionFlowFileDTO.getFilePath()), ingestionFlowFileDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(ingestionFlowFileDTO.getFilePathName()), ingestionFlowFileDTO.getFileName()); } } diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/IngestionFlowFileDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/IngestionFlowFileDTO.java index 35e53653..52a3a5e5 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/IngestionFlowFileDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/IngestionFlowFileDTO.java @@ -7,8 +7,8 @@ import lombok.NoArgsConstructor; import java.io.Serializable; +import java.time.Instant; import java.time.LocalDateTime; -import java.util.Date; @Data @Builder(toBuilder = true) @@ -18,25 +18,25 @@ public class IngestionFlowFileDTO implements Serializable { private Long ingestionFlowFileId; private IngestionFlowFileType flowFileType; - private String mappedExternalUserId; private int version; private OrganizationDTO org; private String status; private String iuf; private Long numTotalRows; private Long numCorrectlyImportedRows; - private Date creationDate; - private Date lastUpdateDate; + private Instant creationDate; + private Instant lastUpdateDate; private boolean flagActive; - private String operatorName; + private String operatorExternalUserId; private Boolean flagSpontaneous; - private String filePath; + private String filePathName; private String fileName; private Long pdfGenerated; private String codRequestToken; private String codError; private String pspIdentifier; private LocalDateTime flowDateTime; + private Long fileSize; private String fileSourceCode; private String discardFileName; diff --git a/src/main/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverService.java b/src/main/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverService.java index 0cdd6856..8fbd2ad3 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverService.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverService.java @@ -25,7 +25,7 @@ public IngestionFlowFileEmailDestinationRetrieverService(AuthzService authzServi } public void configure(IngestionFlowFileDTO ingestionFlowFileDTO, EmailDTO emailDTO) { - UserInfo userInfoDTO = authzService.getOperatorInfo(ingestionFlowFileDTO.getMappedExternalUserId()); + UserInfo userInfoDTO = authzService.getOperatorInfo(ingestionFlowFileDTO.getOperatorExternalUserId()); Optional organizationDTO = organizationService.getOrganizationByIpaCode(ingestionFlowFileDTO.getOrg().getIpaCode()); emailDTO.setTo(new String[]{userInfoDTO.getEmail()}); diff --git a/src/main/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperService.java b/src/main/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperService.java index 91f6f2cf..b07ec0ee 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperService.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperService.java @@ -32,7 +32,7 @@ public List mapToDtoList(CtFlussoRiversamento ctFlussoRive PaymentsReportingDTO.PaymentsReportingDTOBuilder builder = PaymentsReportingDTO.builder() .creationDate(Instant.now()) .lastUpdateDate(Instant.now()) - .acquiringDate(ingestionFlowFileDTO.getCreationDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()) + .acquiringDate(ingestionFlowFileDTO.getCreationDate().atZone(ZoneId.systemDefault()).toLocalDate()) .organizationId(ingestionFlowFileDTO.getOrg().getOrgId()) .ingestionFlowFileId(ingestionFlowFileDTO.getIngestionFlowFileId()) .pspIdentifier(ctFlussoRiversamento.getIstitutoMittente().getDenominazioneMittente()) diff --git a/src/test/java/it/gov/pagopa/payhub/activities/activity/debtposition/SaveDebtPositionActivityTest.java b/src/test/java/it/gov/pagopa/payhub/activities/activity/debtposition/SaveDebtPositionActivityTest.java index 3337d372..13df96e8 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/activity/debtposition/SaveDebtPositionActivityTest.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/activity/debtposition/SaveDebtPositionActivityTest.java @@ -10,12 +10,12 @@ import org.mockito.junit.jupiter.MockitoExtension; import static it.gov.pagopa.payhub.activities.utility.faker.DebtPositionFaker.buildDebtPositionDTO; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class SaveDebtPositionActivityTest { +class SaveDebtPositionActivityTest { @Mock private DebtPositionDao debtPositionDao; @@ -29,12 +29,13 @@ void init(){ @Test void givenSaveDebtPositionThenSuccess() { - Mockito.when(debtPositionDao.save(buildDebtPositionDTO())).thenReturn(buildDebtPositionDTO()); + DebtPositionDTO debtPosition = buildDebtPositionDTO(); + Mockito.when(debtPositionDao.save(debtPosition)).thenReturn(debtPosition); - DebtPositionDTO debtPosition = - saveDebtPositionActivity.saveDebtPosition(buildDebtPositionDTO()); + DebtPositionDTO result = + saveDebtPositionActivity.saveDebtPosition(debtPosition); - verify(debtPositionDao, times(1)).save(buildDebtPositionDTO()); - assertEquals(debtPosition, buildDebtPositionDTO()); + verify(debtPositionDao, times(1)).save(debtPosition); + assertSame(result, debtPosition); } } diff --git a/src/test/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImplTest.java b/src/test/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImplTest.java index a4a64712..83071c5f 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImplTest.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/PaymentsReportingIngestionFlowFileActivityImplTest.java @@ -89,10 +89,10 @@ void givenSuccessfullConditionsWhenProcessFileThenOk() throws IOException { IngestionFlowFileDTO mockFlowDTO = IngestionFlowFileDTO.builder() .ingestionFlowFileId(ingestionFlowFileId) .fileName("valid-file.zip") - .filePath(workingDir.toString()) + .filePathName(workingDir.toString()) .flowFileType(FLOW_FILE_TYPE) .build(); - Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePath()).resolve(mockFlowDTO.getFileName())); + Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePathName()).resolve(mockFlowDTO.getFileName())); List mockedListPath = List.of(filePath); ctFlussoRiversamento.setIdentificativoFlusso("idFlow"); List dtoList = List.of(PaymentsReportingDTO.builder().flowIdentifierCode("idFlow").build()); @@ -102,14 +102,14 @@ void givenSuccessfullConditionsWhenProcessFileThenOk() throws IOException { when(ingestionFlowFileDaoMock.findById(ingestionFlowFileId)).thenReturn(Optional.of(mockFlowDTO)); doReturn(mockedListPath).when(ingestionFlowFileRetrieverServiceMock) - .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePath()), mockFlowDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePathName()), mockFlowDTO.getFileName()); when(flussoRiversamentoUnmarshallerServiceMock.unmarshal(filePath.toFile())).thenReturn(ctFlussoRiversamento); doNothing().when(paymentsReportingIngestionFlowFileValidatorServiceMock).validateOrganization(ctFlussoRiversamento, mockFlowDTO); when(paymentsReportingMapperServiceMock.mapToDtoList(ctFlussoRiversamento, mockFlowDTO)).thenReturn(dtoList); doReturn(dtoList).when(paymentsReportingDaoMock).saveAll(dtoList); doNothing().when(ingestionFlowFileArchiverServiceMock) - .archive(mockedListPath, Path.of(mockFlowDTO.getFilePath(), TARGET_DIR)); + .archive(mockedListPath, Path.of(mockFlowDTO.getFilePathName(), TARGET_DIR)); // When PaymentsReportingIngestionFlowFileActivityResult result = ingestionActivity.processFile(ingestionFlowFileId); @@ -140,7 +140,7 @@ void givenIngestionFlowFileRetrieverServiceExceptionWhenProcessFileThenFails() t IngestionFlowFileDTO mockFlowDTO = IngestionFlowFileDTO.builder() .ingestionFlowFileId(ingestionFlowFileId) .fileName("valid-file.zip") - .filePath(workingDir.toString()) + .filePathName(workingDir.toString()) .flowFileType(FLOW_FILE_TYPE) .build(); @@ -148,7 +148,7 @@ void givenIngestionFlowFileRetrieverServiceExceptionWhenProcessFileThenFails() t doThrow(new RuntimeException("Setup process failed")) .when(ingestionFlowFileRetrieverServiceMock) - .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePath()), mockFlowDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePathName()), mockFlowDTO.getFileName()); // When PaymentsReportingIngestionFlowFileActivityResult result = ingestionActivity.processFile(ingestionFlowFileId); @@ -157,7 +157,7 @@ void givenIngestionFlowFileRetrieverServiceExceptionWhenProcessFileThenFails() t assertFalse(result.isSuccess()); verify(ingestionFlowFileDaoMock, times(1)).findById(ingestionFlowFileId); verify(ingestionFlowFileRetrieverServiceMock, times(1)) - .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePath()), mockFlowDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePathName()), mockFlowDTO.getFileName()); } @Test @@ -167,17 +167,17 @@ void givenUnmarshallingExceptionWhenProcessFileThenFails() throws Exception { IngestionFlowFileDTO mockFlowDTO = IngestionFlowFileDTO.builder() .ingestionFlowFileId(ingestionFlowFileId) .fileName("valid-file.zip") - .filePath(workingDir.toString()) + .filePathName(workingDir.toString()) .flowFileType(FLOW_FILE_TYPE) .build(); - Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePath()).resolve(mockFlowDTO.getFileName())); + Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePathName()).resolve(mockFlowDTO.getFileName())); List mockedListPath = List.of(filePath); PaymentsReportingIngestionFlowFileActivityResult expected = new PaymentsReportingIngestionFlowFileActivityResult(Collections.emptyList(), false, "error occured"); when(ingestionFlowFileDaoMock.findById(ingestionFlowFileId)).thenReturn(Optional.of(mockFlowDTO)); doReturn(mockedListPath).when(ingestionFlowFileRetrieverServiceMock) - .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePath()), mockFlowDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePathName()), mockFlowDTO.getFileName()); when(flussoRiversamentoUnmarshallerServiceMock.unmarshal(filePath.toFile())).thenThrow(new ActivitiesException("error occured")); // When PaymentsReportingIngestionFlowFileActivityResult result = ingestionActivity.processFile(ingestionFlowFileId); @@ -210,11 +210,11 @@ void givenValidationExceptionWhenProcessFileThenFails() throws Exception { IngestionFlowFileDTO mockFlowDTO = IngestionFlowFileDTO.builder() .ingestionFlowFileId(ingestionFlowFileId) .fileName("valid-file.zip") - .filePath(workingDir.toString()) + .filePathName(workingDir.toString()) .flowFileType(FLOW_FILE_TYPE) .org(OrganizationDTO.builder().orgFiscalCode("0").build()) .build(); - Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePath()).resolve(mockFlowDTO.getFileName())); + Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePathName()).resolve(mockFlowDTO.getFileName())); List mockedListPath = List.of(filePath); ctFlussoRiversamento.setIdentificativoFlusso("idFlow"); PaymentsReportingIngestionFlowFileActivityResult expected = @@ -222,7 +222,7 @@ void givenValidationExceptionWhenProcessFileThenFails() throws Exception { when(ingestionFlowFileDaoMock.findById(ingestionFlowFileId)).thenReturn(Optional.of(mockFlowDTO)); doReturn(mockedListPath).when(ingestionFlowFileRetrieverServiceMock) - .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePath()), mockFlowDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePathName()), mockFlowDTO.getFileName()); when(flussoRiversamentoUnmarshallerServiceMock.unmarshal(filePath.toFile())).thenReturn(ctFlussoRiversamento); doThrow(new InvalidIngestionFlowFileDataException("invalid")) .when(paymentsReportingIngestionFlowFileValidatorServiceMock).validateOrganization(ctFlussoRiversamento, mockFlowDTO); @@ -241,10 +241,10 @@ void givenPaymentsReportingExceptionWhenProcessFileThenFails() throws Exception IngestionFlowFileDTO mockFlowDTO = IngestionFlowFileDTO.builder() .ingestionFlowFileId(ingestionFlowFileId) .fileName("valid-file.zip") - .filePath(workingDir.toString()) + .filePathName(workingDir.toString()) .flowFileType(FLOW_FILE_TYPE) .build(); - Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePath()).resolve(mockFlowDTO.getFileName())); + Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePathName()).resolve(mockFlowDTO.getFileName())); List mockedListPath = List.of(filePath); ctFlussoRiversamento = new CtFlussoRiversamento(); ctFlussoRiversamento.setIdentificativoFlusso("idFlow"); @@ -255,7 +255,7 @@ void givenPaymentsReportingExceptionWhenProcessFileThenFails() throws Exception when(ingestionFlowFileDaoMock.findById(ingestionFlowFileId)).thenReturn(Optional.of(mockFlowDTO)); doReturn(mockedListPath).when(ingestionFlowFileRetrieverServiceMock) - .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePath()), mockFlowDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePathName()), mockFlowDTO.getFileName()); when(flussoRiversamentoUnmarshallerServiceMock.unmarshal(filePath.toFile())).thenReturn(ctFlussoRiversamento); doNothing().when(paymentsReportingIngestionFlowFileValidatorServiceMock).validateOrganization(ctFlussoRiversamento, mockFlowDTO); @@ -276,10 +276,10 @@ void givenIOExceptionWhenProcessFileThenFails() throws IOException { IngestionFlowFileDTO mockFlowDTO = IngestionFlowFileDTO.builder() .ingestionFlowFileId(ingestionFlowFileId) .fileName("valid-file.zip") - .filePath(workingDir.toString()) + .filePathName(workingDir.toString()) .flowFileType(FLOW_FILE_TYPE) .build(); - Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePath()).resolve(mockFlowDTO.getFileName())); + Path filePath = Files.createFile(Path.of(mockFlowDTO.getFilePathName()).resolve(mockFlowDTO.getFileName())); List mockedListPath = List.of(filePath); ctFlussoRiversamento = new CtFlussoRiversamento(); ctFlussoRiversamento.setIdentificativoFlusso("idFlow"); @@ -290,7 +290,7 @@ void givenIOExceptionWhenProcessFileThenFails() throws IOException { when(ingestionFlowFileDaoMock.findById(ingestionFlowFileId)).thenReturn(Optional.of(mockFlowDTO)); doReturn(mockedListPath).when(ingestionFlowFileRetrieverServiceMock) - .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePath()), mockFlowDTO.getFileName()); + .retrieveAndUnzipFile(Path.of(mockFlowDTO.getFilePathName()), mockFlowDTO.getFileName()); when(flussoRiversamentoUnmarshallerServiceMock.unmarshal(filePath.toFile())).thenReturn(ctFlussoRiversamento); doNothing().when(paymentsReportingIngestionFlowFileValidatorServiceMock).validateOrganization(ctFlussoRiversamento, mockFlowDTO); @@ -298,7 +298,7 @@ void givenIOExceptionWhenProcessFileThenFails() throws IOException { doReturn(dtoList).when(paymentsReportingDaoMock).saveAll(dtoList); doThrow(new IOException("error occured")).when(ingestionFlowFileArchiverServiceMock) - .archive(mockedListPath, Path.of(mockFlowDTO.getFilePath(), TARGET_DIR)); + .archive(mockedListPath, Path.of(mockFlowDTO.getFilePathName(), TARGET_DIR)); // When PaymentsReportingIngestionFlowFileActivityResult result = ingestionActivity.processFile(ingestionFlowFileId); diff --git a/src/test/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityTest.java b/src/test/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityTest.java index 45657158..479b757a 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityTest.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/activity/treasury/TreasuryOpiIngestionActivityTest.java @@ -6,7 +6,6 @@ import it.gov.pagopa.payhub.activities.enums.IngestionFlowFileType; import it.gov.pagopa.payhub.activities.service.ingestionflow.IngestionFlowFileRetrieverService; import it.gov.pagopa.payhub.activities.service.treasury.TreasuryOpiParserService; -import it.gov.pagopa.payhub.activities.service.treasury.TreasuryUnmarshallerService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,8 +30,6 @@ class TreasuryOpiIngestionActivityTest { @Mock private IngestionFlowFileRetrieverService ingestionFlowFileRetrieverService; @Mock - private TreasuryUnmarshallerService treasuryUnmarshallerService; - @Mock private TreasuryOpiParserService treasuryOpiParserService; private TreasuryOpiIngestionActivity treasuryOpiIngestionActivity; @@ -60,7 +57,7 @@ void givenValidIngestionFlowWhenProcessFileThenOk() throws IOException { Long ingestionFlowFileId = 1L; IngestionFlowFileDTO ingestionFlowFileDTO = new IngestionFlowFileDTO(); ingestionFlowFileDTO.setFlowFileType(IngestionFlowFileType.OPI); - ingestionFlowFileDTO.setFilePath("/test/path"); + ingestionFlowFileDTO.setFilePathName("/test/path"); ingestionFlowFileDTO.setFileName("testFile.zip"); Path mockPath = mock(Path.class); diff --git a/src/test/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverServiceTest.java b/src/test/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverServiceTest.java index 720587b9..23476b19 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverServiceTest.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/service/ingestionflow/email/IngestionFlowFileEmailDestinationRetrieverServiceTest.java @@ -50,7 +50,7 @@ void givenNoOrganizationWhenConfigureThenOk() { IngestionFlowFileDTO ingestionFlowFileDTO = IngestionFlowFileFaker.buildIngestionFlowFileDTO(); UserInfo userInfo = UserInfoFaker.buildUserInfo(); - Mockito.when(authzServiceMock.getOperatorInfo(ingestionFlowFileDTO.getMappedExternalUserId())) + Mockito.when(authzServiceMock.getOperatorInfo(ingestionFlowFileDTO.getOperatorExternalUserId())) .thenReturn(userInfo); Mockito.when(organizationServiceMock.getOrganizationByIpaCode(ingestionFlowFileDTO.getOrg().getIpaCode())) @@ -74,7 +74,7 @@ void givenOrganizationWithSameEmailWhenConfigureThenOk() { OrganizationDTO organizationDTO = OrganizationFaker.buildOrganizationDTO(); organizationDTO.setAdminEmail(userInfo.getEmail()); - Mockito.when(authzServiceMock.getOperatorInfo(ingestionFlowFileDTO.getMappedExternalUserId())) + Mockito.when(authzServiceMock.getOperatorInfo(ingestionFlowFileDTO.getOperatorExternalUserId())) .thenReturn(userInfo); Mockito.when(organizationServiceMock.getOrganizationByIpaCode(ingestionFlowFileDTO.getOrg().getIpaCode())) @@ -97,7 +97,7 @@ void givenOrganizationWithDifferentEmailWhenConfigureThenOk() { UserInfo userInfo = UserInfoFaker.buildUserInfo(); OrganizationDTO organizationDTO = OrganizationFaker.buildOrganizationDTO(); - Mockito.when(authzServiceMock.getOperatorInfo(ingestionFlowFileDTO.getMappedExternalUserId())) + Mockito.when(authzServiceMock.getOperatorInfo(ingestionFlowFileDTO.getOperatorExternalUserId())) .thenReturn(userInfo); Mockito.when(organizationServiceMock.getOrganizationByIpaCode(ingestionFlowFileDTO.getOrg().getIpaCode())) diff --git a/src/test/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperServiceTest.java b/src/test/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperServiceTest.java index 739481e7..972117fd 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperServiceTest.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/service/paymentsreporting/PaymentsReportingMapperServiceTest.java @@ -11,6 +11,7 @@ import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigDecimal; +import java.time.Instant; import java.util.GregorianCalendar; import java.util.List; @@ -20,11 +21,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; class PaymentsReportingMapperServiceTest { - private PaymentsReportingMapperService mapper = new PaymentsReportingMapperService(); + private final PaymentsReportingMapperService mapper = new PaymentsReportingMapperService(); @Test void testMapper() throws DatatypeConfigurationException { - GregorianCalendar gregorianCalendar = new GregorianCalendar(2024, 12, 25); + GregorianCalendar gregorianCalendar = new GregorianCalendar(2024, GregorianCalendar.DECEMBER, 25); // Given CtFlussoRiversamento ctFlussoRiversamento = new CtFlussoRiversamento(); @@ -57,7 +58,7 @@ void testMapper() throws DatatypeConfigurationException { IngestionFlowFileDTO ingestionFlowFileDTO = new IngestionFlowFileDTO(); ingestionFlowFileDTO.setOrg(OrganizationDTO.builder().orgId(1L).build()); ingestionFlowFileDTO.setIngestionFlowFileId(1L); - ingestionFlowFileDTO.setCreationDate(TestUtils.DATE); + ingestionFlowFileDTO.setCreationDate(Instant.now()); CtDatiSingoliPagamenti singlePayment = new CtDatiSingoliPagamenti(); singlePayment.setIdentificativoUnivocoVersamento("vers123"); @@ -67,12 +68,12 @@ void testMapper() throws DatatypeConfigurationException { singlePayment.setCodiceEsitoSingoloPagamento("OK"); singlePayment.setDataEsitoSingoloPagamento(toXMLGregorianCalendar(gregorianCalendar)); - ctFlussoRiversamento.getDatiSingoliPagamenti().addAll(List.of(singlePayment)); + ctFlussoRiversamento.getDatiSingoliPagamenti().add(singlePayment); // When List result = mapper.mapToDtoList(ctFlussoRiversamento, ingestionFlowFileDTO); - PaymentsReportingDTO firstDTO = result.get(0); + PaymentsReportingDTO firstDTO = result.getFirst(); // Then assertEquals(1, result.size()); assertEquals("flow123", firstDTO.getFlowIdentifierCode()); diff --git a/src/test/java/it/gov/pagopa/payhub/activities/util/TestUtils.java b/src/test/java/it/gov/pagopa/payhub/activities/util/TestUtils.java index 853de9df..bb1b9828 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/util/TestUtils.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/util/TestUtils.java @@ -2,10 +2,7 @@ import org.junit.jupiter.api.Assertions; -import java.time.LocalDateTime; -import java.time.ZoneId; import java.util.Arrays; -import java.util.Date; import java.util.HashSet; import java.util.Set; @@ -25,10 +22,4 @@ public static void checkNotNullFields(Object o, String... excludedFields) { f -> !excludedFieldsSet.contains(f.getName())); } - public static final Date DATE = Date.from( - LocalDateTime.of(2024, 5, 15, 10, 30, 0) - .atZone(ZoneId.systemDefault()) - .toInstant() - ); - } diff --git a/src/test/java/it/gov/pagopa/payhub/activities/utility/faker/IngestionFlowFileFaker.java b/src/test/java/it/gov/pagopa/payhub/activities/utility/faker/IngestionFlowFileFaker.java index 26714ffb..351ff8d9 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/utility/faker/IngestionFlowFileFaker.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/utility/faker/IngestionFlowFileFaker.java @@ -4,12 +4,11 @@ import it.gov.pagopa.payhub.activities.dto.OrganizationDTO; import it.gov.pagopa.payhub.activities.enums.IngestionFlowFileType; +import java.time.Instant; import java.time.ZoneId; -import java.util.Date; public class IngestionFlowFileFaker { - public static final Date now = new Date(); public static IngestionFlowFileDTO buildIngestionFlowFileDTO(){ return IngestionFlowFileDTO.builder() @@ -20,18 +19,18 @@ public static IngestionFlowFileDTO buildIngestionFlowFileDTO(){ .iuf("iuf") .numTotalRows(3L) .numCorrectlyImportedRows(2L) - .creationDate(now) - .lastUpdateDate(now) + .creationDate(Instant.now()) + .lastUpdateDate(Instant.now()) .flagActive(true) - .operatorName("operatorName") + .operatorExternalUserId("operatorExternalId") .flagSpontaneous(Boolean.TRUE) - .filePath("filePathName") + .filePathName("filePathName") .fileName("fileName") .pdfGenerated(2L) .codRequestToken("codRequestToken") .codError("codError") .pspIdentifier("PspId") - .flowDateTime(now.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()) + .flowDateTime(Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime()) .fileSourceCode("FileSourceCode") .discardFileName("DiscardFileName") .flowFileType(IngestionFlowFileType.PAYMENTS_REPORTING)