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

Commit

Permalink
[SELC-5170] : PR: Added junit test
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenbegiqi committed Jul 5, 2024
1 parent 7ce6e90 commit d8ad140
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
import org.springframework.test.context.ContextConfiguration;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;

import static it.pagopa.selfcare.commons.utils.TestUtils.mockInstance;
import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -714,4 +712,28 @@ void shouldReturnFalseWhenOnboardingDoesNotExistByFilters() {
// Then
assertFalse(exists);
}
@Test
public void testFindAndDeleteOnboarding() {

String institutionId = UUID.randomUUID().toString();
String productId = "prod-io";

OnboardingEntity mockOnboarding = new OnboardingEntity();
mockOnboarding.setProductId(productId);
mockOnboarding.setUpdatedAt(OffsetDateTime.now());
mockOnboarding.setStatus(RelationshipState.ACTIVE);

InstitutionEntity mockEntity = new InstitutionEntity();
mockEntity.setId(institutionId);
mockEntity.setOnboarding(Collections.singletonList(mockOnboarding));

when(institutionRepository.findAndModify(any(Query.class), any(Update.class),
any(FindAndModifyOptions.class), eq(InstitutionEntity.class)))
.thenReturn(mockEntity);

institutionConnectorImpl.findAndDeleteOnboarding(institutionId, productId);

verify(institutionRepository, times(1)).findAndModify(any(Query.class), any(Update.class), any(FindAndModifyOptions.class), eq(InstitutionEntity.class));
assertNotNull(mockEntity);
}
}

0 comments on commit d8ad140

Please sign in to comment.