Skip to content

Commit

Permalink
[SELC-5086] Fix: InstitutionMapper for null billing (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo authored Jun 14, 2024
1 parent b5396bc commit 730d2f2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public List<OnboardedInstitutionInfo> getInstitutionDetails(String institutionId
@Override
public String createPgInstitution(String description, String taxId) {
log.trace("createPgInstitution start");
CreatePgInstitutionRequest createPgInstitutionRequest = new CreatePgInstitutionRequest(description, false, taxId);
CreatePgInstitutionRequest createPgInstitutionRequest = new CreatePgInstitutionRequest(description, true, taxId);
InstitutionResponse institutionResponse = Objects.requireNonNull(institutionApiClient.
_createPgInstitutionUsingPOST(createPgInstitutionRequest)
.getBody());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ static AssistanceContacts toAssistanceContacts(InstitutionResponse dto) {
@Named("setBillingData")
static Billing setBillingData(List<OnboardedProductResponse> onboardings) {
if(Objects.nonNull(onboardings) && !onboardings.isEmpty()) {
Billing billing = new Billing();
Billing billing = null;
BillingResponse billingResponse = onboardings.get(0).getBilling();
billing.setRecipientCode(billingResponse.getRecipientCode());
billing.setVatNumber(billingResponse.getVatNumber());
billing.setPublicServices(billingResponse.getPublicServices());
if(Objects.nonNull(billingResponse)) {
billing = new Billing();
billing.setRecipientCode(billingResponse.getRecipientCode());
billing.setVatNumber(billingResponse.getVatNumber());
billing.setPublicServices(billingResponse.getPublicServices());
}
return billing;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,30 @@ void createPgInstitution() {
assertEquals(institutionId, institutionPnPgResponse);

}

@Test
void getInstitutionsDetailsBillingNull() throws IOException {
String institutionId = "institutionId";

ClassPathResource resource = new ClassPathResource("stubs/institutionResponse.json");
byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath());
InstitutionResponse response = objectMapper.readValue(resourceStream, new TypeReference<>() {
});
response.getOnboarding().forEach(onboardedProductResponse -> onboardedProductResponse.setBilling(null));

when(institutionApiClient._retrieveInstitutionByIdUsingGET(anyString()))
.thenReturn(ResponseEntity.of(Optional.of(response)));

ClassPathResource expectationResource = new ClassPathResource("stubs/OnboardedInstitutionInfo.json");
byte[] expectationStream = Files.readAllBytes(expectationResource.getFile().toPath());
List<OnboardedInstitutionInfo> expectation = objectMapper.readValue(expectationStream, new TypeReference<>() {
});
expectation.forEach(onboardedInstitutionInfo -> onboardedInstitutionInfo.setBilling(null));

List<OnboardedInstitutionInfo> onboardedInstitutionInfos = msCoreConnector.getInstitutionDetails(institutionId);
assertEquals(1, onboardedInstitutionInfos.size());
assertEquals(expectation, onboardedInstitutionInfos);
verify(institutionApiClient, times(1))._retrieveInstitutionByIdUsingGET(institutionId);

}
}

0 comments on commit 730d2f2

Please sign in to comment.