Skip to content

Commit

Permalink
[SELC-4894] fix: removed filePath from base builder and added only in…
Browse files Browse the repository at this point in the history
… standard builder (#300)
  • Loading branch information
empassaro authored Jun 10, 2024
1 parent e6238e8 commit ee2c0d1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public NotificationToSend buildNotificationToSend(Onboarding onboarding, Token t
notificationToSend.setId(UUID.randomUUID().toString());
}
notificationToSend.setState(convertOnboardingStatusToNotificationStatus(onboarding.getStatus()));
mapDataFromToken(token, notificationToSend);
mapDataFromOnboarding(onboarding, notificationToSend, queueEvent);
notificationToSend.setInstitution(retrieveInstitution(institution));
setTokenData(notificationToSend, token);

return notificationToSend;
}
Expand All @@ -86,17 +86,6 @@ private void mapDataFromOnboarding(Onboarding onboarding, NotificationToSend not
}
}

private void mapDataFromToken(Token token, NotificationToSend notificationToSend) {
if(Objects.isNull(token)) {
return;
}

notificationToSend.setProduct(token.getProductId());
notificationToSend.setFilePath(token.getContractSigned());
notificationToSend.setFileName(Objects.isNull(token.getContractSigned()) ? "" : Paths.get(token.getContractSigned()).getFileName().toString());
notificationToSend.setContentType(token.getContractSigned());
}

private String convertOnboardingStatusToNotificationStatus(OnboardingStatus status) {
if (status.equals(OnboardingStatus.DELETED)) {
return CLOSED;
Expand Down Expand Up @@ -189,4 +178,15 @@ private BillingToSend convertBilling(Billing billing) {
billingToSend.setRecipientCode(billing.getRecipientCode());
return billingToSend;
}

@Override
public void setTokenData(NotificationToSend notificationToSend, Token token) {
if(Objects.isNull(token)) {
return;
}

notificationToSend.setProduct(token.getProductId());
notificationToSend.setFileName(Objects.isNull(token.getContractSigned()) ? "" : Paths.get(token.getContractSigned()).getFileName().toString());
notificationToSend.setContentType(token.getContractSigned());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ default boolean shouldSendNotification(Onboarding onboarding, InstitutionRespons
return true;
}
InstitutionToNotify retrieveInstitution(InstitutionResponse institution);
void setTokenData(NotificationToSend notificationToSend, Token token);
void retrieveAndSetGeographicData(InstitutionToNotify institution);
BillingToSend retrieveBilling(Onboarding onboarding);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ public BillingToSend retrieveBilling(Onboarding onboarding) {
billing.setTaxCodeInvoicing(onboarding.getBilling().getTaxCodeInvoicing());
return billing;
}

@Override
public void setTokenData(NotificationToSend notificationToSend, Token token) {
super.setTokenData(notificationToSend, token);
notificationToSend.setFilePath(token.getContractSigned());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ void toNotificationToSendWhenOnboardingHasActivatedAtAndQueueEventAdd() {
assertNull(notification.getBilling().getTaxCodeInvoicing());
assertNull(notification.getBilling().isPublicServices());
assertEquals(onboarding.getBilling().isPublicServices(), notification.getBilling().isPublicService());
assertNull(notification.getFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void toNotificationToSendForEc() {
assertEquals("provinceAbbreviation", notification.getInstitution().getCounty());
assertEquals("countryAbbreviation", notification.getInstitution().getCountry());
assertEquals("desc", notification.getInstitution().getCity());
assertNull(notification.getFilePath());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void toNotificationToSendWhenOnboardingHasActivatedAtAndQueueEventAdd() {
assertEquals(tokenId, notification.getOnboardingTokenId());
assertEquals(onboarding.getActivatedAt(), notification.getCreatedAt().toLocalDateTime());
assertEquals(onboarding.getActivatedAt(), notification.getUpdatedAt().toLocalDateTime());
assertEquals(token.getContractSigned(), notification.getFilePath());
assertEquals(QueueEvent.ADD, notification.getNotificationType());
}

Expand Down

0 comments on commit ee2c0d1

Please sign in to comment.