Skip to content

Commit

Permalink
feat: added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
gianmarcoplutino committed Apr 18, 2024
1 parent d871874 commit 7beb92f
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,49 @@ void verifyOnboarding_allowed() {
verifyNoInteractions(productsConnectorMock, userConnectorMock);
}

@Test
void verifyOnboardingInfo_notAllowed() {
// given
final String taxCode = "taxCode";
final String subunitCode = "subunitCode";
final String productId = "productId";
final String externalId = "externalId";
final String origin = "origin";
final String originId = "originId";
// when
final Executable executable = () -> institutionService.verifyOnboarding(productId, externalId, taxCode, origin, originId, subunitCode);
// then
final Exception e = assertThrows(OnboardingNotAllowedException.class, executable);
assertEquals("Institution with external id '" + taxCode + "' is not allowed to onboard '" + productId + "' product", e.getMessage());
verify(onboardingValidationStrategyMock, times(1))
.validate(productId, taxCode);
verifyNoMoreInteractions(onboardingValidationStrategyMock);
verifyNoInteractions(productsConnectorMock, userConnectorMock, partyConnectorMock);
}

@Test
void verifyOnboardingInfo_allowed() {
// given
final String taxCode = "taxCode";
final String subunitCode = "subunitCode";
final String productId = "productId";
final String externalId = "externalId";
final String origin = "origin";
final String originId = "originId";
when(onboardingValidationStrategyMock.validate(productId, taxCode))
.thenReturn(true);
// when
final Executable executable = () -> institutionService.verifyOnboarding(productId, externalId, taxCode, origin, originId, subunitCode);
// then
assertDoesNotThrow(executable);
verify(onboardingValidationStrategyMock, times(1))
.validate(productId, taxCode);
verify(partyConnectorMock, times(1))
.verifyOnboarding(productId, externalId, taxCode, origin, originId, subunitCode);
verifyNoMoreInteractions(onboardingValidationStrategyMock, partyConnectorMock);
verifyNoInteractions(productsConnectorMock, userConnectorMock);
}

@Test
void getInstitutionsByUser_default() {
//given
Expand Down

0 comments on commit 7beb92f

Please sign in to comment.