-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
31,201 additions
and
0 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
75 changes: 75 additions & 0 deletions
75
fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/service/JobService.java
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.test.service; | ||
|
||
import static org.awaitility.Awaitility.await; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.BooleanUtils; | ||
import org.apache.fineract.client.models.ExecuteJobRequest; | ||
import org.apache.fineract.client.models.GetJobsResponse; | ||
import org.apache.fineract.client.services.SchedulerJobApi; | ||
import org.apache.fineract.test.data.job.Job; | ||
import org.apache.fineract.test.data.job.JobResolver; | ||
import org.apache.fineract.test.helper.ErrorHelper; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import retrofit2.Response; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class JobService { | ||
|
||
@Autowired | ||
private SchedulerJobApi schedulerJobApi; | ||
|
||
private final JobResolver jobResolver; | ||
|
||
public void execute(Job job) { | ||
try { | ||
Long jobId = jobResolver.resolve(job); | ||
Response<Void> response = schedulerJobApi.executeJob(jobId, "executeJob", new ExecuteJobRequest()).execute(); | ||
ErrorHelper.checkSuccessfulApiCall(response); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Exception while executing job %s".formatted(job.getName()), e); | ||
} | ||
} | ||
|
||
public void executeAndWait(Job job) { | ||
execute(job); | ||
waitUntilJobIsFinished(job); | ||
} | ||
|
||
private void waitUntilJobIsFinished(Job job) { | ||
String jobName = job.getName(); | ||
await().atMost(Duration.ofMinutes(2)).alias("%s didn't finish on time".formatted(jobName)).pollInterval(Duration.ofSeconds(10)) | ||
.until(() -> { | ||
log.info("Waiting for job {} to finish", jobName); | ||
Long jobId = jobResolver.resolve(job); | ||
Response<GetJobsResponse> getJobsResponse = schedulerJobApi.retrieveOne5(jobId).execute(); | ||
ErrorHelper.checkSuccessfulApiCall(getJobsResponse); | ||
Boolean currentlyRunning = getJobsResponse.body().getCurrentlyRunning(); | ||
return BooleanUtils.isFalse(currentlyRunning); | ||
}); | ||
} | ||
} |
771 changes: 771 additions & 0 deletions
771
...va/org/apache/fineract/test/stepdef/assetexternalization/AssetExternalizationStepDef.java
Large diffs are not rendered by default.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
...tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BusinessDateStepDef.java
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.test.stepdef.common; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import java.io.IOException; | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import org.apache.fineract.client.models.BusinessDateResponse; | ||
import org.apache.fineract.client.services.BusinessDateManagementApi; | ||
import org.apache.fineract.test.helper.BusinessDateHelper; | ||
import org.apache.fineract.test.helper.ErrorHelper; | ||
import org.apache.fineract.test.stepdef.AbstractStepDef; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import retrofit2.Response; | ||
|
||
public class BusinessDateStepDef extends AbstractStepDef { | ||
|
||
@Autowired | ||
private BusinessDateHelper businessDateHelper; | ||
|
||
@Autowired | ||
private BusinessDateManagementApi businessDateManagementApi; | ||
|
||
@When("Admin sets the business date to {string}") | ||
public void setBusinessDate(String businessDate) throws IOException { | ||
businessDateHelper.setBusinessDate(businessDate); | ||
} | ||
|
||
@When("Admin sets the business date to the actual date") | ||
public void setBusinessDateToday() throws IOException { | ||
businessDateHelper.setBusinessDateToday(); | ||
} | ||
|
||
@Then("Admin checks that the business date is correctly set to {string}") | ||
public void checkBusinessDate(String businessDate) throws IOException { | ||
Response<BusinessDateResponse> businessDateResponse = businessDateManagementApi.getBusinessDate(BusinessDateHelper.BUSINESS_DATE) | ||
.execute(); | ||
ErrorHelper.checkSuccessfulApiCall(businessDateResponse); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMMM yyyy"); | ||
LocalDate localDate = LocalDate.parse(businessDate, formatter); | ||
|
||
assertThat(businessDateResponse.body().getDate()).isEqualTo(localDate); | ||
} | ||
} |
152 changes: 152 additions & 0 deletions
152
...tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BusinessStepStepDef.java
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.test.stepdef.common; | ||
|
||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.fineract.client.models.BusinessStep; | ||
import org.apache.fineract.client.models.UpdateBusinessStepConfigRequest; | ||
import org.apache.fineract.client.services.BusinessStepConfigurationApi; | ||
import org.apache.fineract.test.helper.ErrorHelper; | ||
import org.apache.fineract.test.stepdef.AbstractStepDef; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import retrofit2.Response; | ||
|
||
public class BusinessStepStepDef extends AbstractStepDef { | ||
|
||
private static final String WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS = "LOAN_CLOSE_OF_BUSINESS"; | ||
private static final String BUSINESS_STEP_NAME_APPLY_CHARGE_TO_OVERDUE_LOANS = "APPLY_CHARGE_TO_OVERDUE_LOANS"; | ||
private static final String BUSINESS_STEP_NAME_LOAN_DELINQUENCY_CLASSIFICATION = "LOAN_DELINQUENCY_CLASSIFICATION"; | ||
private static final String BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_DUE = "CHECK_LOAN_REPAYMENT_DUE"; | ||
private static final String BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_OVERDUE = "CHECK_LOAN_REPAYMENT_OVERDUE"; | ||
private static final String BUSINESS_STEP_NAME_UPDATE_LOAN_ARREARS_AGING = "UPDATE_LOAN_ARREARS_AGING"; | ||
private static final String BUSINESS_STEP_NAME_ADD_PERIODIC_ACCRUAL_ENTRIES = "ADD_PERIODIC_ACCRUAL_ENTRIES"; | ||
private static final String BUSINESS_STEP_NAME_EXTERNAL_ASSET_OWNER_TRANSFER = "EXTERNAL_ASSET_OWNER_TRANSFER"; | ||
private static final String BUSINESS_STEP_NAME_CHECK_DUE_INSTALLMENTS = "CHECK_DUE_INSTALLMENTS"; | ||
|
||
@Autowired | ||
private BusinessStepConfigurationApi businessStepConfigurationApi; | ||
|
||
@Given("Admin puts EXTERNAL_ASSET_OWNER_TRANSFER job into LOAN_CLOSE_OF_BUSINESS workflow") | ||
public void putExternalAssetOwnerTransferJobInCOB() throws IOException { | ||
BusinessStep applyChargeToOverdueLoans = new BusinessStep().stepName(BUSINESS_STEP_NAME_APPLY_CHARGE_TO_OVERDUE_LOANS).order(1L); | ||
BusinessStep loanDelinquencyClassification = new BusinessStep().stepName(BUSINESS_STEP_NAME_LOAN_DELINQUENCY_CLASSIFICATION) | ||
.order(2L); | ||
BusinessStep checkLoanRepaymentDue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_DUE).order(3L); | ||
BusinessStep checkLoanRepaymentOverdue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_OVERDUE).order(4L); | ||
BusinessStep updateLoanArrearsAging = new BusinessStep().stepName(BUSINESS_STEP_NAME_UPDATE_LOAN_ARREARS_AGING).order(5L); | ||
BusinessStep addPeriodicAccrualEntries = new BusinessStep().stepName(BUSINESS_STEP_NAME_ADD_PERIODIC_ACCRUAL_ENTRIES).order(6L); | ||
BusinessStep externalAssetOwnerTransfer = new BusinessStep().stepName(BUSINESS_STEP_NAME_EXTERNAL_ASSET_OWNER_TRANSFER).order(7L); | ||
|
||
List<BusinessStep> businessSteps = new ArrayList<>(); | ||
businessSteps.add(applyChargeToOverdueLoans); | ||
businessSteps.add(loanDelinquencyClassification); | ||
businessSteps.add(checkLoanRepaymentDue); | ||
businessSteps.add(checkLoanRepaymentOverdue); | ||
businessSteps.add(updateLoanArrearsAging); | ||
businessSteps.add(addPeriodicAccrualEntries); | ||
businessSteps.add(externalAssetOwnerTransfer); | ||
|
||
UpdateBusinessStepConfigRequest request = new UpdateBusinessStepConfigRequest().businessSteps(businessSteps); | ||
|
||
Response<Void> response = businessStepConfigurationApi.updateJobBusinessStepConfig(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS, request) | ||
.execute(); | ||
ErrorHelper.checkSuccessfulApiCall(response); | ||
} | ||
|
||
@Then("Admin removes EXTERNAL_ASSET_OWNER_TRANSFER job from LOAN_CLOSE_OF_BUSINESS workflow") | ||
public void removeExternalAssetOwnerTransferJobInCOB() throws IOException { | ||
BusinessStep applyChargeToOverdueLoans = new BusinessStep().stepName(BUSINESS_STEP_NAME_APPLY_CHARGE_TO_OVERDUE_LOANS).order(1L); | ||
BusinessStep loanDelinquencyClassification = new BusinessStep().stepName(BUSINESS_STEP_NAME_LOAN_DELINQUENCY_CLASSIFICATION) | ||
.order(2L); | ||
BusinessStep checkLoanRepaymentDue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_DUE).order(3L); | ||
BusinessStep checkLoanRepaymentOverdue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_OVERDUE).order(4L); | ||
BusinessStep updateLoanArrearsAging = new BusinessStep().stepName(BUSINESS_STEP_NAME_UPDATE_LOAN_ARREARS_AGING).order(5L); | ||
BusinessStep addPeriodicAccrualEntries = new BusinessStep().stepName(BUSINESS_STEP_NAME_ADD_PERIODIC_ACCRUAL_ENTRIES).order(6L); | ||
|
||
List<BusinessStep> businessSteps = new ArrayList<>(); | ||
businessSteps.add(applyChargeToOverdueLoans); | ||
businessSteps.add(loanDelinquencyClassification); | ||
businessSteps.add(checkLoanRepaymentDue); | ||
businessSteps.add(checkLoanRepaymentOverdue); | ||
businessSteps.add(updateLoanArrearsAging); | ||
businessSteps.add(addPeriodicAccrualEntries); | ||
|
||
UpdateBusinessStepConfigRequest request = new UpdateBusinessStepConfigRequest().businessSteps(businessSteps); | ||
|
||
Response<Void> response = businessStepConfigurationApi.updateJobBusinessStepConfig(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS, request) | ||
.execute(); | ||
ErrorHelper.checkSuccessfulApiCall(response); | ||
} | ||
|
||
@Given("Admin puts CHECK_DUE_INSTALLMENTS job into LOAN_CLOSE_OF_BUSINESS workflow") | ||
public void putCheckDueInstallmentsJobInCOB() throws IOException { | ||
BusinessStep applyChargeToOverdueLoans = new BusinessStep().stepName(BUSINESS_STEP_NAME_APPLY_CHARGE_TO_OVERDUE_LOANS).order(1L); | ||
BusinessStep loanDelinquencyClassification = new BusinessStep().stepName(BUSINESS_STEP_NAME_LOAN_DELINQUENCY_CLASSIFICATION) | ||
.order(2L); | ||
BusinessStep checkLoanRepaymentDue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_DUE).order(3L); | ||
BusinessStep checkLoanRepaymentOverdue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_OVERDUE).order(4L); | ||
BusinessStep updateLoanArrearsAging = new BusinessStep().stepName(BUSINESS_STEP_NAME_UPDATE_LOAN_ARREARS_AGING).order(5L); | ||
BusinessStep addPeriodicAccrualEntries = new BusinessStep().stepName(BUSINESS_STEP_NAME_ADD_PERIODIC_ACCRUAL_ENTRIES).order(6L); | ||
BusinessStep checkDueInstallments = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_DUE_INSTALLMENTS).order(7L); | ||
|
||
List<BusinessStep> businessSteps = new ArrayList<>(); | ||
businessSteps.add(applyChargeToOverdueLoans); | ||
businessSteps.add(loanDelinquencyClassification); | ||
businessSteps.add(checkLoanRepaymentDue); | ||
businessSteps.add(checkLoanRepaymentOverdue); | ||
businessSteps.add(updateLoanArrearsAging); | ||
businessSteps.add(addPeriodicAccrualEntries); | ||
businessSteps.add(checkDueInstallments); | ||
|
||
UpdateBusinessStepConfigRequest request = new UpdateBusinessStepConfigRequest().businessSteps(businessSteps); | ||
|
||
Response<Void> response = businessStepConfigurationApi.updateJobBusinessStepConfig(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS, request) | ||
.execute(); | ||
ErrorHelper.checkSuccessfulApiCall(response); | ||
} | ||
|
||
@Then("Admin removes CHECK_DUE_INSTALLMENTS job from LOAN_CLOSE_OF_BUSINESS workflow") | ||
public void removeCheckDueInstallmentsJobInCOB() throws IOException { | ||
BusinessStep applyChargeToOverdueLoans = new BusinessStep().stepName(BUSINESS_STEP_NAME_APPLY_CHARGE_TO_OVERDUE_LOANS).order(1L); | ||
BusinessStep loanDelinquencyClassification = new BusinessStep().stepName(BUSINESS_STEP_NAME_LOAN_DELINQUENCY_CLASSIFICATION) | ||
.order(2L); | ||
BusinessStep checkLoanRepaymentDue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_DUE).order(3L); | ||
BusinessStep checkLoanRepaymentOverdue = new BusinessStep().stepName(BUSINESS_STEP_NAME_CHECK_LOAN_REPAYMENT_OVERDUE).order(4L); | ||
BusinessStep updateLoanArrearsAging = new BusinessStep().stepName(BUSINESS_STEP_NAME_UPDATE_LOAN_ARREARS_AGING).order(5L); | ||
BusinessStep addPeriodicAccrualEntries = new BusinessStep().stepName(BUSINESS_STEP_NAME_ADD_PERIODIC_ACCRUAL_ENTRIES).order(6L); | ||
|
||
List<BusinessStep> businessSteps = new ArrayList<>(); | ||
businessSteps.add(applyChargeToOverdueLoans); | ||
businessSteps.add(loanDelinquencyClassification); | ||
businessSteps.add(checkLoanRepaymentDue); | ||
businessSteps.add(checkLoanRepaymentOverdue); | ||
businessSteps.add(updateLoanArrearsAging); | ||
businessSteps.add(addPeriodicAccrualEntries); | ||
|
||
UpdateBusinessStepConfigRequest request = new UpdateBusinessStepConfigRequest().businessSteps(businessSteps); | ||
|
||
Response<Void> response = businessStepConfigurationApi.updateJobBusinessStepConfig(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS, request) | ||
.execute(); | ||
ErrorHelper.checkSuccessfulApiCall(response); | ||
} | ||
} |
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
Oops, something went wrong.