### Question:
IdentityProviderConfigOnboardingTransactionValidator { public void validate(IdentityProviderConfig identityProviderConfig) { for (String onboardingTransactionEntityId : identityProviderConfig.getOnboardingTransactionEntityIds()) { transactionConfigRepository.getData(onboardingTransactionEntityId) .orElseThrow(() -> createAbsentOnboardingTransactionConfigException( onboardingTransactionEntityId, identityProviderConfig.getEntityId())); } } IdentityProviderConfigOnboardingTransactionValidator(
            final LocalConfigRepository<TransactionConfig> transactionConfigRepository); void validate(IdentityProviderConfig identityProviderConfig);  }### Answer:
@Test public void validate_shouldNotThrowExceptionWhenOnboardingTransactionEntityIdExists() { String transactionEntityID = "transactionEntityID"; IdentityProviderConfig identityProviderConfig = anIdentityProviderConfigData().withOnboarding(List.of(transactionEntityID)).build(); TransactionConfig transactionConfigEntity = aTransactionConfigData().build(); when(transactionConfigRepository.getData(transactionEntityID)).thenReturn(Optional.ofNullable(transactionConfigEntity)); identityProviderConfigOnboardingTransactionValidator.validate(identityProviderConfig); }
@Test public void validate_shouldNotThrowExceptionWhenOnboardingTransactionEntityIsNotSpecified() { IdentityProviderConfig identityProviderConfig = anIdentityProviderConfigData().withoutOnboarding().build(); identityProviderConfigOnboardingTransactionValidator.validate(identityProviderConfig); }
@Test public void validate_shouldThrowExceptionWhenOnboardingTransactionDoesNotExist() { String transactionEntityID = "transactionEntityID"; String idpEntityId = "idpEntityId"; IdentityProviderConfig identityProviderConfig = anIdentityProviderConfigData() .withEntityId(idpEntityId) .withOnboarding(List.of(transactionEntityID)) .build(); when(transactionConfigRepository.getData(transactionEntityID)) .thenReturn(Optional.empty()); try { identityProviderConfigOnboardingTransactionValidator.validate(identityProviderConfig); fail("fail"); } catch (ConfigValidationException e) { final ConfigValidationException expectedException = createAbsentOnboardingTransactionConfigException(transactionEntityID, idpEntityId); assertThat(expectedException.getMessage()).isEqualTo(e.getMessage()); } }