Skip to content

Commit

Permalink
SELC-4785 fix: added distinct billing in model of message to send
Browse files Browse the repository at this point in the history
  • Loading branch information
empassaro committed May 21, 2024
1 parent 8f9cdf3 commit 62100c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package it.pagopa.selfcare.external_interceptor.connector.model.institution;

import lombok.Data;

@Data
public class BillingToSend {
private String vatNumber;
private String recipientCode;
private boolean publicService;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class NotificationToSend {
private InstitutionToSend institution;
private String fileName;
private String contentType;
private Billing billing;
private BillingToSend billing;
private UserToSend user;

}
Original file line number Diff line number Diff line change
Expand Up @@ -158,53 +158,6 @@ void sendInstitutionNotificationEc() throws JsonProcessingException {
checkNotNullFields(captured.getInstitution(), "rootParent");
}

@Test
void sendInstitutionNotificationUOWithTaxCodeInvoicing() throws JsonProcessingException {
//given
final Notification notification = createNotificationMock();
Institution institution = mockInstance(new Institution(), "setCity", "setRootParent");
institution.setSubUnitType("UO");
institution.setOrigin("IPA");
institution.setInstitutionType(InstitutionType.PA);
final Billing billing = createBillingMock();
notification.setInstitution(institution);
notification.setBilling(billing);
notification.setProduct("prod-io-premium");
notification.setState("ACTIVE");
OrganizationUnit organizationUnit = mockInstance(new OrganizationUnit());
GeographicTaxonomies proxyTaxonomy = mockInstance(new GeographicTaxonomies());
proxyTaxonomy.setCountry("proxyContry");
proxyTaxonomy.setProvinceAbbreviation("proxyProvince");
proxyTaxonomy.setDescription("proxyCity - COMUNE");
proxyTaxonomy.setIstatCode(organizationUnit.getMunicipalIstatCode());
when(registryProxyConnector.getUoById(any())).thenReturn(organizationUnit);
when(registryProxyConnector.getExtById(any())).thenReturn(proxyTaxonomy);
when(kafkaTemplate.send(any(ProducerRecord.class)))
.thenReturn(mockFuture);

doAnswer(invocationOnMock -> {
ListenableFutureCallback callback = invocationOnMock.getArgument(0);
callback.onSuccess(mockSendResult);
return null;
}).when(mockFuture).addCallback(any(ListenableFutureCallback.class));

//when
Executable executable = () -> service.sendInstitutionNotification(notification, acknowledgment);
//then
assertDoesNotThrow(executable);
ArgumentCaptor<ProducerRecord<String, String>> producerRecordArgumentCaptor = ArgumentCaptor.forClass(ProducerRecord.class);
verify(kafkaTemplate, times(1)).send(producerRecordArgumentCaptor.capture());
verify(acknowledgment, times(1)).acknowledge();
verify(registryProxyConnector, times(1)).getUoById(notification.getInstitution().getSubUnitCode());
verify(registryProxyConnector, times(1)).getExtById(organizationUnit.getMunicipalIstatCode());
verifyNoMoreInteractions(registryProxyConnector);
NotificationToSend captured = mapper.readValue(producerRecordArgumentCaptor.getValue().value(), NotificationToSend.class);
checkNotNullFields(captured, "user");
checkNotNullFields(captured.getInstitution(), "rootParent");
assertEquals("setTaxCodeInvoicing", captured.getInstitution().getTaxCode());

}

@Test
void sendInstitutionNotificationUo() throws JsonProcessingException {
//given
Expand Down Expand Up @@ -248,6 +201,7 @@ void sendInstitutionNotificationUo() throws JsonProcessingException {
NotificationToSend captured = mapper.readValue(producerRecordArgumentCaptor.getValue().value(), NotificationToSend.class);
checkNotNullFields(captured, "user");
checkNotNullFields(captured.getInstitution());
assertEquals("setTaxCodeInvoicing", captured.getInstitution().getTaxCode());
}

@Test
Expand Down

0 comments on commit 62100c7

Please sign in to comment.