Skip to content

Commit

Permalink
Merge pull request #153 from pagopa/bugfix/SELC-4079
Browse files Browse the repository at this point in the history
[SELC-4079] fix: Added custom method for upperCase on recipientCode in OnboardingMapper
  • Loading branch information
pierpaolodidato89 authored Feb 8, 2024
2 parents 8388d8b + 03e20fb commit 6b774d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
@Mapper(componentModel = "cdi")
public interface OnboardingMapper {

@Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))")
@Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase")
Onboarding toEntity(OnboardingPaRequest request);
@Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))")
@Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase")
Onboarding toEntity(OnboardingPspRequest request);
@Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))")
@Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase")
Onboarding toEntity(OnboardingDefaultRequest request);
@Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))")
@Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase")
Onboarding toEntity(OnboardingSaRequest request);

@Mapping(source = "taxCode", target = "institution.taxCode")
Expand All @@ -40,6 +40,7 @@ public interface OnboardingMapper {
default String objectIdToString(ObjectId objectId) {
return objectId.toHexString();
}

@Named("toUpperCase")
default String toUpperCase(String recipientCode) {
return Objects.nonNull(recipientCode) ? recipientCode.toUpperCase() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ void onboardingPa() {
.post("/pa")
.then()
.statusCode(200);

ArgumentCaptor<Onboarding> captor = ArgumentCaptor.forClass(Onboarding.class);
Mockito.verify(onboardingService, times(1))
.onboarding(captor.capture(), any());
assertEquals(captor.getValue().getBilling().getRecipientCode(), onboardingPaValid.getBilling().getRecipientCode().toUpperCase());

}

private OnboardingPaRequest dummyOnboardingPa() {
Expand Down

0 comments on commit 6b774d6

Please sign in to comment.