Skip to content

Commit

Permalink
[P4ADEV-2179] added payer mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mscarsel committed Feb 14, 2025
1 parent 46ae306 commit b353ae0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public ReceiptDetailDTO mapToReceiptDetailDTO(ReceiptDetailNoPIIView receiptDeta
.pspCompanyName(receiptDetailNoPIIView.getPspCompanyName())
.iud(receiptDetailNoPIIView.getIud())
.iur(receiptDetailNoPIIView.getIur())
.debtor(personMapper.mapToDto(pii.getDebtor()))
.debtor(pii.getDebtor()!=null?personMapper.mapToDto(pii.getDebtor()):null)
.payer(pii.getPayer()!=null?personMapper.mapToDto(pii.getPayer()):null)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,27 @@ void givenValidReceiptNoPIIWhenMapToReceiptDTOThenReturnReceiptDTO() {
Assertions.assertNotNull(response);
TestUtils.reflectionEqualsByName(receiptDetailNoPIIView, response, "debtor", "payer");
TestUtils.reflectionEqualsByName(receiptPIIDTO.getDebtor(), response.getDebtor());
TestUtils.checkNotNullFields(response,"payer");
TestUtils.reflectionEqualsByName(receiptPIIDTO.getPayer(), response.getPayer());
TestUtils.checkNotNullFields(response);
Mockito.verify(personalDataServiceMock).get(receiptDetailNoPIIView.getDebtorPersonalDataId(),ReceiptPIIDTO.class);
Mockito.verify(personMapperSpy).mapToDto(receiptPIIDTO.getDebtor());
Mockito.verify(personMapperSpy).mapToDto(receiptPIIDTO.getPayer());
}

@Test
void givenNoPayerAndDebtorWhenMapToReceiptDTOThenReturnReceiptDTOWithNoPayerAndDebtor() {
//given
ReceiptDetailNoPIIView receiptDetailNoPIIView = podamFactory.manufacturePojo(ReceiptDetailNoPIIView.class);
ReceiptPIIDTO receiptPIIDTO = new ReceiptPIIDTO();
Mockito.when(personalDataServiceMock.get(receiptDetailNoPIIView.getDebtorPersonalDataId(),ReceiptPIIDTO.class)).thenReturn(receiptPIIDTO);
//when
ReceiptDetailDTO response = receiptDetailPIIViewMapper.mapToReceiptDetailDTO(receiptDetailNoPIIView);

//verify
Assertions.assertNotNull(response);
TestUtils.reflectionEqualsByName(receiptDetailNoPIIView, response, "debtor", "payer");
TestUtils.checkNotNullFields(response, "payer", "debtor");
Mockito.verify(personalDataServiceMock).get(receiptDetailNoPIIView.getDebtorPersonalDataId(),ReceiptPIIDTO.class);
Mockito.verifyNoInteractions(personMapperSpy);
}
}

0 comments on commit b353ae0

Please sign in to comment.