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

Commit

Permalink
[SELC - 5131] cherry-pick of release 1.1.5 (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
gianmarcoplutino authored Jun 20, 2024
1 parent 49e3293 commit e3c24ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion connector-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-product</artifactId>
<version>0.1.8</version>
<version>0.1.14</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,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 @@ -669,6 +669,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 e3c24ca

Please sign in to comment.