FINERACT-2181: Using JUnit 5 for E2E

This commit is contained in:
Adam Saghy
2025-06-11 20:44:21 +02:00
parent c37e2daa86
commit 7c656ecae8
35 changed files with 199 additions and 226 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ jobs:
run: |
./gradlew --no-daemon --console=plain build -x cucumber -x test -x doc
./gradlew --no-daemon --console=plain cucumber -x :fineract-e2e-tests-runner:cucumber
./gradlew --no-daemon --console=plain test -x :twofactor-tests:test -x :oauth2-test:test :fineract-e2e-tests-runner:test -PdbType=mysql
./gradlew --no-daemon --console=plain test -x :twofactor-tests:test -x :oauth2-test:test -x :fineract-e2e-tests-runner:test -PdbType=mysql
./gradlew --no-daemon --console=plain :twofactor-tests:test -PdbType=mysql
./gradlew --no-daemon --console=plain :oauth2-tests:test -PdbType=mysql
- name: Archive test results
+1 -1
View File
@@ -69,7 +69,7 @@ jobs:
run: |
./gradlew --no-daemon --console=plain build -x cucumber -x test -x doc
./gradlew --no-daemon --console=plain cucumber -x :fineract-e2e-tests-runner:cucumber
./gradlew --no-daemon --console=plain test -x :twofactor-tests:test -x :oauth2-test:test :fineract-e2e-tests-runner:test -PdbType=postgresql
./gradlew --no-daemon --console=plain test -x :twofactor-tests:test -x :oauth2-test:test -x :fineract-e2e-tests-runner:test -PdbType=postgresql
./gradlew --no-daemon --console=plain :twofactor-tests:test -PdbType=postgresql
./gradlew --no-daemon --console=plain :oauth2-tests:test -PdbType=postgresql
- name: Archive test results
+3 -3
View File
@@ -376,7 +376,7 @@ configure(project.fineractJavaProjects) {
cacheDynamicVersionsFor 0, 'seconds'
}
}
tasks.withType(JavaCompile).configureEach {
options.incremental = true
options.fork = true
@@ -672,7 +672,7 @@ configure(project.fineractJavaProjects) {
'org.junit.jupiter:junit-jupiter-api',
'org.junit.jupiter:junit-jupiter-engine',
'org.junit.jupiter:junit-jupiter-params',
'org.junit.platform:junit-platform-runner', // required to be able to run tests directly under Eclipse, see FINERACT-943 & FINERACT-1021
'org.junit.platform:junit-platform-suite', // required to be able to run tests directly under Eclipse, see FINERACT-943 & FINERACT-1021
'org.bouncycastle:bcpkix-jdk18on',
'org.bouncycastle:bcprov-jdk18on',
'org.bouncycastle:bcutil-jdk18on',
@@ -783,7 +783,7 @@ configure(project.fineractCustomProjects) {
'org.mockito:mockito-junit-jupiter',
'org.junit.jupiter:junit-jupiter-api',
'org.junit.jupiter:junit-jupiter-engine',
'org.junit.platform:junit-platform-runner', // required to be able to run tests directly under Eclipse, see FINERACT-943 & FINERACT-1021
'org.junit.platform:junit-platform-suite', // required to be able to run tests directly under Eclipse, see FINERACT-943 & FINERACT-1021
'org.bouncycastle:bcpkix-jdk18on',
'org.bouncycastle:bcprov-jdk18on',
'org.bouncycastle:bcutil-jdk18on',
+8 -5
View File
@@ -40,17 +40,17 @@ repositories {
// Configure test compilation
tasks.named('compileTestJava') {
description = 'Compiles test Java source files'
// Enable caching
outputs.cacheIf { true }
// Configure compiler options
options.compilerArgs.add("-parameters")
// Ensure proper output tracking
outputs.dir(sourceSets.test.java.destinationDirectory)
.withPropertyName("testClassesDir")
// Track annotation processor outputs
options.annotationProcessorGeneratedSourcesDirectory =
layout.buildDirectory.dir('generated/sources/annotationProcessor/java/test').get().asFile
@@ -69,12 +69,15 @@ dependencies {
testImplementation 'com.squareup.retrofit2:retrofit:2.11.0'
testImplementation 'org.apache.httpcomponents:httpclient:4.5.14'
testImplementation 'org.apache.commons:commons-lang3:3.17.0'
testImplementation 'com.googlecode.json-simple:json-simple:1.1.1'
testImplementation ('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}
testImplementation 'com.google.code.gson:gson:2.11.0'
testImplementation 'io.cucumber:cucumber-java:7.20.1'
testImplementation 'io.cucumber:cucumber-junit:7.20.1'
testImplementation 'io.cucumber:cucumber-spring:7.20.1'
testImplementation 'io.cucumber:cucumber-junit-platform-engine:7.20.1'
testImplementation 'io.qameta.allure:allure-cucumber7-jvm:2.29.1'
@@ -61,7 +61,7 @@ public class EventAssertion {
}
T event = eventFactory.create(eventClazz);
try {
await().atMost(Duration.ofSeconds(eventProperties.getEventWaitTimeoutInSec())).until(() -> {
await().atMost(Duration.ofMillis(eventProperties.getWaitTimeoutInMillis())).until(() -> {
if (removeEventIfFound) {
return eventStore.removeEventById(event, id).isPresent();
} else {
@@ -69,8 +69,8 @@ public class EventAssertion {
}
});
} catch (ConditionTimeoutException e) {
Assertions
.fail(event.getEventName() + " hasn't been received within " + eventProperties.getEventWaitTimeoutInSec() + " seconds");
Assertions.fail(
event.getEventName() + " hasn't been received within " + eventProperties.getWaitTimeoutInMillis() / 1000 + " seconds");
}
}
@@ -80,7 +80,7 @@ public class EventAssertion {
}
T event = eventFactory.create(eventClazz);
try {
await().atMost(Duration.ofSeconds(eventProperties.getEventWaitTimeoutInSec())).until(() -> {
await().atMost(Duration.ofMillis(eventProperties.getWaitTimeoutInMillis())).until(() -> {
if (id == null) {
return !eventStore.findByType(event).isEmpty();
}
@@ -115,7 +115,7 @@ public class EventAssertion {
}
T event = eventFactory.create(eventClazz);
try {
await().atMost(Duration.ofSeconds(eventProperties.getEventWaitTimeoutInSec()))
await().atMost(Duration.ofMillis(eventProperties.getWaitTimeoutInMillis()))
.until(() -> eventStore.findByType(event).stream().anyMatch(filter));
String receivedEventsLogParam = eventStore.getReceivedEvents().stream().map(LoggedEvent::new).map(LoggedEvent::toString)
@@ -26,8 +26,14 @@ import org.springframework.stereotype.Component;
@Getter
public class EventProperties {
@Value("${fineract-test.event.wait-timeout-in-sec}")
private int eventWaitTimeoutInSec;
@Value("${fineract-test.event.wait-timeout-in-ms}")
private long waitTimeoutInMillis;
@Value("${fineract-test.event.interval-in-ms}")
private long intervalInMillis;
@Value("${fineract-test.event.delay-in-ms}")
private long delayInMillis;
@Value("${fineract-test.event.verification-enabled}")
private boolean eventVerificationEnabled;
@@ -26,13 +26,13 @@ import org.springframework.stereotype.Component;
@Getter
public class JobPollingProperties {
@Value("${fineract-test.job.interval-in-sec}")
private long pollingIntervalInSec;
@Value("${fineract-test.job.interval-in-ms}")
private long intervalInMillis;
@Value("${fineract-test.job.delay-in-sec}")
private long pollingDelayInSec;
@Value("${fineract-test.job.delay-in-ms}")
private long delayInMillis;
@Value("${fineract-test.job.at-most-in-sec}")
private long pollingAtMostInSec;
@Value("${fineract-test.job.wait-timeout-in-ms}")
private long timeoutInMillis;
}
@@ -66,10 +66,10 @@ public class JobService {
private void waitUntilJobIsFinished(Job job) {
String jobName = job.getName();
await().atMost(Duration.ofSeconds(jobPollingProperties.getPollingAtMostInSec())) //
await().atMost(Duration.ofMillis(jobPollingProperties.getTimeoutInMillis())) //
.alias("%s didn't finish on time".formatted(jobName)) //
.pollInterval(Duration.ofSeconds(jobPollingProperties.getPollingIntervalInSec())) //
.pollDelay(Duration.ofSeconds(jobPollingProperties.getPollingDelayInSec())) //
.pollInterval(Duration.ofMillis(jobPollingProperties.getIntervalInMillis())) //
.pollDelay(Duration.ofMillis(jobPollingProperties.getDelayInMillis())) //
.until(() -> {
log.info("Waiting for job {} to finish", jobName);
Long jobId = jobResolver.resolve(job);
@@ -26,8 +26,8 @@ import static org.apache.fineract.test.data.loanproduct.DefaultLoanProduct.LP2_A
import static org.apache.fineract.test.factory.LoanProductsRequestFactory.CHARGE_OFF_REASONS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.gson.Gson;
@@ -2453,8 +2453,10 @@ public class LoanStepDef extends AbstractStepDef {
long loanId = loanResponse.body().getLoanId();
LoanStatusEnumDataV1 expectedStatus = getExpectedStatus(loanStatus);
await().pollDelay(Duration.ofSeconds(1L)).pollInterval(Duration.ofSeconds(1L))
.atMost(Duration.ofSeconds(eventProperties.getEventWaitTimeoutInSec())).untilAsserted(() -> {
await().atMost(Duration.ofMillis(eventProperties.getWaitTimeoutInMillis()))//
.pollDelay(Duration.ofMillis(eventProperties.getDelayInMillis())) //
.pollInterval(Duration.ofMillis(eventProperties.getIntervalInMillis()))//
.untilAsserted(() -> {
eventAssertion.assertEvent(LoanStatusChangedEvent.class, loanId).extractingData(LoanAccountDataV1::getStatus)
.isEqualTo(expectedStatus);
});
@@ -2479,7 +2481,7 @@ public class LoanStepDef extends AbstractStepDef {
public void getLoanLastCOBDate(String date) throws IOException {
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanResponse.body().getLoanId();
log.debug("Loan ID: {}", loanId);
Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "", "", "").execute();
ErrorHelper.checkSuccessfulApiCall(loanDetails);
if ("null".equals(date)) {
@@ -2497,9 +2499,16 @@ public class LoanStepDef extends AbstractStepDef {
@When("Admin checks that Loan COB is running until the current business date")
public void checkLoanCOBCatchUpRunningUntilCOBBusinessDate() {
await().atMost(Duration.ofSeconds(jobPollingProperties.getPollingAtMostInSec())) //
.pollInterval(Duration.ofSeconds(jobPollingProperties.getPollingIntervalInSec())) //
.pollDelay(Duration.ofSeconds(jobPollingProperties.getPollingDelayInSec())) //
await().atMost(Duration.ofMillis(jobPollingProperties.getTimeoutInMillis())) //
.pollInterval(Duration.ofMillis(jobPollingProperties.getIntervalInMillis())) //
.until(() -> {
Response<IsCatchUpRunningDTO> isCatchUpRunningResponse = loanCobCatchUpApi.isCatchUpRunning().execute();
ErrorHelper.checkSuccessfulApiCall(isCatchUpRunningResponse);
IsCatchUpRunningDTO isCatchUpRunning = isCatchUpRunningResponse.body();
return isCatchUpRunning.getCatchUpRunning();
});
await().atMost(Duration.ofMillis(jobPollingProperties.getTimeoutInMillis())) //
.pollInterval(Duration.ofMillis(jobPollingProperties.getIntervalInMillis())) //
.until(() -> {
Response<IsCatchUpRunningDTO> isCatchUpRunningResponse = loanCobCatchUpApi.isCatchUpRunning().execute();
ErrorHelper.checkSuccessfulApiCall(isCatchUpRunningResponse);
@@ -2676,8 +2685,8 @@ public class LoanStepDef extends AbstractStepDef {
Response<GetLoansLoanIdTransactionsTransactionIdResponse> originalTransaction = loanTransactionsApi
.retrieveTransaction(loanId, originalTransactionId, "").execute();
assertNull(String.format("Original transaction external id is not null %n%s", originalTransaction.body()),
originalTransaction.body().getExternalId());
assertNull(originalTransaction.body().getExternalId(),
String.format("Original transaction external id is not null %n%s", originalTransaction.body()));
}
@Then("LoanTransactionAccrualActivityPostBusinessEvent is raised on {string}")
@@ -36,10 +36,13 @@ fineract-test.messaging.jms.broker-username=${ACTIVEMQ_BROKER_USERNAME:}
fineract-test.messaging.jms.broker-password=${ACTIVEMQ_BROKER_PASSWORD:}
fineract-test.messaging.jms.topic-name=${ACTIVEMQ_TOPIC_NAME:}
fineract-test.event.wait-timeout-in-sec=${EVENT_WAIT_TIMEOUT_IN_SEC:5}
fineract-test.event.verification-enabled=${EVENT_VERIFICATION_ENABLED:false}
fineract-test.event.wait-timeout-in-ms=${POLLING_EVENT_WAIT_TIMEOUT_IN_MS:5000}
fineract-test.event.delay-in-ms=${POLLING_EVENT_WAIT_TIMEOUT_IN_MS:100}
fineract-test.event.interval-in-ms=${POLLING_EVENT_WAIT_TIMEOUT_IN_MS:100}
fineract-test.job.interval-in-ms=${POLLING_JOB_INTERVAL_IN_MS:100}
fineract-test.job.delay-in-ms=${POLLING_JOB_DELAY_IN_MS:3000}
fineract-test.job.wait-timeout-in-ms=${POLLING_JOB_WAIT_TIMEOUT_IN_MS:120000}
fineract-test.client-read-timeout=${CLIENT_READ_TIMEOUT:60}
fineract-test.job.interval-in-sec=${POLLING_INTERVAL_IN_SEC:1}
fineract-test.job.delay-in-sec=${POLLING_DELAY_IN_SEC:3}
fineract-test.job.at-most-in-sec=${POLLING_AT_MOST_IN_SEC:120}
+11 -3
View File
@@ -41,18 +41,21 @@ dependencies {
testImplementation 'com.squareup.retrofit2:retrofit:2.11.0'
testImplementation 'org.apache.httpcomponents:httpclient:4.5.14'
testImplementation 'org.apache.commons:commons-lang3:3.17.0'
testImplementation 'com.googlecode.json-simple:json-simple:1.1.1'
testImplementation ('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}
testImplementation 'com.google.code.gson:gson:2.11.0'
testImplementation 'org.junit.platform:junit-platform-suite:1.11.4'
testImplementation 'org.junit.platform:junit-platform-console:1.11.4'
testImplementation 'io.cucumber:cucumber-java:7.20.1'
testImplementation 'io.cucumber:cucumber-junit:7.20.1'
testImplementation 'io.cucumber:cucumber-spring:7.20.1'
testImplementation 'io.cucumber:cucumber-junit-platform-engine:7.20.1'
testImplementation 'io.qameta.allure:allure-cucumber7-jvm:2.29.1'
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.3'
testCompileOnly 'org.projectlombok:lombok:1.18.36'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.36'
@@ -70,6 +73,7 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
systemProperty("cucumber.junit-platform.naming-strategy", "long")
}
tasks.named('cucumber').get().finalizedBy 'allureReport'
@@ -89,3 +93,7 @@ cucumber {
allure {
version = '2.17.3'
}
test {
useJUnitPlatform()
}
@@ -18,12 +18,21 @@
*/
package org.apache.fineract.test;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features", glue = { "org.apache.fineract.test.stepdef",
"org.apache.fineract.test.stepdef.common", "org.apache.fineract.test.stepdef.hook", "org.apache.fineract.test.stepdef.loan",
"org.apache.fineract.test.stepdef.saving", "org.apache.fineract.test.config" })
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.ExcludeTags;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectDirectories;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.Suite;
@Suite
@IncludeEngines("cucumber")
@SelectPackages("org.apache.fineract.test")
@SelectDirectories("src/test/resources/features")
@ExcludeTags("Skip")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "org.apache.fineract.test.stepdef, org.apache.fineract.test.stepdef.common, org.apache.fineract.test.stepdef.hook, org.apache.fineract.test.stepdef.loan, org.apache.fineract.test.stepdef.saving, org.apache.fineract.test.config")
public class TestRunner {}
@@ -1836,11 +1836,7 @@ Feature: Charge-off
| 02 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
And Admin does charge-off the loan on "03 June 2024"
When Admin sets the business date to "05 June 2024"
And Admin runs the Accrual Activity Posting job
And Admin runs the Add Accrual Transactions job
And Admin runs the Add Accrual Transactions For Loans With Income Posted As Transactions job
And Admin runs the Add Periodic Accrual Transactions job
And Admin runs the Recalculate Interest for Loans job
And Admin runs inline COB job for Loan
Then Loan Repayment schedule has 4 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 June 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
@@ -1915,13 +1911,9 @@ Feature: Charge-off
| 02 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Charge-off | 255.23 | 250.0 | 5.23 | 0.0 | 0.0 | 0.0 | false | false |
When Admin sets the business date to "06 June 2024"
When Admin sets the business date to "07 June 2024"
Then Admin does a charge-off undo the loan
And Admin runs the Accrual Activity Posting job
And Admin runs the Add Accrual Transactions job
And Admin runs the Add Accrual Transactions For Loans With Income Posted As Transactions job
And Admin runs the Add Periodic Accrual Transactions job
And Admin runs the Recalculate Interest for Loans job
And Admin runs inline COB job for Loan
Then Loan Repayment schedule has 4 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 June 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
@@ -1938,7 +1930,8 @@ Feature: Charge-off
| 02 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Charge-off | 255.23 | 250.0 | 5.23 | 0.0 | 0.0 | 0.0 | true | false |
| 06 June 2024 | Accrual | 0.21 | 0.0 | 0.21 | 0.0 | 0.0 | 0.0 | false | false |
| 05 June 2024 | Accrual | 0.14 | 0.0 | 0.14 | 0.0 | 0.0 | 0.0 | false | false |
| 06 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
@TestRailId:C3326 @AdvancedPaymentAllocation
Scenario: Verify the repayment schedule is updated before the Charge-off in case of interest recalculation = true
@@ -1976,68 +1969,6 @@ Feature: Charge-off
@TestRailId:C3337 @AdvancedPaymentAllocation
Scenario: Verify charged off loans to be excluded from scheduled jobs - no interest is added for charged-off loans with 0 interest
When Admin sets the business date to "01 June 2024"
When Admin creates a client with random data
When Admin creates a fully customized loan with the following data:
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LP2_ADV_CUSTOM_PAYMENT_ALLOC_INTEREST_RECALCULATION_DAILY_EMI_360_30_MULTIDISBURSE | 01 June 2024 | 1000 | 10 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 4 | MONTHS | 1 | MONTHS | 4 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
And Admin successfully approves the loan on "01 June 2024" with "1000" amount and expected disbursement date on "01 June 2024"
When Admin successfully disburse the loan on "01 June 2024" with "250" EUR transaction amount
Then Loan Repayment schedule has 4 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 June 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 30 | 01 July 2024 | | 188.27 | 61.73 | 2.08 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 2 | 31 | 01 August 2024 | | 126.03 | 62.24 | 1.57 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 3 | 31 | 01 September 2024 | | 63.27 | 62.76 | 1.05 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 4 | 30 | 01 October 2024 | | 0.0 | 63.27 | 0.53 | 0.0 | 0.0 | 63.8 | 0.0 | 0.0 | 0.0 | 63.8 |
Then Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 250.0 | 5.23 | 0.0 | 0.0 | 255.23 | 0.0 | 0.0 | 0.0 | 255.23 |
Then Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
| 01 June 2024 | Disbursement | 250.0 | 0.0 | 0.0 | 0.0 | 0.0 | 250.0 | false | false |
When Admin sets the business date to "03 June 2024"
And Admin runs inline COB job for Loan
Then Loan Repayment schedule has 4 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 June 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 30 | 01 July 2024 | | 188.27 | 61.73 | 2.08 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 2 | 31 | 01 August 2024 | | 126.03 | 62.24 | 1.57 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 3 | 31 | 01 September 2024 | | 63.27 | 62.76 | 1.05 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 4 | 30 | 01 October 2024 | | 0.0 | 63.27 | 0.53 | 0.0 | 0.0 | 63.8 | 0.0 | 0.0 | 0.0 | 63.8 |
Then Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 250.0 | 5.23 | 0.0 | 0.0 | 255.23 | 0.0 | 0.0 | 0.0 | 255.23 |
Then Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
| 01 June 2024 | Disbursement | 250.0 | 0.0 | 0.0 | 0.0 | 0.0 | 250.0 | false | false |
| 02 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
And Admin does charge-off the loan on "03 June 2024"
When Admin sets the business date to "05 June 2024"
And Admin runs the Accrual Activity Posting job
And Admin runs the Add Accrual Transactions job
And Admin runs the Add Accrual Transactions For Loans With Income Posted As Transactions job
And Admin runs the Add Periodic Accrual Transactions job
And Admin runs the Recalculate Interest for Loans job
Then Loan Repayment schedule has 4 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 June 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 30 | 01 July 2024 | | 188.27 | 61.73 | 2.08 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 2 | 31 | 01 August 2024 | | 126.03 | 62.24 | 1.57 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 3 | 31 | 01 September 2024 | | 63.27 | 62.76 | 1.05 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 4 | 30 | 01 October 2024 | | 0.0 | 63.27 | 0.53 | 0.0 | 0.0 | 63.8 | 0.0 | 0.0 | 0.0 | 63.8 |
Then Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 250.0 | 5.23 | 0.0 | 0.0 | 255.23 | 0.0 | 0.0 | 0.0 | 255.23 |
Then Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
| 01 June 2024 | Disbursement | 250.0 | 0.0 | 0.0 | 0.0 | 0.0 | 250.0 | false | false |
| 02 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Charge-off | 255.23 | 250.0 | 5.23 | 0.0 | 0.0 | 0.0 | false | false |
@TestRailId:C3338 @AdvancedPaymentAllocation
Scenario: Verify charged off loans to be excluded from scheduled jobs - accrual entries and interest are added when loan has reverted charged-off transaction
When Admin sets the business date to "01 June 2024"
When Admin creates a client with random data
When Admin creates a fully customized loan with the following data:
@@ -2093,30 +2024,6 @@ Feature: Charge-off
| 02 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Charge-off | 255.23 | 250.0 | 5.23 | 0.0 | 0.0 | 0.0 | false | false |
When Admin sets the business date to "06 June 2024"
Then Admin does a charge-off undo the loan
And Admin runs the Accrual Activity Posting job
And Admin runs the Add Accrual Transactions job
And Admin runs the Add Accrual Transactions For Loans With Income Posted As Transactions job
And Admin runs the Add Periodic Accrual Transactions job
And Admin runs the Recalculate Interest for Loans job
Then Loan Repayment schedule has 4 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 June 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 30 | 01 July 2024 | | 188.27 | 61.73 | 2.08 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 2 | 31 | 01 August 2024 | | 126.03 | 62.24 | 1.57 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 3 | 31 | 01 September 2024 | | 63.27 | 62.76 | 1.05 | 0.0 | 0.0 | 63.81 | 0.0 | 0.0 | 0.0 | 63.81 |
| 4 | 30 | 01 October 2024 | | 0.0 | 63.27 | 0.53 | 0.0 | 0.0 | 63.8 | 0.0 | 0.0 | 0.0 | 63.8 |
Then Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 250.0 | 5.23 | 0.0 | 0.0 | 255.23 | 0.0 | 0.0 | 0.0 | 255.23 |
Then Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
| 01 June 2024 | Disbursement | 250.0 | 0.0 | 0.0 | 0.0 | 0.0 | 250.0 | false | false |
| 02 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Accrual | 0.07 | 0.0 | 0.07 | 0.0 | 0.0 | 0.0 | false | false |
| 03 June 2024 | Charge-off | 255.23 | 250.0 | 5.23 | 0.0 | 0.0 | 0.0 | true | false |
| 06 June 2024 | Accrual | 0.21 | 0.0 | 0.21 | 0.0 | 0.0 | 0.0 | false | false |
@TestRailId:C3326 @AdvancedPaymentAllocation
Scenario: Verify the repayment schedule is updated before the Charge-off in case of interest recalculation = true
@@ -0,0 +1,30 @@
#
# 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.
#
cucumber.execution.parallel.enabled=false
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=3
cucumber.execution.parallel.config.fixed.max-pool-size=3
junit.jupiter.execution.parallel.config.fixed.parallelism=3
junit.jupiter.execution.parallel.enabled = false
junit.jupiter.execution.parallel.config.strategy=fixed
cucumber.plugin=pretty
cucumber.filter.tags=not @Skip
cucumber.execution.exclusive-resources.isolated.read-write=org.junit.platform.engine.support.hierarchical.ExclusiveResource.GLOBAL_KEY
cucumber.execution.execution-mode.feature=same_thread
@@ -18,6 +18,7 @@
*/
package org.apache.fineract.investor.service;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -43,7 +44,6 @@ import org.apache.fineract.investor.exception.ExternalAssetOwnerLoanProductAttri
import org.apache.fineract.investor.exception.ExternalAssetOwnerLoanProductAttributesException;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
import org.apache.fineract.portfolio.loanproduct.exception.LoanProductNotFoundException;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -150,7 +150,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
when(testContext.loanProductRepository.existsById(testContext.loanProductId)).thenReturn(true);
when(testContext.externalAssetOwnerLoanProductAttributesRepository.findById(1L)).thenReturn(Optional.empty());
ExternalAssetOwnerLoanProductAttributeNotFoundException thrownException = Assert.assertThrows(
ExternalAssetOwnerLoanProductAttributeNotFoundException thrownException = assertThrows(
ExternalAssetOwnerLoanProductAttributeNotFoundException.class,
() -> testContext.externalAssetOwnerLoanProductAttributesWriteService.updateExternalAssetOwnerLoanProductAttribute(command,
testContext.attributeKey, testContext.attributeValue));
@@ -181,7 +181,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
when(testContext.externalAssetOwnerLoanProductAttributesRepository.findById(command.entityId()))
.thenReturn(Optional.of(attributeInDB));
ExternalAssetOwnerLoanProductAttributesException thrownException = Assert.assertThrows(
ExternalAssetOwnerLoanProductAttributesException thrownException = assertThrows(
ExternalAssetOwnerLoanProductAttributesException.class,
() -> testContext.externalAssetOwnerLoanProductAttributesWriteService.updateExternalAssetOwnerLoanProductAttribute(command,
testContext.attributeKey, testContext.attributeValue));
@@ -233,7 +233,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
when(testContext.fromApiJsonHelper.extractStringNamed(ExternalAssetOwnerLoanProductAttributeRequestParameters.ATTRIBUTE_VALUE,
jsonCommandElement)).thenReturn(attributeValue);
PlatformApiDataValidationException thrownException = Assert.assertThrows(PlatformApiDataValidationException.class,
PlatformApiDataValidationException thrownException = assertThrows(PlatformApiDataValidationException.class,
() -> testContext.externalAssetOwnerLoanProductAttributesWriteService
.createExternalAssetOwnerLoanProductAttribute(command));
@@ -250,7 +250,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
when(testContext.loanProductRepository.existsById(testContext.loanProductId)).thenReturn(false);
LoanProductNotFoundException thrownException = Assert.assertThrows(LoanProductNotFoundException.class,
LoanProductNotFoundException thrownException = assertThrows(LoanProductNotFoundException.class,
() -> testContext.externalAssetOwnerLoanProductAttributesWriteService
.createExternalAssetOwnerLoanProductAttribute(command));
@@ -270,7 +270,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
testContext.attributeKey)).thenReturn(true);
when(testContext.loanProductRepository.existsById(testContext.loanProductId)).thenReturn(true);
ExternalAssetOwnerLoanProductAttributeAlreadyExistsException thrownException = Assert.assertThrows(
ExternalAssetOwnerLoanProductAttributeAlreadyExistsException thrownException = assertThrows(
ExternalAssetOwnerLoanProductAttributeAlreadyExistsException.class,
() -> testContext.externalAssetOwnerLoanProductAttributesWriteService
.createExternalAssetOwnerLoanProductAttribute(command));
@@ -291,7 +291,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
final JsonElement jsonCommandElement = testContext.fromJsonHelper.parse(testContext.jsonCommandString);
when(testContext.fromApiJsonHelper.extractStringNamed(ExternalAssetOwnerLoanProductAttributeRequestParameters.ATTRIBUTE_KEY,
jsonCommandElement)).thenReturn("BAD_KEY");
ExternalAssetOwnerLoanProductAttributeInvalidSettlementAttributeException thrownException = Assert.assertThrows(
ExternalAssetOwnerLoanProductAttributeInvalidSettlementAttributeException thrownException = assertThrows(
ExternalAssetOwnerLoanProductAttributeInvalidSettlementAttributeException.class,
() -> testContext.externalAssetOwnerLoanProductAttributesWriteService
.createExternalAssetOwnerLoanProductAttribute(command));
@@ -311,7 +311,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
final JsonElement jsonCommandElement = testContext.fromJsonHelper.parse(testContext.jsonCommandString);
when(testContext.fromApiJsonHelper.extractStringNamed(ExternalAssetOwnerLoanProductAttributeRequestParameters.ATTRIBUTE_VALUE,
jsonCommandElement)).thenReturn("BAD_VALUE");
ExternalAssetOwnerLoanProductAttributeInvalidSettlementAttributeException thrownException = Assert.assertThrows(
ExternalAssetOwnerLoanProductAttributeInvalidSettlementAttributeException thrownException = assertThrows(
ExternalAssetOwnerLoanProductAttributeInvalidSettlementAttributeException.class,
() -> testContext.externalAssetOwnerLoanProductAttributesWriteService
.createExternalAssetOwnerLoanProductAttribute(command));
@@ -66,7 +66,6 @@ import org.apache.fineract.investor.exception.ExternalAssetOwnerInitiateTransfer
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
import org.apache.fineract.portfolio.loanaccount.exception.LoanNotFoundException;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -132,7 +131,7 @@ public class ExternalAssetOwnersWriteServiceTest {
when(testContext.delayedSettlementAttributeService.isEnabled(testContext.loanProductId)).thenReturn(false);
// when
ExternalAssetOwnerInitiateTransferException thrownException = Assert.assertThrows(ExternalAssetOwnerInitiateTransferException.class,
ExternalAssetOwnerInitiateTransferException thrownException = assertThrows(ExternalAssetOwnerInitiateTransferException.class,
() -> testContext.externalAssetOwnersWriteServiceImpl.intermediarySaleLoanByLoanId(command));
// then
@@ -160,7 +159,7 @@ public class ExternalAssetOwnersWriteServiceTest {
any(LocalDate.class))).thenReturn(externalAssetOwnerTransferList);
// when
ExternalAssetOwnerInitiateTransferException thrownException = Assert.assertThrows(ExternalAssetOwnerInitiateTransferException.class,
ExternalAssetOwnerInitiateTransferException thrownException = assertThrows(ExternalAssetOwnerInitiateTransferException.class,
() -> testContext.externalAssetOwnersWriteServiceImpl.intermediarySaleLoanByLoanId(command));
// then
@@ -356,7 +355,7 @@ public class ExternalAssetOwnersWriteServiceTest {
when(testContext.delayedSettlementAttributeService.isEnabled(testContext.loanProductId)).thenReturn(true);
// when
ExternalAssetOwnerInitiateTransferException thrownException = Assert.assertThrows(ExternalAssetOwnerInitiateTransferException.class,
ExternalAssetOwnerInitiateTransferException thrownException = assertThrows(ExternalAssetOwnerInitiateTransferException.class,
() -> testContext.externalAssetOwnersWriteServiceImpl.intermediarySaleLoanByLoanId(command));
// then
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.cob.listener;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -20,6 +20,7 @@ package org.apache.fineract.cob.loan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
@@ -41,7 +42,6 @@ import org.apache.fineract.infrastructure.core.exception.MultiException;
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.service.LoanAccrualsProcessingService;
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -92,7 +92,7 @@ public class AddPeriodicAccrualEntriesBusinessStepTest {
doThrow(new MultiException(Collections.singletonList(new RuntimeException()))).when(loanAccrualsProcessingService)
.addPeriodicAccruals(any(LocalDate.class), eq(loanForProcessing));
// when
final BusinessStepException businessStepException = Assert.assertThrows(BusinessStepException.class,
final BusinessStepException businessStepException = assertThrows(BusinessStepException.class,
() -> underTest.execute(loanForProcessing));
// then
verify(loanAccrualsProcessingService, times(1)).addPeriodicAccruals(any(LocalDate.class), eq(loanForProcessing));
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.cob.loan;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
@@ -18,11 +18,11 @@
*/
package org.apache.fineract.cob.loan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.doNothing;
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.businessdate.data;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.businessdate.data;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
import org.junit.jupiter.api.Test;
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.businessdate.mapper;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.infrastructure.businessdate.validator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.time.LocalDate;
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateData;
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.infrastructure.core.config;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@@ -18,13 +18,16 @@
*/
package org.apache.fineract.infrastructure.dataqueries.service;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.infrastructure.dataqueries.service.export.DatatableExportUtil;
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -43,27 +46,27 @@ public class DatatableExportUtilTest {
@Test
public void emptyFolderTest() {
Assert.assertEquals("", DatatableExportUtil.normalizeFolderName(""));
Assert.assertEquals("", DatatableExportUtil.normalizeFolderName("/"));
Assert.assertEquals("", DatatableExportUtil.normalizeFolderName(null));
assertEquals("", DatatableExportUtil.normalizeFolderName(""));
assertEquals("", DatatableExportUtil.normalizeFolderName("/"));
assertEquals("", DatatableExportUtil.normalizeFolderName(null));
}
@Test
public void specialCharacterFolderTest() {
Assert.assertEquals("_", DatatableExportUtil.normalizeFolderName("Á"));
Assert.assertEquals("_", DatatableExportUtil.normalizeFolderName("="));
Assert.assertEquals("_", DatatableExportUtil.normalizeFolderName("\\"));
Assert.assertEquals("_", DatatableExportUtil.normalizeFolderName("@"));
assertEquals("_", DatatableExportUtil.normalizeFolderName("Á"));
assertEquals("_", DatatableExportUtil.normalizeFolderName("="));
assertEquals("_", DatatableExportUtil.normalizeFolderName("\\"));
assertEquals("_", DatatableExportUtil.normalizeFolderName("@"));
}
@Test
public void normalizedFolderNameTest() {
Assert.assertEquals("$", DatatableExportUtil.normalizeFolderName("$"));
Assert.assertEquals("reports", DatatableExportUtil.normalizeFolderName("reports"));
Assert.assertEquals("reports", DatatableExportUtil.normalizeFolderName("reports/"));
Assert.assertEquals("reports", DatatableExportUtil.normalizeFolderName("/reports/"));
Assert.assertEquals("reports/content", DatatableExportUtil.normalizeFolderName("reports/content"));
Assert.assertEquals("reports/content", DatatableExportUtil.normalizeFolderName("reports/////content"));
assertEquals("$", DatatableExportUtil.normalizeFolderName("$"));
assertEquals("reports", DatatableExportUtil.normalizeFolderName("reports"));
assertEquals("reports", DatatableExportUtil.normalizeFolderName("reports/"));
assertEquals("reports", DatatableExportUtil.normalizeFolderName("/reports/"));
assertEquals("reports/content", DatatableExportUtil.normalizeFolderName("reports/content"));
assertEquals("reports/content", DatatableExportUtil.normalizeFolderName("reports/////content"));
}
@Test
@@ -71,41 +74,40 @@ public class DatatableExportUtilTest {
String reportName = "reportName";
Map<String, String> reportParams = Collections.synchronizedSortedMap(new TreeMap<>(Map.of("param1", "value1", "param2", "value2")));
String fileName = DatatableExportUtil.generateS3DatatableExportFileName(1024, "folder", "csv", reportName, reportParams);
Assert.assertTrue(fileName.matches("folder/reportName\\(param1_value1;param2_value2\\)_\\d{14}.csv"));
assertTrue(fileName.matches("folder/reportName\\(param1_value1;param2_value2\\)_\\d{14}.csv"));
}
@Test
public void generateDatatableExportFileNameComplexTest() {
String reportName = "reportName";
Map<String, String> reportParams = Collections.synchronizedSortedMap(new TreeMap<>(Map.of("param1", "value1", "param2", "value2")));
Assert.assertTrue(DatatableExportUtil.generateS3DatatableExportFileName(1024, "folder///name///", "csv", reportName, reportParams)
assertTrue(DatatableExportUtil.generateS3DatatableExportFileName(1024, "folder///name///", "csv", reportName, reportParams)
.matches("folder/name/reportName\\(param1_value1;param2_value2\\)_\\d{14}.csv"));
IllegalArgumentException folderTooLongException = Assert.assertThrows(IllegalArgumentException.class, () -> {
IllegalArgumentException folderTooLongException = assertThrows(IllegalArgumentException.class, () -> {
DatatableExportUtil.generateS3DatatableExportFileName(30, "too_long_folder_name_test", "csv", reportName, reportParams);
});
Assert.assertEquals("The folder name is too long", folderTooLongException.getMessage());
assertEquals("The folder name is too long", folderTooLongException.getMessage());
IllegalArgumentException maximumLengthException = Assert.assertThrows(IllegalArgumentException.class, () -> {
IllegalArgumentException maximumLengthException = assertThrows(IllegalArgumentException.class, () -> {
DatatableExportUtil.generateS3DatatableExportFileName(29, "folder///name/", "csv", reportName, reportParams);
});
Assert.assertEquals("The maximum length must be greater than 30", maximumLengthException.getMessage());
assertEquals("The maximum length must be greater than 30", maximumLengthException.getMessage());
IllegalArgumentException extensionRequired = Assert.assertThrows(IllegalArgumentException.class, () -> {
IllegalArgumentException extensionRequired = assertThrows(IllegalArgumentException.class, () -> {
DatatableExportUtil.generateS3DatatableExportFileName(30, "too_long_folder_name_test", null, reportName, reportParams);
});
Assert.assertEquals("The extension is required", extensionRequired.getMessage());
assertEquals("The extension is required", extensionRequired.getMessage());
IllegalArgumentException reportNameRequired = Assert.assertThrows(IllegalArgumentException.class, () -> {
IllegalArgumentException reportNameRequired = assertThrows(IllegalArgumentException.class, () -> {
DatatableExportUtil.generateS3DatatableExportFileName(30, "too_long_folder_name_test", "csv", null, reportParams);
});
Assert.assertEquals("The report name is required", reportNameRequired.getMessage());
assertEquals("The report name is required", reportNameRequired.getMessage());
Assert.assertTrue(DatatableExportUtil.generateS3DatatableExportFileName(1024, "folder///name/", ".csv", reportName, null)
assertTrue(DatatableExportUtil.generateS3DatatableExportFileName(1024, "folder///name/", ".csv", reportName, null)
.matches("folder/name/reportName_\\d{14}.csv"));
Assert.assertTrue(
DatatableExportUtil.generateS3DatatableExportFileName(1024, "folder///name/", "csv", "report/with/slash", reportParams)
.matches("folder/name/report_with_slash\\(param1_value1;param2_value2\\)_\\d{14}.csv"));
assertTrue(DatatableExportUtil.generateS3DatatableExportFileName(1024, "folder///name/", "csv", "report/with/slash", reportParams)
.matches("folder/name/report_with_slash\\(param1_value1;param2_value2\\)_\\d{14}.csv"));
}
}
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.event.external.service.message;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.increasebusinessdateby1day;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.increasecobdateby1day;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.portfolio.loanaccount.domain;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.LocalDate;
import java.util.ArrayList;
@@ -20,8 +20,8 @@ package org.apache.fineract.portfolio.loanproduct;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import io.cucumber.java8.En;
import org.apache.commons.lang3.StringUtils;
@@ -68,7 +68,6 @@ import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHe
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
import org.junit.experimental.runners.Enclosed;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Named;
import org.junit.jupiter.api.Nested;
@@ -76,9 +75,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runner.RunWith;
@RunWith(Enclosed.class)
@Slf4j
public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest {
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.integrationtests;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.math.BigDecimal;
import java.util.List;
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.integrationtests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
@@ -88,7 +88,7 @@ public class SearchResourcesTest {
getResources(resources));
assertNotNull(searchResponse);
assertEquals(1, searchResponse.size());
assertEquals("Client name comparation", getClientResponse.getDisplayName(), searchResponse.get(0).getEntityName());
assertEquals(getClientResponse.getDisplayName(), searchResponse.get(0).getEntityName(), "Client name comparation");
}
@Test
@@ -20,9 +20,9 @@ package org.apache.fineract.integrationtests.investor.externalassetowner;
import static org.apache.fineract.client.models.ExternalTransferData.StatusEnum.CANCELLED;
import static org.apache.fineract.client.models.ExternalTransferData.StatusEnum.PENDING;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.math.BigDecimal;
import java.time.LocalDate;
@@ -114,21 +114,21 @@ public class SearchExternalAssetOwnerTransferTest extends ExternalAssetOwnerTran
.buildExternalAssetOwnerSearchRequest(textToSearch, "", null, null, 0, 10);
PageExternalTransferData response = EXTERNAL_ASSET_OWNER_HELPER.searchExternalAssetOwnerTransfer(searchRequest);
assertNotNull(response);
assertEquals("Expecting none result", 0, response.getContent().size());
assertEquals(0, response.getContent().size(), "Expecting none result");
// Search over the current Asset Transfers and get just the first five
textToSearch = "";
searchRequest = EXTERNAL_ASSET_OWNER_HELPER.buildExternalAssetOwnerSearchRequest(textToSearch, "", null, null, 0, 5);
response = EXTERNAL_ASSET_OWNER_HELPER.searchExternalAssetOwnerTransfer(searchRequest);
assertNotNull(response);
assertEquals("Expecting first five results", 5, response.getContent().size());
assertEquals(5, response.getContent().size(), "Expecting first five results");
textToSearch = response.getContent().iterator().next().getOwner().getExternalId();
searchRequest = EXTERNAL_ASSET_OWNER_HELPER.buildExternalAssetOwnerSearchRequest(textToSearch, "", null, null, 0, 5);
response = EXTERNAL_ASSET_OWNER_HELPER.searchExternalAssetOwnerTransfer(searchRequest);
assertNotNull(response);
assertTrue("Expecting only two results", response.getContent().size() >= 2);
assertEquals("External Id is different", textToSearch, response.getContent().iterator().next().getOwner().getExternalId());
assertTrue(response.getContent().size() >= 2, "Expecting only two results");
assertEquals(textToSearch, response.getContent().iterator().next().getOwner().getExternalId(), "External Id is different");
}
@Test
@@ -146,7 +146,7 @@ public class SearchExternalAssetOwnerTransferTest extends ExternalAssetOwnerTran
searchRequest = EXTERNAL_ASSET_OWNER_HELPER.buildExternalAssetOwnerSearchRequest(null, attribute, fromDate, toDate, 0, null);
response = EXTERNAL_ASSET_OWNER_HELPER.searchExternalAssetOwnerTransfer(searchRequest);
validateResponse(response, 1);
assertTrue("Transfers were not found", response.getContent().size() > 0);
assertTrue(response.getContent().size() > 0, "Transfers were not found");
}
@Test
@@ -164,7 +164,7 @@ public class SearchExternalAssetOwnerTransferTest extends ExternalAssetOwnerTran
searchRequest = EXTERNAL_ASSET_OWNER_HELPER.buildExternalAssetOwnerSearchRequest(null, attribute, fromDate, toDate, 0, null);
response = EXTERNAL_ASSET_OWNER_HELPER.searchExternalAssetOwnerTransfer(searchRequest);
validateResponse(response, 1);
assertTrue("Transfers were not found", response.getContent().size() > 0);
assertTrue(response.getContent().size() > 0, "Transfers were not found");
}
@Test
@@ -192,11 +192,11 @@ public class SearchExternalAssetOwnerTransferTest extends ExternalAssetOwnerTran
assertEquals(isEmpty, response.getEmpty());
assertEquals(true, response.getFirst());
if (isEmpty) {
assertTrue("Transfers size difference", response.getContent().size() == size);
assertTrue("Total pages difference", response.getTotalPages() == 0);
assertTrue(response.getContent().size() == size, "Transfers size difference");
assertTrue(response.getTotalPages() == 0, "Total pages difference");
} else {
assertTrue("Total pages difference", response.getTotalPages() > 0);
assertTrue("Total number of elements difference", response.getNumberOfElements() > 0);
assertTrue(response.getTotalPages() > 0, "Total pages difference");
assertTrue(response.getNumberOfElements() > 0, "Total number of elements difference");
}
assertEquals(true, response.getFirst());
}