Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
[SELC - 5131] fix: fixed filters in verify onboarding (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
gianmarcoplutino authored Jun 20, 2024
1 parent 427834d commit 61de5da
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,10 @@ public Boolean existsOnboardingByFilters(VerifyOnboardingFilters filters) {
.isIfNotNull(InstitutionEntity.Fields.taxCode.name(), filters.getTaxCode())
.isIfNotNull(InstitutionEntity.Fields.origin.name(), filters.getOrigin())
.isIfNotNull(InstitutionEntity.Fields.originId.name(), filters.getOriginId())
.isIfNotNull(InstitutionEntity.Fields.subunitCode.name(), filters.getSubunitCode())
.build();

criteriaInstitution.and(InstitutionEntity.Fields.subunitCode.name()).is(filters.getSubunitCode());

Criteria criteriaOnboarding = Criteria.where(Onboarding.Fields.status.name()).in(filters.getValidRelationshipStates())
.and(Onboarding.Fields.productId.name()).is(filters.getProductId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,36 @@ void shouldReturnTrueWhenOnboardingExistsByFilters() {
assertTrue(exists);
}

@Test
@DisplayName("Should return true when onboarding exists by filters when subunitCode is null")
void shouldReturnTrueWhenOnboardingExistsByFiltersAndSubunitCodeIsNull() {
// Given
VerifyOnboardingFilters filters = new VerifyOnboardingFilters("productId", "externalId", "taxCode", "origin", "originId", null);
filters.setValidRelationshipStates(List.of(RelationshipState.ACTIVE));
when(institutionRepository.exists(any(Query.class), any())).thenReturn(true);

// When
Boolean exists = institutionConnectorImpl.existsOnboardingByFilters(filters);

// Then
assertTrue(exists);
}

@Test
@DisplayName("Should return false when onboarding exists by filters when subunitCode is null")
void shouldReturnFalseWhenOnboardingExistsByFiltersAndSubunitCodeIsNull() {
// Given
VerifyOnboardingFilters filters = new VerifyOnboardingFilters("productId", "externalId", "taxCode", "origin", "originId", null);
filters.setValidRelationshipStates(List.of(RelationshipState.ACTIVE));
when(institutionRepository.exists(any(Query.class), any())).thenReturn(false);

// When
Boolean exists = institutionConnectorImpl.existsOnboardingByFilters(filters);

// Then
assertFalse(exists);
}

@Test
@DisplayName("Should return false when onboarding does not exist by filters")
void shouldReturnFalseWhenOnboardingDoesNotExistByFilters() {
Expand Down

0 comments on commit 61de5da

Please sign in to comment.