Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/
package org.apache.fineract.integrationtests;

import com.google.gson.Gson;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.models.BusinessDateUpdateRequest;
import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest;
import org.apache.fineract.client.models.PostLoanProductsRequest;
import org.apache.fineract.client.models.PostLoanProductsResponse;
import org.apache.fineract.infrastructure.event.external.data.ExternalEventResponse;
Expand Down Expand Up @@ -307,26 +306,19 @@ private void enableCOBBusinessStep(String... steps) {

}

public static String getExternalEventConfigurationsForUpdateJSON() {
Map<String, Map<String, Boolean>> configurationsForUpdate = new HashMap<>();
Map<String, Boolean> configurations = new HashMap<>();
configurations.put("CentersCreateBusinessEvent", true);
configurations.put("ClientActivateBusinessEvent", true);
configurationsForUpdate.put("externalEventConfigurations", configurations);
return new Gson().toJson(configurationsForUpdate);
}

private void enableLoanAccountCustomSnapshotBusinessEvent() {
final Map<String, Boolean> updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec,
responseSpec, "{\"externalEventConfigurations\":{\"LoanAccountCustomSnapshotBusinessEvent\":true}}\n");
responseSpec, new ExternalEventConfigurationUpdateRequest()
.externalEventConfigurations(Map.of("LoanAccountCustomSnapshotBusinessEvent", true)));
Assertions.assertEquals(updatedConfigurations.size(), 1);
Assertions.assertTrue(updatedConfigurations.containsKey("LoanAccountCustomSnapshotBusinessEvent"));
Assertions.assertTrue(updatedConfigurations.get("LoanAccountCustomSnapshotBusinessEvent"));
}

private void disableLoanAccountCustomSnapshotBusinessEvent() {
final Map<String, Boolean> updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec,
responseSpec, "{\"externalEventConfigurations\":{\"LoanAccountCustomSnapshotBusinessEvent\":false}}\n");
responseSpec, new ExternalEventConfigurationUpdateRequest()
.externalEventConfigurations(Map.of("LoanAccountCustomSnapshotBusinessEvent", false)));
Assertions.assertEquals(updatedConfigurations.size(), 1);
Assertions.assertTrue(updatedConfigurations.containsKey("LoanAccountCustomSnapshotBusinessEvent"));
Assertions.assertFalse(updatedConfigurations.get("LoanAccountCustomSnapshotBusinessEvent"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.Map;
import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest;
import org.apache.fineract.integrationtests.common.ExternalEventConfigurationHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -68,9 +69,10 @@ private void verifyAllEventConfigurations(ArrayList<Map<String, Object>> actualE

@Test
public void updateExternalEventConfigurations() {
String updateRequestJson = ExternalEventConfigurationHelper.getExternalEventConfigurationsForUpdateJSON();
ExternalEventConfigurationUpdateRequest updateRequest = ExternalEventConfigurationHelper
.getExternalEventConfigurationsForUpdateRequest();
final Map<String, Boolean> updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec,
responseSpec, updateRequestJson);
responseSpec, updateRequest);
Assertions.assertEquals(updatedConfigurations.size(), 2);
Assertions.assertTrue(updatedConfigurations.containsKey("CentersCreateBusinessEvent"));
Assertions.assertTrue(updatedConfigurations.containsKey("ClientActivateBusinessEvent"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Optional;
import java.util.UUID;
import org.apache.fineract.accounting.common.AccountingConstants;
import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest;
import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
import org.apache.fineract.client.models.GetSavingsAccountTransactionsPageItem;
import org.apache.fineract.client.models.PostLoanProductsRequest;
Expand Down Expand Up @@ -248,15 +249,17 @@ private void verifyTransactionIsAccountTransfer(final LocalDate transactionDate,

private void enableLoanBalanceChangedBusinessEvent() {
final Map<String, Boolean> updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec,
responseSpec, "{\"externalEventConfigurations\":{\"LoanBalanceChangedBusinessEvent\":true}}\n");
responseSpec,
new ExternalEventConfigurationUpdateRequest().externalEventConfigurations(Map.of("LoanBalanceChangedBusinessEvent", true)));
Assertions.assertEquals(updatedConfigurations.size(), 1);
Assertions.assertTrue(updatedConfigurations.containsKey("LoanBalanceChangedBusinessEvent"));
Assertions.assertTrue(updatedConfigurations.get("LoanBalanceChangedBusinessEvent"));
}

private void disableLoanBalanceChangedBusinessEvent() {
final Map<String, Boolean> updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec,
responseSpec, "{\"externalEventConfigurations\":{\"LoanBalanceChangedBusinessEvent\":false}}\n");
responseSpec, new ExternalEventConfigurationUpdateRequest()
.externalEventConfigurations(Map.of("LoanBalanceChangedBusinessEvent", false)));
Assertions.assertEquals(updatedConfigurations.size(), 1);
Assertions.assertTrue(updatedConfigurations.containsKey("LoanBalanceChangedBusinessEvent"));
Assertions.assertFalse(updatedConfigurations.get("LoanBalanceChangedBusinessEvent"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import org.apache.fineract.client.models.BusinessDateUpdateRequest;
import org.apache.fineract.client.models.GetJournalEntriesTransactionIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.GetStandingInstructionHistoryPageItemsResponse;
import org.apache.fineract.client.models.GetStandingInstructionsStandingInstructionIdResponse;
import org.apache.fineract.client.models.JournalEntryTransactionItem;
import org.apache.fineract.client.models.PostClientsResponse;
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
Expand Down Expand Up @@ -741,23 +744,24 @@ public void testExecuteStandingInstructionsJobOutcome() throws InterruptedExcept
HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsId);
Float toSavingsBalanceAfter = (Float) toSavingsSummaryAfter.get("accountBalance");

final HashMap standingInstructionData = standingInstructionsHelper.getStandingInstructionById(standingInstructionId.toString());
Float expectedFromSavingsBalance = fromSavingsBalanceBefore - (Float) standingInstructionData.get("amount");
Float expectedToSavingsBalance = toSavingsBalanceBefore + (Float) standingInstructionData.get("amount");
final GetStandingInstructionsStandingInstructionIdResponse standingInstructionData = standingInstructionsHelper
.getStandingInstructionById(standingInstructionId.longValue());
Float expectedFromSavingsBalance = fromSavingsBalanceBefore - standingInstructionData.getAmount();
Float expectedToSavingsBalance = toSavingsBalanceBefore + standingInstructionData.getAmount();

Assertions.assertEquals(expectedFromSavingsBalance, fromSavingsBalanceAfter,
"Verifying From Savings Balance after Successful completion of Scheduler Job");
Assertions.assertEquals(expectedToSavingsBalance, toSavingsBalanceAfter,
"Verifying To Savings Balance after Successful completion of Scheduler Job");
Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue();
Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue();
List<HashMap> standingInstructionHistoryData = standingInstructionsHelper.getStandingInstructionHistory(fromSavingsId,
fromAccountType, clientID, transferType);
Set<GetStandingInstructionHistoryPageItemsResponse> standingInstructionHistoryData = standingInstructionsHelper
.getStandingInstructionHistory(fromSavingsId, fromAccountType, clientID, transferType);
Assertions.assertEquals(1, standingInstructionHistoryData.size(),
"Verifying the no of standing instruction transactions logged for the client");
HashMap loggedTransaction = standingInstructionHistoryData.get(0);
GetStandingInstructionHistoryPageItemsResponse loggedTransaction = standingInstructionHistoryData.iterator().next();

Assertions.assertEquals((Float) standingInstructionData.get("amount"), (Float) loggedTransaction.get("amount"),
Assertions.assertEquals(standingInstructionData.getAmount(), loggedTransaction.getAmount(),
"Verifying transferred amount and logged transaction amounts");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.fineract.client.models.PostProvisioningEntriesResponse;
import org.apache.fineract.client.models.ProvisionEntryRequest;
import org.apache.fineract.client.models.ProvisioningCategoryData;
import org.apache.fineract.client.models.ProvisioningEntryData;
import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase;
import org.apache.fineract.integrationtests.common.Utils;
Expand Down Expand Up @@ -61,11 +63,11 @@ public void testRetrieveProvisioningEntryWithNoActiveLoansDoesNotReturn500() {

ProvisioningTransactionHelper transactionHelper = new ProvisioningTransactionHelper(requestSpec, responseSpec);
AccountHelper accountHelper = new AccountHelper(requestSpec, responseSpec);
ArrayList categories = transactionHelper.retrieveAllProvisioningCategories();
List<ProvisioningCategoryData> categories = transactionHelper.retrieveAllProvisioningCategories();
Account liability = accountHelper.createLiabilityAccount();
Account expense = accountHelper.createExpenseAccount();

Map requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense);
Map requestCriteria = ProvisioningHelper.createProvisioningCriteriaJson(loanProducts, categories, liability, expense);
String criteriaJson = new Gson().toJson(requestCriteria);
Integer criteriaId = transactionHelper.createProvisioningCriteria(criteriaJson);
assertNotNull(criteriaId);
Expand All @@ -86,6 +88,6 @@ public void testRetrieveProvisioningEntryWithNoActiveLoansDoesNotReturn500() {
assertNotNull(entry.getId());

// Cleanup
transactionHelper.deleteProvisioningCriteria(criteriaId);
transactionHelper.deleteProvisioningCriteria(criteriaId.longValue());
}
}
Loading
Loading