generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added junit test for controller and service
- Loading branch information
1 parent
95c2b26
commit 8addb66
Showing
2 changed files
with
203 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ | |
import it.pagopa.selfcare.onboarding.entity.Billing; | ||
import it.pagopa.selfcare.onboarding.entity.CheckManagerResponse; | ||
import it.pagopa.selfcare.onboarding.entity.Onboarding; | ||
import it.pagopa.selfcare.onboarding.entity.OnboardingAggregationImportRequest; | ||
import it.pagopa.selfcare.onboarding.exception.InvalidRequestException; | ||
import it.pagopa.selfcare.onboarding.model.OnboardingGetFilters; | ||
import it.pagopa.selfcare.onboarding.model.RecipientCodeStatus; | ||
|
@@ -1244,4 +1245,65 @@ void updateRecipientCodeByOnboardingIdTest() { | |
assertEquals(captor.getValue().getBilling().getRecipientCode(), fakeRecipientCode); | ||
} | ||
|
||
@Test | ||
@TestSecurity(user = "userJwt") | ||
void onboardingAggregationImportTest_KO() { | ||
// given | ||
OnboardingAggregationImportRequest onboardingImport = new OnboardingAggregationImportRequest(); | ||
|
||
//when | ||
given() | ||
.when() | ||
.body(onboardingImport) | ||
.contentType(ContentType.JSON) | ||
.post("/aggregation/import") | ||
.then() | ||
.statusCode(400); | ||
} | ||
|
||
@Test | ||
@TestSecurity(user = "userJwt") | ||
void onboardingAggregationImportTest_OK() { | ||
// given | ||
OnboardingAggregationImportRequest onboardingImport = dummyOnboardingAggregationImportRequest(); | ||
|
||
Mockito.when(onboardingService.onboardingAggregationImport(any(), any(), any(), any())) | ||
.thenReturn(Uni.createFrom().item(new OnboardingResponse())); | ||
|
||
// when | ||
given() | ||
.when() | ||
.body(onboardingImport) | ||
.contentType(ContentType.JSON) | ||
.post("/aggregation/import") | ||
.then() | ||
.statusCode(200); | ||
|
||
// then | ||
Mockito.verify(onboardingService, times(1)) | ||
.onboardingAggregationImport(any(), any(), any(), any()); | ||
} | ||
|
||
private OnboardingAggregationImportRequest dummyOnboardingAggregationImportRequest() { | ||
OnboardingAggregationImportRequest onboardingRequest = new OnboardingAggregationImportRequest(); | ||
onboardingRequest.setBilling(new BillingRequest()); | ||
InstitutionPspRequest institutionRequest = new InstitutionPspRequest(); | ||
institutionRequest.setInstitutionType(InstitutionType.PSP); | ||
institutionRequest.setDigitalAddress("[email protected]"); | ||
PaymentServiceProviderRequest pspData = new PaymentServiceProviderRequest(); | ||
pspData.setAbiCode("abiCode"); | ||
pspData.setProviderNames(List.of("test")); | ||
institutionRequest.setPaymentServiceProvider(new PaymentServiceProviderRequest()); | ||
onboardingRequest.setInstitution(institutionRequest); | ||
onboardingRequest.setProductId("prod-io"); | ||
OnboardingImportContract importContract = new OnboardingImportContract(); | ||
importContract.setFilePath("/test/path"); | ||
String str = "2025-01-15 11:30"; | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
LocalDateTime dateTime = LocalDateTime.parse(str, formatter); | ||
importContract.setCreatedAt(dateTime); | ||
onboardingRequest.setOnboardingImportContract(new OnboardingImportContract()); | ||
return onboardingRequest; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters