bulk auto reformat ca. 2900 files using ./gradlew :spotlessApply [FINERACT-1006]

This commit is contained in:
Michael Vorburger
2020-06-14 18:31:47 +02:00
committed by Michael Vorburger ⛑️
parent 89e321acaf
commit 9da5932307
2899 changed files with 44572 additions and 46101 deletions
@@ -155,7 +155,8 @@ public class AccountNumberPreferencesTest {
LOG.info("Successfully deleted account number preference (ID: {} )", delResponse.get("resourceId")); LOG.info("Successfully deleted account number preference (ID: {} )", delResponse.get("resourceId"));
} }
/* Deletion of invalid account preference ID should fail */ /* Deletion of invalid account preference ID should fail */
LOG.info("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE WITH INVALID ID------------------------------------------"); LOG.info(
"---------------------------------DELETING ACCOUNT NUMBER PREFERENCE WITH INVALID ID------------------------------------------");
HashMap<String, Object> deletionError = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(10, HashMap<String, Object> deletionError = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(10,
this.responseNotFoundError, ""); this.responseNotFoundError, "");
@@ -180,24 +181,24 @@ public class AccountNumberPreferencesTest {
} }
private void createAccountNumberPreference() { private void createAccountNumberPreference() {
this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference( this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createClientAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Client (ID: {})", this.clientAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Client (ID: {})", this.clientAccountNumberPreferenceId);
this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createLoanAccountNumberPreference( this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createLoanAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Loan (ID: {} )", this.loanAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Loan (ID: {} )", this.loanAccountNumberPreferenceId);
this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference( this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createSavingsAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Savings (ID: {})", this.savingsAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Savings (ID: {})", this.savingsAccountNumberPreferenceId);
this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference( this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createGroupsAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Groups (ID: {})", this.groupsAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Groups (ID: {})", this.groupsAccountNumberPreferenceId);
this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference( this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createCenterAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Center (ID: {})", this.centerAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Center (ID: {})", this.centerAccountNumberPreferenceId);
this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId, this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId,
@@ -211,10 +212,11 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) { private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) {
/* Creating account Preference with duplicate data should fail */ /* Creating account Preference with duplicate data should fail */
LOG.info("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH DUPLICATE DATA------------------------------------------"); LOG.info(
"---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH DUPLICATE DATA------------------------------------------");
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData( HashMap<String, Object> creationError = this.accountNumberPreferencesHelper
this.responseForbiddenError, accountType, prefixType, ""); .createAccountNumberPreferenceWithInvalidData(this.responseForbiddenError, accountType, prefixType, "");
Assertions.assertEquals("error.msg.account.number.format.duplicate.account.type", Assertions.assertEquals("error.msg.account.number.format.duplicate.account.type",
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -224,34 +226,36 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) { private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) {
/* Creating account Preference with invalid data should fail */ /* Creating account Preference with invalid data should fail */
LOG.info("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); LOG.info(
"---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------");
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData( HashMap<String, Object> creationError = this.accountNumberPreferencesHelper
this.responseValidationError, accountType, prefixType, ""); .createAccountNumberPreferenceWithInvalidData(this.responseValidationError, accountType, prefixType, "");
if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals( if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)
"validation.msg.accountNumberFormat.accountType.is.not.within.expected.range")) { .equals("validation.msg.accountNumberFormat.accountType.is.not.within.expected.range")) {
Assertions.assertEquals("validation.msg.accountNumberFormat.accountType.is.not.within.expected.range", Assertions.assertEquals("validation.msg.accountNumberFormat.accountType.is.not.within.expected.range",
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} else if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals( } else if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)
"validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations")) { .equals("validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations")) {
Assertions.assertEquals("validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations", Assertions.assertEquals("validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations",
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
} }
private void updateAccountNumberPreference() { private void updateAccountNumberPreference() {
HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference( HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper
this.clientAccountNumberPreferenceId, "101", this.responseSpec, ""); .updateAccountNumberPreference(this.clientAccountNumberPreferenceId, "101", this.responseSpec, "");
LOG.info("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID {}" LOG.info("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID {}",
, accountNumberPreferences.get("resourceId")); accountNumberPreferences.get("resourceId"));
this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"), this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"),
this.responseSpec, this.requestSpec); this.responseSpec, this.requestSpec);
/* Update invalid account preference id should fail */ /* Update invalid account preference id should fail */
LOG.info("---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); LOG.info(
"---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------");
/* Invalid Account Type */ /* Invalid Account Type */
HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101", HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101",
@@ -260,8 +264,8 @@ public class AccountNumberPreferencesTest {
Assertions.assertEquals("error.msg.resource.not.found", updationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); Assertions.assertEquals("error.msg.resource.not.found", updationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
/* Invalid Prefix Type */ /* Invalid Prefix Type */
HashMap<String, Object> updationError1 = this.accountNumberPreferencesHelper.updateAccountNumberPreference( HashMap<String, Object> updationError1 = this.accountNumberPreferencesHelper
this.clientAccountNumberPreferenceId, "103", this.responseValidationError, ""); .updateAccountNumberPreference(this.clientAccountNumberPreferenceId, "103", this.responseValidationError, "");
Assertions.assertEquals("validation.msg.validation.errors.exist", updationError1.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); Assertions.assertEquals("validation.msg.validation.errors.exist", updationError1.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -288,8 +292,8 @@ public class AccountNumberPreferencesTest {
this.groupAccountNo = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "accountNo"); this.groupAccountNo = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "accountNo");
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String groupsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String groupsPrefixName = (String) this.accountNumberPreferencesHelper
this.groupsAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.groupsAccountNumberPreferenceId, "prefixType.value");
if (groupsPrefixName.equals(this.officeName)) { if (groupsPrefixName.equals(this.officeName)) {
@@ -313,8 +317,8 @@ public class AccountNumberPreferencesTest {
Assertions.assertTrue(center.getName().equals(name)); Assertions.assertTrue(center.getName().equals(name));
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String centerPrefixName = (String) this.accountNumberPreferencesHelper
this.centerAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.centerAccountNumberPreferenceId, "prefixType.value");
final String CENTER_URL = "/fineract-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER; final String CENTER_URL = "/fineract-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER;
if (centerPrefixName.equals(this.officeName)) { if (centerPrefixName.equals(this.officeName)) {
@@ -326,7 +330,6 @@ public class AccountNumberPreferencesTest {
} }
} }
private void createAndValidateClientWithoutAccountPreference() { private void createAndValidateClientWithoutAccountPreference() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(this.clientId); Assertions.assertNotNull(this.clientId);
@@ -337,8 +340,8 @@ public class AccountNumberPreferencesTest {
private void createAndValidateClientBasedOnAccountPreference() { private void createAndValidateClientBasedOnAccountPreference() {
final String codeName = "ClientType"; final String codeName = "ClientType";
String clientAccountNo = null; String clientAccountNo = null;
String clientPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String clientPrefixName = (String) this.accountNumberPreferencesHelper
this.clientAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.clientAccountNumberPreferenceId, "prefixType.value");
if (clientPrefixName.equals(this.clientTypeName)) { if (clientPrefixName.equals(this.clientTypeName)) {
/* Retrieve Code id for the Code "ClientType" */ /* Retrieve Code id for the Code "ClientType" */
@@ -412,8 +415,8 @@ public class AccountNumberPreferencesTest {
"accountNo"); "accountNo");
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String loanPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String loanPrefixName = (String) this.accountNumberPreferencesHelper
this.loanAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.loanAccountNumberPreferenceId, "prefixType.value");
if (loanPrefixName.equals(this.officeName)) { if (loanPrefixName.equals(this.officeName)) {
String loanOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "officeName"); String loanOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "officeName");
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanOfficeName); this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanOfficeName);
@@ -458,14 +461,14 @@ public class AccountNumberPreferencesTest {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.savingsId = this.savingsAccountHelper this.savingsId = this.savingsAccountHelper.applyForSavingsApplication(this.clientId, this.savingsProductId,
.applyForSavingsApplication(this.clientId, this.savingsProductId, ACCOUNT_TYPE_INDIVIDUAL); ACCOUNT_TYPE_INDIVIDUAL);
String savingsAccountNo = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "accountNo"); String savingsAccountNo = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "accountNo");
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String savingsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String savingsPrefixName = (String) this.accountNumberPreferencesHelper
this.savingsAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.savingsAccountNumberPreferenceId, "prefixType.value");
if (savingsPrefixName.equals(this.officeName)) { if (savingsPrefixName.equals(this.officeName)) {
String savingsOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), String savingsOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(),
@@ -127,8 +127,8 @@ public class AccountTransferTest {
*/ */
@AfterEach @AfterEach
public void tearDown() { public void tearDown() {
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = financialActivityAccountHelper
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
} }
@@ -214,10 +214,10 @@ public class AccountTransferTest {
HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsID); HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsID);
assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"), assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"),
"Verifying To Savings Account Balance after Account Transfer"); "Verifying To Savings Account Balance after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), final JournalEntry[] office1LiabilityEntries = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), final JournalEntry[] office2LiabilityEntries = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries); AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -311,10 +311,10 @@ public class AccountTransferTest {
assertEquals(TRANSFER_AMOUNT_ADJUST, toLoanSummaryAfter.get("totalRepayment"), assertEquals(TRANSFER_AMOUNT_ADJUST, toLoanSummaryAfter.get("totalRepayment"),
"Verifying To Loan Repayment Amount after Account Transfer"); "Verifying To Loan Repayment Amount after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office1LiabilityEntries = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office2LiabilityEntries = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries); AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -432,10 +432,10 @@ public class AccountTransferTest {
assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"), assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"),
"Verifying From Savings Account Balance after Account Transfer"); "Verifying From Savings Account Balance after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office1LiabilityEntries = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office2LiabilityEntries = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries); AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -68,6 +68,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
public class AccountingScenarioIntegrationTest { public class AccountingScenarioIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class);
private static RequestSpecification requestSpec; private static RequestSpecification requestSpec;
private static ResponseSpecification responseSpec; private static ResponseSpecification responseSpec;
@@ -94,7 +95,8 @@ public class AccountingScenarioIntegrationTest {
Float SP_WITHDRAWAL_AMOUNT = Float.valueOf(WITHDRAWAL_AMOUNT); Float SP_WITHDRAWAL_AMOUNT = Float.valueOf(WITHDRAWAL_AMOUNT);
Float SP_WITHDRAWAL_AMOUNT_ADJUSTED = Float.valueOf(WITHDRAWAL_AMOUNT_ADJUSTED); Float SP_WITHDRAWAL_AMOUNT_ADJUSTED = Float.valueOf(WITHDRAWAL_AMOUNT_ADJUSTED);
private final String[] REPAYMENT_DATE = { "", "04 May 2011", "04 July 2011", "04 September 2011", "04 November 2011", "04 January 2012" }; private final String[] REPAYMENT_DATE = { "", "04 May 2011", "04 July 2011", "04 September 2011", "04 November 2011",
"04 January 2012" };
private final Float[] REPAYMENT_AMOUNT = { .0f, 2200.0f, 3000.0f, 900.0f, 2000.0f, 2500.0f }; private final Float[] REPAYMENT_AMOUNT = { .0f, 2200.0f, 3000.0f, 900.0f, 2000.0f, 2500.0f };
private final Float AMOUNT_TO_BE_WAIVE = 400.0f; private final Float AMOUNT_TO_BE_WAIVE = 400.0f;
@@ -274,8 +276,8 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) }; final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) }; final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountInitialEntry);
this.journalEntryHelper this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, liablilityAccountInitialEntry); liablilityAccountInitialEntry);
// First Transaction-Deposit // First Transaction-Deposit
this.savingsAccountHelper.depositToSavingsAccount(savingsID, DEPOSIT_AMOUNT, SavingsAccountHelper.TRANSACTION_DATE, this.savingsAccountHelper.depositToSavingsAccount(savingsID, DEPOSIT_AMOUNT, SavingsAccountHelper.TRANSACTION_DATE,
@@ -285,10 +287,10 @@ public class AccountingScenarioIntegrationTest {
assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after Deposit"); assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after Deposit");
LOG.info("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------"); LOG.info("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------");
final JournalEntry[] assetAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, final JournalEntry[] assetAccountFirstTransactionEntry = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(this.SP_DEPOSIT_AMOUNT, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liabililityAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, final JournalEntry[] liabililityAccountFirstTransactionEntry = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.SP_DEPOSIT_AMOUNT, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountFirstTransactionEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountFirstTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liabililityAccountFirstTransactionEntry); liabililityAccountFirstTransactionEntry);
@@ -301,10 +303,10 @@ public class AccountingScenarioIntegrationTest {
assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after Withdrawal"); assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after Withdrawal");
LOG.info("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------"); LOG.info("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------");
final JournalEntry[] assetAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, final JournalEntry[] assetAccountSecondTransactionEntry = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] liabililityAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, final JournalEntry[] liabililityAccountSecondTransactionEntry = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountSecondTransactionEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountSecondTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liabililityAccountSecondTransactionEntry); liabililityAccountSecondTransactionEntry);
@@ -322,16 +324,15 @@ public class AccountingScenarioIntegrationTest {
Float chargeAmount = (Float) paidCharge.get("amount"); Float chargeAmount = (Float) paidCharge.get("amount");
// Withdrawal after adding Charge of type Withdrawal Fee // Withdrawal after adding Charge of type Withdrawal Fee
this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsID, WITHDRAWAL_AMOUNT_ADJUSTED, this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsID, WITHDRAWAL_AMOUNT_ADJUSTED, SavingsAccountHelper.TRANSACTION_DATE,
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
summary = this.savingsAccountHelper.getSavingsSummary(savingsID); summary = this.savingsAccountHelper.getSavingsSummary(savingsID);
balance = balance - SP_WITHDRAWAL_AMOUNT_ADJUSTED - chargeAmount; balance = balance - SP_WITHDRAWAL_AMOUNT_ADJUSTED - chargeAmount;
final JournalEntry[] liabililityAccountThirdTransactionEntry = { final JournalEntry[] liabililityAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(chargeAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.DEBIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] assetAccountThirdTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, final JournalEntry[] assetAccountThirdTransactionEntry = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] incomeAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.CREDIT) }; final JournalEntry[] incomeAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountThirdTransactionEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountThirdTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
@@ -464,8 +465,8 @@ public class AccountingScenarioIntegrationTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, RecurringDepositTest.WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, RecurringDepositTest.WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -529,13 +530,14 @@ public class AccountingScenarioIntegrationTest {
LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper return this.fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec,
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); this.responseSpec);
} }
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) { private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) {
LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec,
this.responseSpec);
final String recurringDepositProductJSON = recurringDepositProductHelper // final String recurringDepositProductJSON = recurringDepositProductHelper //
.withPeriodRangeChart()// .withPeriodRangeChart()//
.withAccountingRuleAsCashBased(accounts).build(validFrom, validTo); .withAccountingRuleAsCashBased(accounts).build(validFrom, validTo);
@@ -715,8 +717,8 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountEntry = { new JournalEntry(15000f, JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountEntry = { new JournalEntry(15000f, JournalEntry.TransactionType.DEBIT),
new JournalEntry(11000f, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(11000f, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1],
JournalEntry.TransactionType.CREDIT)); new JournalEntry(4000f, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment Done......"); LOG.info("Repayment Done......");
} }
@@ -738,8 +740,8 @@ public class AccountingScenarioIntegrationTest {
final float PENALTY_PORTION = 100.0f; final float PENALTY_PORTION = 100.0f;
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false)); ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true)); .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -766,10 +768,8 @@ public class AccountingScenarioIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
todayDate.add(Calendar.DATE, 1); todayDate.add(Calendar.DATE, 1);
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION))); String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION)));
@@ -833,11 +833,11 @@ public class AccountingScenarioIntegrationTest {
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false)); ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true)); .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
Integer flatNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( Integer flatNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_FEE_PORTION), false)); .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_FEE_PORTION), false));
Integer flatSpecifiedDueDateNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper Integer flatSpecifiedDueDateNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_PENALTY_PORTION), true)); .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_PENALTY_PORTION), true));
@@ -866,29 +866,20 @@ public class AccountingScenarioIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
todayDate.add(Calendar.DATE, 1); todayDate.add(Calendar.DATE, 1);
String runOndate = dateFormat.format(todayDate.getTime()); String runOndate = dateFormat.format(todayDate.getTime());
this.loanTransactionHelper this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper
.addChargesForLoan( .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), runOndate, String.valueOf(FEE_PORTION)));
loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), runOndate,
String.valueOf(FEE_PORTION)));
todayDate.add(Calendar.DATE, 1); todayDate.add(Calendar.DATE, 1);
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatSpecifiedDueDateNext), dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_PENALTY_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDateNext),
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_PENALTY_PORTION)));
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatNext), dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatNext),
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
LOG.info("Entries ......"); LOG.info("Entries ......");
@@ -986,8 +977,8 @@ public class AccountingScenarioIntegrationTest {
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
LOG.info("CHECKING INCOME: ******************************************"); LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1], new JournalEntry(FIRST_INTEREST, this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1],
JournalEntry.TransactionType.CREDIT)); new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment 1 Done......"); LOG.info("Repayment 1 Done......");
// REPAYMENT 2 // REPAYMENT 2
@@ -1001,8 +992,8 @@ public class AccountingScenarioIntegrationTest {
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), }; new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
LOG.info("CHECKING INCOME: ******************************************"); LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2], new JournalEntry( this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2],
SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT)); new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment 2 Done ......"); LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST // WAIVE INTEREST
@@ -33,9 +33,8 @@ public class ActuatorIntegrationTest {
@Test @Test
public void testActuatorGitBuildInfo() { public void testActuatorGitBuildInfo() {
Response response = RestAssured.given() Response response = RestAssured.given().headers("Content-Type", ContentType.JSON, "Accept", ContentType.JSON).when().get(INFO_URL)
.headers("Content-Type", ContentType.JSON, "Accept", ContentType.JSON).when() .then().contentType(ContentType.JSON).extract().response();
.get(INFO_URL).then().contentType(ContentType.JSON).extract().response();
Map<String, String> gitBuildInfo = response.jsonPath().getMap("git"); Map<String, String> gitBuildInfo = response.jsonPath().getMap("git");
@@ -58,7 +58,8 @@ public class BatchApiTest {
/** /**
* Sets up the essential settings for the TEST like contentType, * Sets up the essential settings for the TEST like contentType,
* expectedStatusCode. It uses the '@BeforeEach' annotation provided by jUnit. * expectedStatusCode. It uses the '@BeforeEach' annotation provided by
* jUnit.
*/ */
@BeforeEach @BeforeEach
public void setup() { public void setup() {
@@ -333,10 +334,10 @@ public class BatchApiTest {
} }
/** /**
* Tests that batch repayment for loans is happening properly. * Tests that batch repayment for loans is happening properly. Collected
* Collected properly 200(OK) status was returned for successful responses. * properly 200(OK) status was returned for successful responses. It first
* It first creates a new loan and then makes two repayments for it * creates a new loan and then makes two repayments for it and then verifies
* and then verifies that 200(OK) is returned for the repayment requests. * that 200(OK) is returned for the repayment requests.
* *
* @see org.apache.fineract.batch.command.internal.RepayLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.RepayLoanCommandStrategy
*/ */
@@ -482,8 +483,9 @@ public class BatchApiTest {
} }
/** /**
* Test for the successful create client, apply loan,approval and disbursal of a loan using * Test for the successful create client, apply loan,approval and disbursal
* Batch API with enclosingTransaction. A '200' status code is expected on successful activation. * of a loan using Batch API with enclosingTransaction. A '200' status code
* is expected on successful activation.
* *
* @see org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy
* @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy
@@ -58,7 +58,8 @@ public class BatchRequestsIntegrationTest {
/** /**
* Sets up the essential settings for the TEST like contentType, * Sets up the essential settings for the TEST like contentType,
* expectedStatusCode. It uses the '@BeforeEach' annotation provided by jUnit. * expectedStatusCode. It uses the '@BeforeEach' annotation provided by
* jUnit.
*/ */
@BeforeEach @BeforeEach
public void setup() { public void setup() {
@@ -42,6 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class CenterIntegrationTest { public class CenterIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(CenterIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(CenterIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -106,8 +107,8 @@ public class CenterIntegrationTest {
Assertions.assertNotNull(paginatedList); Assertions.assertNotNull(paginatedList);
Assertions.assertNotNull(list); Assertions.assertNotNull(list);
Assertions.assertTrue(Arrays.equals(paginatedList.toArray(new CenterDomain[paginatedList.size()]), Assertions.assertTrue(
list.toArray(new CenterDomain[list.size()]))); Arrays.equals(paginatedList.toArray(new CenterDomain[paginatedList.size()]), list.toArray(new CenterDomain[list.size()])));
} }
@Test @Test
@@ -190,8 +191,8 @@ public class CenterIntegrationTest {
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", "04 March 2011"); map.put("activationDate", "04 March 2011");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec, "/fineract-provider/api/v1/groups?" groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec,
+ Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId"); "/fineract-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
} }
return groupMembers; return groupMembers;
} }
@@ -220,9 +221,8 @@ public class CenterIntegrationTest {
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID); CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec,
this.responseSpec, groupID.toString(), groupID.toString(), staffId.longValue());
staffId.longValue());
assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent"); assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent");
final CenterDomain center = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec); final CenterDomain center = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
@@ -241,18 +241,16 @@ public class CenterIntegrationTest {
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID); CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec,
this.responseSpec, groupID.toString(), groupID.toString(), staffId.longValue());
staffId.longValue());
assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent"); assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent");
final CenterDomain centerWithStaffAssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec); final CenterDomain centerWithStaffAssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
Assertions.assertNotNull(centerWithStaffAssigned); Assertions.assertNotNull(centerWithStaffAssigned);
Assertions.assertTrue(centerWithStaffAssigned.getId().intValue() == groupID); Assertions.assertTrue(centerWithStaffAssigned.getId().intValue() == groupID);
Assertions.assertTrue(centerWithStaffAssigned.getStaffId().intValue() == staffId); Assertions.assertTrue(centerWithStaffAssigned.getStaffId().intValue() == staffId);
final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec, final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec, this.responseSpec,
this.responseSpec, groupID.toString(), groupID.toString(), staffId.longValue());
staffId.longValue());
assertEquals(unassignStaffToCenterResponseMap.get("staffId"), null, "Verify staffId is null after unassigning "); assertEquals(unassignStaffToCenterResponseMap.get("staffId"), null, "Verify staffId is null after unassigning ");
final CenterDomain centerWithStaffUnssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec); final CenterDomain centerWithStaffUnssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
Assertions.assertNotNull(centerWithStaffUnssigned); Assertions.assertNotNull(centerWithStaffUnssigned);
@@ -63,6 +63,7 @@ import org.slf4j.LoggerFactory;
*/ */
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public class ClientSavingsIntegrationTest { public class ClientSavingsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ClientSavingsIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(ClientSavingsIntegrationTest.class);
public static final String DEPOSIT_AMOUNT = "2000"; public static final String DEPOSIT_AMOUNT = "2000";
public static final String WITHDRAW_AMOUNT = "1000"; public static final String WITHDRAW_AMOUNT = "1000";
@@ -203,8 +204,8 @@ public class ClientSavingsIntegrationTest {
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false"; String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField( ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE); .closeSavingsAccountAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -559,8 +560,8 @@ public class ClientSavingsIntegrationTest {
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(annualSavingsChargeId, ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(annualSavingsChargeId,
savingsId, CommonConstants.RESPONSE_ERROR); savingsId, CommonConstants.RESPONSE_ERROR);
assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due", savingsAccountErrorData assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due",
.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.DATE_FORMAT, Locale.US); SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.DATE_FORMAT, Locale.US);
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
@@ -604,8 +605,8 @@ public class ClientSavingsIntegrationTest {
savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(monthlySavingsCharge, savingsId, savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(monthlySavingsCharge, savingsId,
CommonConstants.RESPONSE_ERROR); CommonConstants.RESPONSE_ERROR);
assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due", savingsAccountErrorData assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due",
.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId); this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id")); HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
@@ -630,8 +631,8 @@ public class ClientSavingsIntegrationTest {
savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(weeklySavingsFeeId, savingsId, savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(weeklySavingsFeeId, savingsId,
CommonConstants.RESPONSE_ERROR); CommonConstants.RESPONSE_ERROR);
assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due", savingsAccountErrorData assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due",
.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
cal = Calendar.getInstance(); cal = Calendar.getInstance();
dates = (List) savingsChargeForPay.get("dueDate"); dates = (List) savingsChargeForPay.get("dueDate");
@@ -793,8 +794,8 @@ public class ClientSavingsIntegrationTest {
todaysDate = Calendar.getInstance(); todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false"; String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField( ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE); .closeSavingsAccountAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
@@ -802,14 +803,12 @@ public class ClientSavingsIntegrationTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountPostInterestOnLastDayWithOverdraft() { public void testSavingsAccountPostInterestOnLastDayWithOverdraft() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.responseSpec);
/*** /***
* Create a client to apply for savings account (overdraft account). * Create a client to apply for savings account (overdraft account).
*/ */
final Integer clientID = ClientHelper.createClient(this.requestSpec, final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
this.responseSpec);
Assertions.assertNotNull(clientID); Assertions.assertNotNull(clientID);
final String minBalanceForInterestCalculation = null; final String minBalanceForInterestCalculation = null;
@@ -821,33 +820,27 @@ public class ClientSavingsIntegrationTest {
final String minRequiredBalance = null; final String minRequiredBalance = null;
final String enforceMinRequiredBalance = "false"; final String enforceMinRequiredBalance = "false";
final boolean allowOverdraft = true; final boolean allowOverdraft = true;
final Integer savingsProductID = createSavingsProduct(this.requestSpec, final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, zeroOpeningBalance,
this.responseSpec, zeroOpeningBalance, minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
minBalanceForInterestCalculation, minRequiredBalance,
enforceMinRequiredBalance, allowOverdraft);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
/*** /***
* Apply for Savings account * Apply for Savings account
*/ */
final Integer savingsId = this.savingsAccountHelper final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
.applyForSavingsApplication(clientID, savingsProductID,
ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount( HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
clientID, savingsProductID, savingsId, ACCOUNT_TYPE_INDIVIDUAL); ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertTrue(modifications.containsKey("submittedOnDate")); Assertions.assertTrue(modifications.containsKey("submittedOnDate"));
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings( HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
this.requestSpec, this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
/*** /***
* Approve the savings account * Approve the savings account
*/ */
savingsStatusHashMap = this.savingsAccountHelper savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
@@ -862,26 +855,23 @@ public class ClientSavingsIntegrationTest {
* @param activationDate * @param activationDate
* this value is every time first day of previous month * this value is every time first day of previous month
*/ */
savingsStatusHashMap = activateSavingsAccount(savingsId, savingsStatusHashMap = activateSavingsAccount(savingsId, ACTIVATION_DATE);
ACTIVATION_DATE);
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
/*** /***
* Verify the account summary * Verify the account summary
*/ */
final HashMap summaryBefore = this.savingsAccountHelper final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
.getSavingsSummary(savingsId);
this.savingsAccountHelper.calculateInterestForSavings(savingsId); this.savingsAccountHelper.calculateInterestForSavings(savingsId);
HashMap summary = this.savingsAccountHelper HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
.getSavingsSummary(savingsId);
assertEquals(summaryBefore, summary); assertEquals(summaryBefore, summary);
final Integer lastDayOfMonth = todaysDate final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH);
.getActualMaximum(Calendar.DAY_OF_MONTH);
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth); todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime()); final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime());
Float balance = Float.valueOf(zeroOpeningBalance); Float balance = Float.valueOf(zeroOpeningBalance);
//DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM yyyy",Locale.US); // DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM
// yyyy",Locale.US);
Calendar transactionDate = Calendar.getInstance(); Calendar transactionDate = Calendar.getInstance();
transactionDate.set(Calendar.DAY_OF_MONTH, 2); transactionDate.set(Calendar.DAY_OF_MONTH, 2);
String TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); String TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
@@ -893,16 +883,12 @@ public class ClientSavingsIntegrationTest {
* @param transactionDate * @param transactionDate
* this value is every time last day of previous month * this value is every time last day of previous month
*/ */
Integer depositTransactionId = (Integer) this.savingsAccountHelper Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
WITHDRAWAL_DATE, CommonConstants.RESPONSE_RESOURCE_ID); WITHDRAWAL_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
HashMap depositTransaction = this.savingsAccountHelper HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
.getSavingsTransaction(savingsId, depositTransactionId);
balance += Float.valueOf(DEPOSIT_AMOUNT); balance += Float.valueOf(DEPOSIT_AMOUNT);
assertEquals(Float.valueOf(DEPOSIT_AMOUNT), depositTransaction.get("amount"), assertEquals(Float.valueOf(DEPOSIT_AMOUNT), depositTransaction.get("amount"), "Verifying Deposit Amount");
"Verifying Deposit Amount"); assertEquals(balance, depositTransaction.get("runningBalance"), "Verifying Balance after Deposit");
assertEquals(balance, depositTransaction.get("runningBalance"),
"Verifying Balance after Deposit");
/*** /***
* Calculate expected interest to be posted, interest should be posted * Calculate expected interest to be posted, interest should be posted
@@ -910,18 +896,13 @@ public class ClientSavingsIntegrationTest {
* month before this account balance is negative. * month before this account balance is negative.
*/ */
this.savingsAccountHelper.postInterestForSavings(savingsId); this.savingsAccountHelper.postInterestForSavings(savingsId);
HashMap accountDetails = this.savingsAccountHelper HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
.getSavingsDetails(savingsId);
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
Float accountDetailsPostInterestPosted = Float.valueOf(summary.get( Float accountDetailsPostInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
Float nominalAnnualInterest = Float.valueOf(accountDetails.get( Float nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); HashMap interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
HashMap interestCalculationDaysInYearType = (HashMap) accountDetails Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
double interestRateInFraction = nominalAnnualInterest / 100; double interestRateInFraction = nominalAnnualInterest / 100;
double perDay = (double) 1 / daysInYear; double perDay = (double) 1 / daysInYear;
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
@@ -931,29 +912,20 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
DecimalFormat decimalFormat = new DecimalFormat("", DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
new DecimalFormatSymbols(Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); HashMap accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
HashMap accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
Float accountDetailsPostInterest = Float.valueOf(summary.get( Float accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -963,33 +935,24 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3); transactionDate.set(Calendar.DAY_OF_MONTH, 3);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -999,36 +962,28 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked-------"); LOG.info("-----Post Interest As on Successfully Worked-------");
//DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); // DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy",
// Locale.US);
Calendar transactionCalendarDateFormat = Calendar.getInstance(); Calendar transactionCalendarDateFormat = Calendar.getInstance();
transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0); transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0);
transactionDate.set(Calendar.DAY_OF_MONTH, 22); transactionDate.set(Calendar.DAY_OF_MONTH, 22);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
if (Calendar.DAY_OF_MONTH >= 22) { if (Calendar.DAY_OF_MONTH >= 22) {
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
"id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1038,40 +993,28 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
DateFormat lastTransactionDateFormat = new SimpleDateFormat( DateFormat lastTransactionDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
"dd MMMM yyyy", Locale.US);
Calendar postedLastDate = Calendar.getInstance(); Calendar postedLastDate = Calendar.getInstance();
int numberOfDateOfMonth = postedLastDate int numberOfDateOfMonth = postedLastDate.getActualMaximum(Calendar.DAY_OF_MONTH);
.getActualMaximum(Calendar.DAY_OF_MONTH); TRANSACTION_DATE = lastTransactionDateFormat.format(transactionDate.getTime());
TRANSACTION_DATE = lastTransactionDateFormat.format(transactionDate
.getTime());
if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) { if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) {
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
"id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1081,33 +1024,24 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
transactionDate.set(Calendar.DAY_OF_MONTH, 1); transactionDate.set(Calendar.DAY_OF_MONTH, 1);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1117,14 +1051,11 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
@@ -1132,14 +1063,12 @@ public class ClientSavingsIntegrationTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountPostInterestOnLastDayWithdrawalWithOverdraft() { public void testSavingsAccountPostInterestOnLastDayWithdrawalWithOverdraft() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.responseSpec);
/*** /***
* Create a client to apply for savings account (overdraft account). * Create a client to apply for savings account (overdraft account).
*/ */
final Integer clientID = ClientHelper.createClient(this.requestSpec, final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
this.responseSpec);
Assertions.assertNotNull(clientID); Assertions.assertNotNull(clientID);
final String minBalanceForInterestCalculation = null; final String minBalanceForInterestCalculation = null;
@@ -1151,33 +1080,27 @@ public class ClientSavingsIntegrationTest {
final String minRequiredBalance = null; final String minRequiredBalance = null;
final String enforceMinRequiredBalance = "false"; final String enforceMinRequiredBalance = "false";
final boolean allowOverdraft = true; final boolean allowOverdraft = true;
final Integer savingsProductID = createSavingsProduct(this.requestSpec, final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, zeroOpeningBalance,
this.responseSpec, zeroOpeningBalance, minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
minBalanceForInterestCalculation, minRequiredBalance,
enforceMinRequiredBalance, allowOverdraft);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
/*** /***
* Apply for Savings account * Apply for Savings account
*/ */
final Integer savingsId = this.savingsAccountHelper final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
.applyForSavingsApplication(clientID, savingsProductID,
ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount( HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
clientID, savingsProductID, savingsId, ACCOUNT_TYPE_INDIVIDUAL); ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertTrue(modifications.containsKey("submittedOnDate")); Assertions.assertTrue(modifications.containsKey("submittedOnDate"));
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings( HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
this.requestSpec, this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
/*** /***
* Approve the savings account * Approve the savings account
*/ */
savingsStatusHashMap = this.savingsAccountHelper savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
@@ -1192,26 +1115,23 @@ public class ClientSavingsIntegrationTest {
* @param activationDate * @param activationDate
* this value is every time first day of previous month * this value is every time first day of previous month
*/ */
savingsStatusHashMap = activateSavingsAccount(savingsId, savingsStatusHashMap = activateSavingsAccount(savingsId, ACTIVATION_DATE);
ACTIVATION_DATE);
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
/*** /***
* Verify the account summary * Verify the account summary
*/ */
final HashMap summaryBefore = this.savingsAccountHelper final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
.getSavingsSummary(savingsId);
this.savingsAccountHelper.calculateInterestForSavings(savingsId); this.savingsAccountHelper.calculateInterestForSavings(savingsId);
HashMap summary = this.savingsAccountHelper HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
.getSavingsSummary(savingsId);
assertEquals(summaryBefore, summary); assertEquals(summaryBefore, summary);
final Integer lastDayOfMonth = todaysDate final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH);
.getActualMaximum(Calendar.DAY_OF_MONTH);
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth); todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime()); final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime());
Float balance = Float.valueOf(zeroOpeningBalance); Float balance = Float.valueOf(zeroOpeningBalance);
//DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); // DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM
// yyyy", Locale.US);
Calendar transactionDate = Calendar.getInstance(); Calendar transactionDate = Calendar.getInstance();
transactionDate.set(Calendar.DAY_OF_MONTH, 2); transactionDate.set(Calendar.DAY_OF_MONTH, 2);
String TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); String TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
@@ -1248,18 +1168,13 @@ public class ClientSavingsIntegrationTest {
* month before this account balance is negative. * month before this account balance is negative.
*/ */
this.savingsAccountHelper.postInterestForSavings(savingsId); this.savingsAccountHelper.postInterestForSavings(savingsId);
HashMap accountDetails = this.savingsAccountHelper HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
.getSavingsDetails(savingsId);
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
Float accountDetailsPostInterestPosted = Float.valueOf(summary.get( Float accountDetailsPostInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
Float nominalAnnualInterest = Float.valueOf(accountDetails.get( Float nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); HashMap interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
HashMap interestCalculationDaysInYearType = (HashMap) accountDetails Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
double interestRateInFraction = nominalAnnualInterest / 100; double interestRateInFraction = nominalAnnualInterest / 100;
double perDay = (double) 1 / daysInYear; double perDay = (double) 1 / daysInYear;
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
@@ -1269,29 +1184,20 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
DecimalFormat decimalFormat = new DecimalFormat("", DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
new DecimalFormatSymbols(Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); HashMap accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
HashMap accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
Float accountDetailsPostInterest = Float.valueOf(summary.get( Float accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1301,33 +1207,24 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3); transactionDate.set(Calendar.DAY_OF_MONTH, 3);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1337,36 +1234,28 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked-------"); LOG.info("-----Post Interest As on Successfully Worked-------");
//DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); // DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy",
// Locale.US);
Calendar transactionCalendarDateFormat = Calendar.getInstance(); Calendar transactionCalendarDateFormat = Calendar.getInstance();
transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0); transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0);
transactionDate.set(Calendar.DAY_OF_MONTH, 22); transactionDate.set(Calendar.DAY_OF_MONTH, 22);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
if (Calendar.DAY_OF_MONTH >= 22) { if (Calendar.DAY_OF_MONTH >= 22) {
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
"id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1376,40 +1265,28 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
DateFormat lastTransactionDateFormat = new SimpleDateFormat( DateFormat lastTransactionDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
"dd MMMM yyyy", Locale.US);
Calendar postedLastDate = Calendar.getInstance(); Calendar postedLastDate = Calendar.getInstance();
int numberOfDateOfMonth = postedLastDate int numberOfDateOfMonth = postedLastDate.getActualMaximum(Calendar.DAY_OF_MONTH);
.getActualMaximum(Calendar.DAY_OF_MONTH); TRANSACTION_DATE = lastTransactionDateFormat.format(transactionDate.getTime());
TRANSACTION_DATE = lastTransactionDateFormat.format(transactionDate
.getTime());
if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) { if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) {
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
"id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1419,33 +1296,24 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted, accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
transactionDate.set(Calendar.DAY_OF_MONTH, 1); transactionDate.set(Calendar.DAY_OF_MONTH, 1);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, this.savingsAccountHelper.postInterestAsOnSavings(savingsId, TRANSACTION_DATE);
TRANSACTION_DATE); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
accountTransactionDetails = this.savingsAccountHelper
.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
accountDetailsPostInterest = Float.valueOf(summary.get( accountDetailsPostInterest = Float.valueOf(summary.get("totalInterestPosted").toString());
"totalInterestPosted").toString());
nominalAnnualInterest = Float.valueOf(accountDetails.get( nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
"nominalAnnualInterestRate").toString()); interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
interestCalculationDaysInYearType = (HashMap) accountDetails daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
.get("interestCalculationDaysInYearType");
daysInYear = Integer.valueOf(interestCalculationDaysInYearType
.get("id").toString());
interestRateInFraction = nominalAnnualInterest / 100; interestRateInFraction = nominalAnnualInterest / 100;
perDay = (double) 1 / daysInYear; perDay = (double) 1 / daysInYear;
interestPerDay = interestRateInFraction * perDay; interestPerDay = interestRateInFraction * perDay;
@@ -1455,14 +1323,11 @@ public class ClientSavingsIntegrationTest {
* Apply rounding on interestPosted, actualInterestPosted and verify * Apply rounding on interestPosted, actualInterestPosted and verify
* both are same * both are same
*/ */
decimalFormat = new DecimalFormat("", new DecimalFormatSymbols( decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
accountDetailsPostInterestPosted = Float.valueOf( accountDetailsPostInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
assertEquals(interestPosted,accountDetailsPostInterestPosted,
"Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
@@ -1608,7 +1473,8 @@ public class ClientSavingsIntegrationTest {
DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US)); DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
//actualInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted)); // actualInterestPosted =
// Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("------Post Interest As On After doing a post interest Successfully worked--------"); LOG.info("------Post Interest As On After doing a post interest Successfully worked--------");
@@ -1623,7 +1489,6 @@ public class ClientSavingsIntegrationTest {
final String TODYS_POSTING_DATE = dateFormat.format(todysDate.getTime()); final String TODYS_POSTING_DATE = dateFormat.format(todysDate.getTime());
String withdrawBalance = "true"; String withdrawBalance = "true";
if (TODYS_POSTING_DATE.equalsIgnoreCase(INTEREST_POSTING_DATE)) { if (TODYS_POSTING_DATE.equalsIgnoreCase(INTEREST_POSTING_DATE)) {
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, responseSpec); final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, responseSpec);
validationErrorHelper.closeSavingsAccountPostInterestAndGetBackRequiredField(savingsId, withdrawBalance, validationErrorHelper.closeSavingsAccountPostInterestAndGetBackRequiredField(savingsId, withdrawBalance,
@@ -1641,8 +1506,10 @@ public class ClientSavingsIntegrationTest {
@Test @Test
public void testPostInterestAsOnSavingsAccountWithOverdraft() { public void testPostInterestAsOnSavingsAccountWithOverdraft() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
//final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build(); // final ResponseSpecification errorResponse = new
//final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse); // ResponseSpecBuilder().expectStatusCode(400).build();
// final SavingsAccountHelper validationErrorHelper = new
// SavingsAccountHelper(this.requestSpec, errorResponse);
/*** /***
* Create a client to apply for savings account (overdraft account). * Create a client to apply for savings account (overdraft account).
@@ -1754,7 +1621,6 @@ public class ClientSavingsIntegrationTest {
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
Float actualInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString()); Float actualInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
/*** /***
* Calculate expected interest to be posted, interest should be posted * Calculate expected interest to be posted, interest should be posted
* for one day only because deposit transaction happened on last day of * for one day only because deposit transaction happened on last day of
@@ -1801,8 +1667,6 @@ public class ClientSavingsIntegrationTest {
} }
@Test @Test
public void testSavingsAccount_WITH_WITHHOLD_TAX() { public void testSavingsAccount_WITH_WITHHOLD_TAX() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -1816,7 +1680,8 @@ public class ClientSavingsIntegrationTest {
final String percentage = "10"; final String percentage = "10";
final Integer taxGroupId = createTaxGroup(percentage); final Integer taxGroupId = createTaxGroup(percentage);
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId), false); minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId),
false);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL); final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
@@ -1864,7 +1729,8 @@ public class ClientSavingsIntegrationTest {
final String percentage = "10"; final String percentage = "10";
final Integer taxGroupId = createTaxGroup(percentage); final Integer taxGroupId = createTaxGroup(percentage);
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId), false); minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId),
false);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL); final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
@@ -1914,7 +1780,8 @@ public class ClientSavingsIntegrationTest {
final String percentage = "10"; final String percentage = "10";
final Integer taxGroupId = createTaxGroup(percentage); final Integer taxGroupId = createTaxGroup(percentage);
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId), true); minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId),
true);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, final Integer savingsChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
@@ -1924,7 +1791,8 @@ public class ClientSavingsIntegrationTest {
ArrayList<Integer> savingsList = new ArrayList<>(); ArrayList<Integer> savingsList = new ArrayList<>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL); final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId, HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
@@ -1979,7 +1847,6 @@ public class ClientSavingsIntegrationTest {
balance -= chargeAmt; balance -= chargeAmt;
assertEquals(balance, summary.get("accountBalance"), "Verifying account Balance"); assertEquals(balance, summary.get("accountBalance"), "Verifying account Balance");
// VERIFY INACTIVE // VERIFY INACTIVE
savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(1)); savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(1));
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
@@ -2040,10 +1907,8 @@ public class ClientSavingsIntegrationTest {
savingsStatusHashMap = SavingsStatusChecker.getSubStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(5)); savingsStatusHashMap = SavingsStatusChecker.getSubStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(5));
SavingsStatusChecker.verifySavingsSubStatusNone(savingsStatusHashMap); SavingsStatusChecker.verifySavingsSubStatusNone(savingsStatusHashMap);
} }
private HashMap activateSavingsAccount(final Integer savingsId, final String activationDate) { private HashMap activateSavingsAccount(final Integer savingsId, final String activationDate) {
final HashMap status = this.savingsAccountHelper.activateSavingsAccount(savingsId, activationDate); final HashMap status = this.savingsAccountHelper.activateSavingsAccount(savingsId, activationDate);
return status; return status;
@@ -2087,11 +1952,11 @@ public class ClientSavingsIntegrationTest {
private Integer createTaxGroup(final String percentage) { private Integer createTaxGroup(final String percentage) {
final Integer liabilityAccountId = null; final Integer liabilityAccountId = null;
final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId); final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage,
liabilityAccountId);
return TaxGroupHelper.createTaxGroup(this.requestSpec, this.responseSpec, Arrays.asList(taxComponentId)); return TaxGroupHelper.createTaxGroup(this.requestSpec, this.responseSpec, Arrays.asList(taxComponentId));
} }
/* /*
* private void verifySavingsInterest(final Object savingsInterest) { * private void verifySavingsInterest(final Object savingsInterest) {
* LOG.info( * LOG.info(
@@ -2218,14 +2083,16 @@ public class ClientSavingsIntegrationTest {
} }
/** /**
* incorrect savings account balance when charge transaction is * incorrect savings account balance when charge transaction is reversed
* reversed during an overdraft recalculate Daily Balances * during an overdraft recalculate Daily Balances
*/ */
@Test @Test
public void testAccountBalanceAfterTransactionReversal() { public void testAccountBalanceAfterTransactionReversal() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
//SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,new ResponseSpecBuilder().build()); // SavingsAccountHelper savingsAccountHelperValidationError = new
// SavingsAccountHelper(this.requestSpec,new
// ResponseSpecBuilder().build());
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientID); Assertions.assertNotNull(clientID);
@@ -2239,22 +2106,18 @@ public class ClientSavingsIntegrationTest {
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft); minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL); final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsId); Assertions.assertNotNull(savingsId);
HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "500", Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "500",
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID); SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
String chargeAmount = "300"; String chargeAmount = "300";
String chargeCurrency = "USD"; String chargeCurrency = "USD";
@@ -2265,14 +2128,13 @@ public class ClientSavingsIntegrationTest {
Integer amount = 300; Integer amount = 300;
final Integer chargeId = this.savingsAccountHelper.addChargesForSavingsWithDueDate(savingsId, savingsChargeId,
final Integer chargeId = this.savingsAccountHelper.addChargesForSavingsWithDueDate(savingsId, savingsChargeId, SavingsAccountHelper.TRANSACTION_DATE, SavingsAccountHelper.TRANSACTION_DATE, amount);
amount);
Assertions.assertNotNull(chargeId); Assertions.assertNotNull(chargeId);
final Integer payChargeId = this.savingsAccountHelper.payCharge(chargeId, savingsId, chargeAmount, SavingsAccountHelper.TRANSACTION_DATE); final Integer payChargeId = this.savingsAccountHelper.payCharge(chargeId, savingsId, chargeAmount,
SavingsAccountHelper.TRANSACTION_DATE);
final Integer undoSavingsTransaction = this.savingsAccountHelper.undoSavingsAccountTransaction(savingsId, depositTransactionId); final Integer undoSavingsTransaction = this.savingsAccountHelper.undoSavingsAccountTransaction(savingsId, depositTransactionId);
HashMap reversedDepositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId); HashMap reversedDepositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
@@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClientStatusChecker { public class ClientStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(ClientStatusChecker.class); private final static Logger LOG = LoggerFactory.getLogger(ClientStatusChecker.class);
public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) {
@@ -32,36 +33,31 @@ public class ClientStatusChecker {
} }
public static void verifyClientClosed(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientClosed(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
assertEquals(600, (int) clientStatusHashMap.get("id")); assertEquals(600, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientPending(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientPending(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
assertEquals(100, (int) clientStatusHashMap.get("id")); assertEquals(100, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientRejected(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientRejected(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
assertEquals(700, (int) clientStatusHashMap.get("id")); assertEquals(700, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientActiavted(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientActiavted(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
assertEquals(300, (int) clientStatusHashMap.get("id")); assertEquals(300, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientWithdrawn(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientWithdrawn(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
assertEquals(800, (int) clientStatusHashMap.get("id")); assertEquals(800, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
@@ -53,8 +53,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
@@ -69,8 +68,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -93,8 +91,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -122,8 +119,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
@@ -152,8 +148,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -182,8 +177,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -207,8 +201,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -236,8 +229,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
@@ -265,8 +257,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -297,16 +288,14 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec); final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
status = this.clientHelper.withdrawClient(clientId); status = this.clientHelper.withdrawClient(clientId);
ClientStatusChecker.verifyClientWithdrawn(status); ClientStatusChecker.verifyClientWithdrawn(status);
status = this.clientHelper.undoWithdrawn(clientId); status = this.clientHelper.undoWithdrawn(clientId);
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.activateClient(clientId, ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.activateClient(clientId, CommonConstants.RESPONSE_ERROR);
CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.clients.submittedOnDate.after.reopened.date", assertEquals("error.msg.clients.submittedOnDate.after.reopened.date",
clientErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); clientErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -315,15 +304,15 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
@Test @Test
public void testReopenedDate() { public void testReopenedDate() {
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build(); final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
//final ClientHelper validationErrorHelper = new ClientHelper(this.requestSpec, errorResponse); // final ClientHelper validationErrorHelper = new
// ClientHelper(this.requestSpec, errorResponse);
// CREATE CLIENT // CREATE CLIENT
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec); final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
status = this.clientHelper.withdrawClient(clientId); status = this.clientHelper.withdrawClient(clientId);
@@ -41,6 +41,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ConcurrencyIntegrationTest { public class ConcurrencyIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ConcurrencyIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(ConcurrencyIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -153,11 +154,12 @@ public class ConcurrencyIntegrationTest {
this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId); this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId);
} catch (Exception e) { } catch (Exception e) {
LOG.info("Found an exception {}", e.getMessage()); LOG.info("Found an exception {}", e.getMessage());
LOG.info("Details of failed concurrent transaction (date, amount, loanId) are {},{},{}" , repaymentDate, repaymentAmount , loanId); LOG.info("Details of failed concurrent transaction (date, amount, loanId) are {},{},{}", repaymentDate, repaymentAmount,
loanId);
throw (e); throw (e);
} }
LOG.info("Details of passed concurrent transaction, details (date, amount, loanId) are {},{},{}" , repaymentDate LOG.info("Details of passed concurrent transaction, details (date, amount, loanId) are {},{},{}", repaymentDate,
, repaymentAmount , loanId); repaymentAmount, loanId);
} }
} }
@@ -73,7 +73,6 @@ public class CurrenciesTest {
currenciestoUpdate.add("USD"); currenciestoUpdate.add("USD");
currenciestoUpdate.add("INR"); currenciestoUpdate.add("INR");
ArrayList<String> currenciesOutput = CurrenciesHelper.updateSelectedCurrencies(this.requestSpec, this.responseSpec, ArrayList<String> currenciesOutput = CurrenciesHelper.updateSelectedCurrencies(this.requestSpec, this.responseSpec,
currenciestoUpdate); currenciestoUpdate);
Assertions.assertNotNull(currenciesOutput); Assertions.assertNotNull(currenciesOutput);
@@ -33,7 +33,6 @@ public class CurrencyIntegrationTest {
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private SavingsAccountHelper savingsAccountHelper; private SavingsAccountHelper savingsAccountHelper;
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -78,7 +78,8 @@ public class DisbursalAndRepaymentScheduleTest {
@Test @Test
public void testRescheduleJLGLoanSynk() { public void testRescheduleJLGLoanSynk() {
// system.out.println("---------------------------------STARTING RESCHEDULE JLG // system.out.println("---------------------------------STARTING
// RESCHEDULE JLG
// LOAN TEST ------------------------------------------"); // LOAN TEST ------------------------------------------");
Calendar meetingCalendar = Calendar.getInstance(); Calendar meetingCalendar = Calendar.getInstance();
@@ -107,8 +108,7 @@ public class DisbursalAndRepaymentScheduleTest {
final String loanType = "jlg"; final String loanType = "jlg";
final String rescheduleInterestRate = "28.0"; final String rescheduleInterestRate = "28.0";
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
final String groupMeetingNewStartDate = this.dateFormatterStandard final String groupMeetingNewStartDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
.format(groupMeetingChangeCalendar.getTime());
// The date // The date
// from // from
// which we // which we
@@ -122,35 +122,32 @@ public class DisbursalAndRepaymentScheduleTest {
final String rescheduleDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime()); final String rescheduleDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default"); this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build(); this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
// system.out.println("---------------------------------CREATING ENTITIES AND // system.out.println("---------------------------------CREATING
// ENTITIES AND
// JLG LOAN ------------------------------------------"); // JLG LOAN ------------------------------------------");
// create all required entities // create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24")
.withLoanTermFrequency("24").withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12") .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2")
.withRepaymentEveryAfter("2").withRepaymentFrequencyTypeAsMonths() .withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
.withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate)
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks() .withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin()
.withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate) .withCalendarID(this.groupCalendarId.toString())
.withLoanType(loanType).withSyncDisbursementWithMeetin() .build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null);
.withCalendarID(this.groupCalendarId.toString()).build(this.clientId.toString(),
this.groupId.toString(), this.loanProductId.toString(), null);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
// Test for loan account is created // Test for loan account is created
Assertions.assertNotNull(this.loanId); Assertions.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
this.loanId);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -164,10 +161,11 @@ public class DisbursalAndRepaymentScheduleTest {
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// system.out.println("---------------------------------CHANGING GROUP MEETING // system.out.println("---------------------------------CHANGING GROUP
// MEETING
// DATE ------------------------------------------"); // DATE ------------------------------------------");
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(),
this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New groupMeetingNewStartDate, "2", "2", "2"); // New
// meeting // meeting
// dates // dates
// will be // will be
@@ -177,74 +175,73 @@ public class DisbursalAndRepaymentScheduleTest {
// coming // coming
// monday // monday
ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec,
generalResponseSpec, this.loanId); this.loanId);
ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
Calendar dueDateCalendar = Calendar.getInstance(); Calendar dueDateCalendar = Calendar.getInstance();
dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY); dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY);
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2)); (Integer) dueDateLoanSchedule.get(2));
assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY");
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY");
// system.out.println("---------------------------------CREATING LOAN RESCHEDULE // system.out.println("---------------------------------CREATING LOAN
// RESCHEDULE
// REQUEST------------------------------------------"); // REQUEST------------------------------------------");
String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2") String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2").updateGraceOnPrincipal("2")
.updateGraceOnPrincipal("2").updateNewInterestRate(rescheduleInterestRate) .updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate)
.updateRescheduleFromDate(rescheduleDate).updateSubmittedOnDate(rescheduleSubmittedDate) .updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString());
.build(this.loanId.toString());
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId); this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
generalResponseSpec, this.loanId);
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2)); (Integer) dueDateLoanSchedule.get(2));
assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT"); "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT");
// system.out.println("Successfully created loan reschedule request (ID: " + // system.out.println("Successfully created loan reschedule request (ID:
// " +
// this.loanRescheduleRequestId + ")"); // this.loanRescheduleRequestId + ")");
// system.out.println("-----------------------------APPROVING LOAN RESCHEDULE // system.out.println("-----------------------------APPROVING LOAN
// RESCHEDULE
// REQUEST--------------------------"); // REQUEST--------------------------");
requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate) requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate)
.getApproveLoanRescheduleRequestJSON(); .getApproveLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean) response.get("approved")); assertTrue((Boolean) response.get("approved"));
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
generalResponseSpec, this.loanId);
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2)); (Integer) dueDateLoanSchedule.get(2));
assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE"); "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE");
// system.out.println("Successfully changed group meeting date (CAELNDAR ID: " + // system.out.println("Successfully changed group meeting date (CAELNDAR
// ID: " +
// this.groupCalendarId // this.groupCalendarId
// + ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId + // + ") and rescheduled loan (RESCHEDULE ID: " +
// this.loanRescheduleRequestId +
// ")"); // ")");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
this.responseSpecForStatusCode403);
} }
@Test @Test
public void testChangeGroupMeetingMaturedOnDate() { public void testChangeGroupMeetingMaturedOnDate() {
// system.out // system.out
// .println("---------------------------------STARTING GROUP LOAN MEETING CHANGE // .println("---------------------------------STARTING GROUP LOAN
// DATE EXPECTED MATURED CHANGE------------------------------------------"); // MEETING CHANGE
// DATE EXPECTED MATURED
// CHANGE------------------------------------------");
Calendar meetingCalendar = Calendar.getInstance(); Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
@@ -269,8 +266,7 @@ public class DisbursalAndRepaymentScheduleTest {
final String loanType = "jlg"; final String loanType = "jlg";
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
final String groupMeetingNewStartDate = this.dateFormatterStandard final String groupMeetingNewStartDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
.format(groupMeetingChangeCalendar.getTime());
// The date // The date
// from // from
// which we // which we
@@ -282,35 +278,32 @@ public class DisbursalAndRepaymentScheduleTest {
// tuesday. // tuesday.
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default"); this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build(); this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
// system.out.println("---------------------------------CREATING ENTITIES AND // system.out.println("---------------------------------CREATING
// ENTITIES AND
// JLG LOAN ------------------------------------------"); // JLG LOAN ------------------------------------------");
// create all required entities // create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24")
.withLoanTermFrequency("24").withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12") .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2")
.withRepaymentEveryAfter("2").withRepaymentFrequencyTypeAsMonths() .withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
.withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate)
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks() .withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin()
.withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate) .withCalendarID(this.groupCalendarId.toString())
.withLoanType(loanType).withSyncDisbursementWithMeetin() .build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null);
.withCalendarID(this.groupCalendarId.toString()).build(this.clientId.toString(),
this.groupId.toString(), this.loanProductId.toString(), null);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
// Test for loan account is created // Test for loan account is created
Assertions.assertNotNull(this.loanId); Assertions.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
this.loanId);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -324,10 +317,11 @@ public class DisbursalAndRepaymentScheduleTest {
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// system.out.println("---------------------------------CHANGING GROUP MEETING // system.out.println("---------------------------------CHANGING GROUP
// MEETING
// DATE ------------------------------------------"); // DATE ------------------------------------------");
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(),
this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New groupMeetingNewStartDate, "2", "2", "2"); // New
// meeting // meeting
// dates // dates
// will be // will be
@@ -339,18 +333,16 @@ public class DisbursalAndRepaymentScheduleTest {
Calendar expectedMaturityCalendar = Calendar.getInstance(); Calendar expectedMaturityCalendar = Calendar.getInstance();
expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY); expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY);
ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec,
.getLoanDetail(requestSpec, generalResponseSpec, this.loanId, "timeline")) this.loanId, "timeline")).get("expectedMaturityDate"));
.get("expectedMaturityDate"));
expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), (Integer) expectedMaturityDate.get(1) - 1,
(Integer) expectedMaturityDate.get(1) - 1, (Integer) expectedMaturityDate.get(2)); (Integer) expectedMaturityDate.get(2));
assertEquals(3, expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK), assertEquals(3, expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY"); "AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
this.responseSpecForStatusCode403);
} }
/** /**
@@ -373,20 +365,19 @@ public class DisbursalAndRepaymentScheduleTest {
*/ */
private void associateClientToGroup(final Integer groupId, final Integer clientId) { private void associateClientToGroup(final Integer groupId, final Integer clientId) {
GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString());
clientId.toString());
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId); GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId);
} }
private void createGroupEntityWithCalendar(final String frequency, final String interval, private void createGroupEntityWithCalendar(final String frequency, final String interval, final String repeatsOnDay,
final String repeatsOnDay, final String groupActivationDate) { final String groupActivationDate) {
this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate); this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate);
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId); GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId);
final String startDate = groupActivationDate; final String startDate = groupActivationDate;
this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, startDate,
this.responseSpec, this.groupId, startDate, frequency, interval, repeatsOnDay)); frequency, interval, repeatsOnDay));
} }
/** /**
@@ -402,9 +393,8 @@ public class DisbursalAndRepaymentScheduleTest {
**/ **/
private void createLoanProductEntity() { private void createLoanProductEntity() {
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount) final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments) .withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withinterestRatePerPeriod(interestRatePerPeriod).withInterestRateFrequencyTypeAsYear() .withInterestRateFrequencyTypeAsYear().build(null);
.build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
} }
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
public class ExternalServicesConfigurationTest { public class ExternalServicesConfigurationTest {
private final static Logger LOG = LoggerFactory.getLogger(ExternalServicesConfigurationTest.class); private final static Logger LOG = LoggerFactory.getLogger(ExternalServicesConfigurationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -86,7 +86,8 @@ public class FinancialActivityAccountsTest {
* Fetch Created Financial Activity to Account Mapping and validate * Fetch Created Financial Activity to Account Mapping and validate
* created values * created values
**/ **/
assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityTransferAccount); assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID,
liabilityTransferAccount);
/** /**
* Update Existing Financial Activity to Account Mapping and assert * Update Existing Financial Activity to Account Mapping and assert
@@ -129,8 +130,8 @@ public class FinancialActivityAccountsTest {
invalidFinancialActivityAccountError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); invalidFinancialActivityAccountError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
/** Should be able to delete a Financial Activity to Account Mapping **/ /** Should be able to delete a Financial Activity to Account Mapping **/
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = financialActivityAccountHelper
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
@@ -138,7 +139,8 @@ public class FinancialActivityAccountsTest {
financialActivityAccountHelper.getFinancialActivityAccount(deletedFinancialActivityAccountId, responseSpecForResourceNotFoundError); financialActivityAccountHelper.getFinancialActivityAccount(deletedFinancialActivityAccountId, responseSpecForResourceNotFoundError);
} }
private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId, Account glAccount) { private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId,
Account glAccount) {
HashMap mappingDetails = financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId, responseSpec); HashMap mappingDetails = financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId, responseSpec);
Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id")); Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
Assertions.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id")); Assertions.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id"));
@@ -152,8 +154,8 @@ public class FinancialActivityAccountsTest {
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec); List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
for (HashMap financialActivity : financialActivities) { for (HashMap financialActivity : financialActivities) {
Integer financialActivityAccountId = (Integer) financialActivity.get("id"); Integer financialActivityAccountId = (Integer) financialActivity.get("id");
Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper
financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
} }
@@ -65,6 +65,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" }) @SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" })
public class FixedDepositTest { public class FixedDepositTest {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositTest.class); private final static Logger LOG = LoggerFactory.getLogger(FixedDepositTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -100,9 +101,12 @@ public class FixedDepositTest {
public static final Integer BIANNULLY_INTERVAL = 6; public static final Integer BIANNULLY_INTERVAL = 6;
public static final Integer ANNUL_INTERVAL = 12; public static final Integer ANNUL_INTERVAL = 12;
// TODO Given the difference in calculation methods in test vs application, the exact values // TODO Given the difference in calculation methods in test vs application,
// returned may differ enough to cause differences in rounding. Given this, we only compare the full // the exact values
// digits. A proper solution would be to implement the exact interest calculation in this test, // returned may differ enough to cause differences in rounding. Given this,
// we only compare the full
// digits. A proper solution would be to implement the exact interest
// calculation in this test,
// and then to compare the exact results // and then to compare the exact results
@BeforeEach @BeforeEach
@@ -173,8 +177,8 @@ public class FixedDepositTest {
/*** /***
* Apply for FD account with created product and verify status * Apply for FD account with created product and verify status
*/ */
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -229,8 +233,7 @@ public class FixedDepositTest {
this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry); this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit( Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -240,21 +243,19 @@ public class FixedDepositTest {
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsPrematureClosed(fixedDepositAccountStatusHashMap); FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsPrematureClosed(fixedDepositAccountStatusHashMap);
/*** /***
* Verify journal entry transactions for preclosure transaction * Verify journal entry transactions for preclosure transaction
*/ */
HashMap accountDetails = this.fixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, HashMap accountDetails = this.fixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Float maturityAmount = Float.valueOf(accountDetails.get("maturityAmount").toString()); Float maturityAmount = Float.valueOf(accountDetails.get("maturityAmount").toString());
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.DEBIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT));
} }
@Test @Test
public void testFixedDepositAccountWithPrematureClosureTypeWithdrawal_WITH_HOLD_TAX() { public void testFixedDepositAccountWithPrematureClosureTypeWithdrawal_WITH_HOLD_TAX() {
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
@@ -367,8 +368,7 @@ public class FixedDepositTest {
this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry); this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit( Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -389,16 +389,15 @@ public class FixedDepositTest {
Assertions.assertNotNull(summary.get("totalWithholdTax")); Assertions.assertNotNull(summary.get("totalWithholdTax"));
Float withHoldTax = (Float) summary.get("totalWithholdTax"); Float withHoldTax = (Float) summary.get("totalWithholdTax");
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.DEBIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(withHoldTax, JournalEntry.TransactionType.CREDIT));
} }
@Test @Test
public void testFixedDepositAccountClosureTypeWithdrawal_WITH_HOLD_TAX() throws InterruptedException { public void testFixedDepositAccountClosureTypeWithdrawal_WITH_HOLD_TAX() throws InterruptedException {
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
@@ -518,9 +517,8 @@ public class FixedDepositTest {
HashMap summary = (HashMap) accountDetails.get("summary"); HashMap summary = (HashMap) accountDetails.get("summary");
Assertions.assertNotNull(summary.get("totalWithholdTax")); Assertions.assertNotNull(summary.get("totalWithholdTax"));
Float withHoldTax = (Float) summary.get("totalWithholdTax"); Float withHoldTax = (Float) summary.get("totalWithholdTax");
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(withHoldTax, JournalEntry.TransactionType.CREDIT));
fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -528,7 +526,6 @@ public class FixedDepositTest {
} }
@Test @Test
public void testFixedDepositAccountWithPeriodInterestRateChart() { public void testFixedDepositAccountWithPeriodInterestRateChart() {
final String chartToUse = "period"; final String chartToUse = "period";
@@ -663,8 +660,8 @@ public class FixedDepositTest {
/*** /***
* Apply for FD account with created product and verify status * Apply for FD account with created product and verify status
*/ */
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM, depositAmount, depositPeriod); SUBMITTED_ON_DATE, WHOLE_TERM, depositAmount, depositPeriod);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -761,8 +758,8 @@ public class FixedDepositTest {
incomeAccount, expenseAccount); incomeAccount, expenseAccount);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -819,8 +816,7 @@ public class FixedDepositTest {
*/ */
Account financialAccount = getMappedLiabilityFinancialAccount(); Account financialAccount = getMappedLiabilityFinancialAccount();
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
/*** /***
* Preclose the account and verify journal entries * Preclose the account and verify journal entries
@@ -842,11 +838,13 @@ public class FixedDepositTest {
* transaction is an account transfer you should get financial account * transaction is an account transfer you should get financial account
* mapping details and verify amounts * mapping details and verify amounts
*/ */
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(prematurityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT), new JournalEntry(prematurityAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(prematurityAmount, JournalEntry.TransactionType.CREDIT),
new JournalEntry(prematurityAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForAssetAccount(financialAccount, CLOSED_ON_DATE, new JournalEntry(prematurityAmount, this.journalEntryHelper.checkJournalEntryForAssetAccount(financialAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.DEBIT), new JournalEntry(prematurityAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(prematurityAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(prematurityAmount, JournalEntry.TransactionType.CREDIT));
HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance"); Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance");
@@ -913,8 +911,8 @@ public class FixedDepositTest {
incomeAccount, expenseAccount); incomeAccount, expenseAccount);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -957,8 +955,7 @@ public class FixedDepositTest {
this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry); this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
ArrayList<HashMap> errorResponse = (ArrayList<HashMap>) fixedDepositAccountHelperValidationError.prematureCloseForFixedDeposit( ArrayList<HashMap> errorResponse = (ArrayList<HashMap>) fixedDepositAccountHelperValidationError.prematureCloseForFixedDeposit(
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_REINVEST, null, CommonConstants.RESPONSE_ERROR); fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_REINVEST, null, CommonConstants.RESPONSE_ERROR);
@@ -994,13 +991,12 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
this.fixedDepositProductHelper.retrieveAllFixedDepositProducts(this.requestSpec, this.fixedDepositProductHelper.retrieveAllFixedDepositProducts(this.requestSpec, this.responseSpec);
this.responseSpec); this.fixedDepositProductHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
this.fixedDepositProductHelper.retrieveFixedDepositProductById(this.requestSpec, fixedDepositProductId.toString());
this.responseSpec, fixedDepositProductId.toString());
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
todaysDate.add(Calendar.DATE, -1); todaysDate.add(Calendar.DATE, -1);
@@ -1038,8 +1034,8 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -1081,8 +1077,8 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -1122,8 +1118,8 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -1161,8 +1157,8 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -1204,8 +1200,8 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -1222,8 +1218,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
double perDay = (double) 1 / daysInYear; double perDay = (double) 1 / daysInYear;
@@ -1272,13 +1268,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -1294,8 +1290,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
double perDay = (double) 1 / daysInYear; double perDay = (double) 1 / daysInYear;
@@ -1348,8 +1344,8 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -1369,8 +1365,8 @@ public class FixedDepositTest {
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
@@ -1394,8 +1390,7 @@ public class FixedDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit( Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -1450,13 +1445,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -1475,8 +1470,8 @@ public class FixedDepositTest {
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
@@ -1500,8 +1495,7 @@ public class FixedDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit( Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -1556,8 +1550,8 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
TILL_PREMATURE_WITHDRAWAL); SUBMITTED_ON_DATE, TILL_PREMATURE_WITHDRAWAL);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -1576,8 +1570,8 @@ public class FixedDepositTest {
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Calendar activationDate = Calendar.getInstance(); Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1); activationDate.add(Calendar.MONTH, -1);
@@ -1611,8 +1605,7 @@ public class FixedDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit( Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -1667,13 +1660,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
TILL_PREMATURE_WITHDRAWAL); SUBMITTED_ON_DATE, TILL_PREMATURE_WITHDRAWAL);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, TILL_PREMATURE_WITHDRAWAL,
TILL_PREMATURE_WITHDRAWAL, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -1691,8 +1684,8 @@ public class FixedDepositTest {
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) fixedDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Calendar activationDate = Calendar.getInstance(); Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1); activationDate.add(Calendar.MONTH, -1);
@@ -1726,8 +1719,7 @@ public class FixedDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE);
CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit( Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -1778,13 +1770,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -1800,8 +1792,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -1853,13 +1845,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -1875,8 +1867,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -1933,13 +1925,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -1957,8 +1949,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2016,13 +2008,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -2040,8 +2032,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2100,13 +2092,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -2121,8 +2113,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2181,13 +2173,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -2202,8 +2194,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2262,13 +2254,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -2283,8 +2275,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2342,13 +2334,13 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM); SUBMITTED_ON_DATE, WHOLE_TERM);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), fixedDepositProductId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, fixedDepositAccountId.toString(), SUBMITTED_ON_DATE, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM,
WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY); INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -2363,8 +2355,8 @@ public class FixedDepositTest {
Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) fixedDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) fixedDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.fixedDepositProductHelper
this.requestSpec, this.responseSpec, fixedDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, fixedDepositProductId);
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2385,8 +2377,8 @@ public class FixedDepositTest {
} }
/*** /***
* Test case for Fixed Deposit Account rollover with maturity * Test case for Fixed Deposit Account rollover with maturity instruction as
* instruction as re invest maturity amount(principal+interest) * re invest maturity amount(principal+interest)
*/ */
@Test @Test
public void testFixedDepositAccountWithRolloverMaturityAmount() { public void testFixedDepositAccountWithRolloverMaturityAmount() {
@@ -2437,14 +2429,14 @@ public class FixedDepositTest {
/*** /***
* Set maturityInstructionId as re-invest principal+interest * Set maturityInstructionId as re-invest principal+interest
* */ */
final Integer maturityInstructionId = 300; final Integer maturityInstructionId = 300;
/*** /***
* Apply for FD account with created product and verify status * Apply for FD account with created product and verify status
*/ */
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM, maturityInstructionId); SUBMITTED_ON_DATE, WHOLE_TERM, maturityInstructionId);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
@@ -2465,10 +2457,9 @@ public class FixedDepositTest {
FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap); FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap);
} }
/*** /***
* Test case for Fixed Deposit Account rollover with maturity * Test case for Fixed Deposit Account rollover with maturity instruction as
* instruction as re invest principal only * re invest principal only
*/ */
@Test @Test
public void testFixedDepositAccountWithRolloverPrincipal() { public void testFixedDepositAccountWithRolloverPrincipal() {
@@ -2519,14 +2510,14 @@ public class FixedDepositTest {
/*** /***
* Set maturityInstructionId as re-invest principal * Set maturityInstructionId as re-invest principal
* */ */
final Integer maturityInstructionId = 400; final Integer maturityInstructionId = 400;
/*** /***
* Apply for FD account with created product and verify status * Apply for FD account with created product and verify status
*/ */
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(),
WHOLE_TERM, maturityInstructionId); SUBMITTED_ON_DATE, WHOLE_TERM, maturityInstructionId);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
@@ -2561,7 +2552,6 @@ public class FixedDepositTest {
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec); return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
} }
private Integer createFixedDepositProductWithWithHoldTax(final String validFrom, final String validTo, final String taxGroupId, private Integer createFixedDepositProductWithWithHoldTax(final String validFrom, final String validTo, final String taxGroupId,
final String accountingRule, Account... accounts) { final String accountingRule, Account... accounts) {
LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
@@ -2613,19 +2603,18 @@ public class FixedDepositTest {
LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper return this.fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec,
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); this.responseSpec);
} }
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate, private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate,
final String penalInterestType, final Integer maturityInstructionId) { final String penalInterestType, final Integer maturityInstructionId) {
LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) .withSubmittedOnDate(submittedOnDate).withMaturityInstructionId(maturityInstructionId)
.withMaturityInstructionId(maturityInstructionId)
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper return this.fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec,
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); this.responseSpec);
} }
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate, private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate,
@@ -2635,8 +2624,8 @@ public class FixedDepositTest {
// //
.withSubmittedOnDate(submittedOnDate).withDepositPeriod(depositPeriod).withDepositAmount(depositAmount) .withSubmittedOnDate(submittedOnDate).withDepositPeriod(depositPeriod).withDepositAmount(depositAmount)
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper return this.fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec,
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); this.responseSpec);
} }
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@@ -2701,11 +2690,13 @@ public class FixedDepositTest {
LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityAccountForMapping.getAccountID(), this.responseSpec, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityAccountForMapping.getAccountID(), this.responseSpec,
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(financialActivityAccountId); Assertions.assertNotNull(financialActivityAccountId);
assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityAccountForMapping); assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID,
liabilityAccountForMapping);
return liabilityAccountForMapping; return liabilityAccountForMapping;
} }
private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId, Account glAccount) { private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId,
Account glAccount) {
HashMap mappingDetails = this.financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId, HashMap mappingDetails = this.financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId,
this.responseSpec); this.responseSpec);
Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id")); Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
@@ -2714,7 +2705,8 @@ public class FixedDepositTest {
private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax) { private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax) {
final Integer liabilityAccountId = liabilityAccountForTax.getAccountID(); final Integer liabilityAccountId = liabilityAccountForTax.getAccountID();
final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId); final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage,
liabilityAccountId);
return TaxGroupHelper.createTaxGroup(this.requestSpec, this.responseSpec, Arrays.asList(taxComponentId)); return TaxGroupHelper.createTaxGroup(this.requestSpec, this.responseSpec, Arrays.asList(taxComponentId));
} }
@@ -2726,8 +2718,8 @@ public class FixedDepositTest {
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec); List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
for (HashMap financialActivity : financialActivities) { for (HashMap financialActivity : financialActivities) {
Integer financialActivityAccountId = (Integer) financialActivity.get("id"); Integer financialActivityAccountId = (Integer) financialActivity.get("id");
Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper
financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
} }
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unused", "unchecked" }) @SuppressWarnings({ "rawtypes", "unused", "unchecked" })
public class FlexibleSavingsInterestPostingIntegrationTest { public class FlexibleSavingsInterestPostingIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class);
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
@@ -74,8 +75,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
final Integer savingsId = createSavingsAccount(clientID, startDate); final Integer savingsId = createSavingsAccount(clientID, startDate);
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate, this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate, CommonConstants.RESPONSE_RESOURCE_ID);
CommonConstants.RESPONSE_RESOURCE_ID);
/*** /***
* Perform Post interest transaction and verify the posted transaction * Perform Post interest transaction and verify the posted transaction
@@ -85,8 +85,9 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions"); ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2); HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
for (Entry<String, Object> entry : interestPostingTransaction.entrySet()) for (Entry<String, Object> entry : interestPostingTransaction.entrySet()) {
{LOG.info("{} - {}",entry.getKey(), entry.getValue().toString());} LOG.info("{} - {}", entry.getKey(), entry.getValue().toString());
}
// 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily // 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily
// balance // balance
// 33.7016 obtained from formula in excel provided by Subramanya // 33.7016 obtained from formula in excel provided by Subramanya
@@ -123,16 +124,16 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled"); Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
if (!enabled.equals(periodEndEnable)) { if (!enabled.equals(periodEndEnable)) {
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
this.responseSpec, periodEndConfigId.toString(), periodEndEnable); periodEndConfigId.toString(), periodEndEnable);
} }
// Updating value for financial year beginning month // Updating value for financial year beginning month
Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id"); Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
Assertions.assertNotNull(financialYearBeginningConfigId); Assertions.assertNotNull(financialYearBeginningConfigId);
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
this.responseSpec, financialYearBeginningConfigId.toString()); financialYearBeginningConfigId.toString());
Assertions.assertNotNull(financialYearBeginningConfigData); Assertions.assertNotNull(financialYearBeginningConfigData);
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
@@ -57,10 +57,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFund() { public void testCreateFund() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -69,10 +66,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithEmptyName() { public void testCreateFundWithEmptyName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(null).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(null)
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -82,10 +76,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithEmptyExternalId() { public void testCreateFundWithEmptyExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(null).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(null)
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -94,19 +85,13 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithDuplicateName() { public void testCreateFundWithDuplicateName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
Assertions.assertNotNull(fundID); Assertions.assertNotNull(fundID);
FundsHelper fh2 = FundsHelper FundsHelper fh2 = FundsHelper.create(fh.getName()).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(fh.getName())
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
jsonData = fh2.toJSON(); jsonData = fh2.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
@@ -116,19 +101,13 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithDuplicateExternalId() { public void testCreateFundWithDuplicateExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
Assertions.assertNotNull(fundID); Assertions.assertNotNull(fundID);
FundsHelper fh2 = FundsHelper FundsHelper fh2 = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(fh.getExternalId()).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(fh.getExternalId())
.build();
jsonData = fh2.toJSON(); jsonData = fh2.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
@@ -138,10 +117,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithInvalidName() { public void testCreateFundWithInvalidName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 120)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 120))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -151,10 +127,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithInvalidExternalId() { public void testCreateFundWithInvalidExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 120)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 120))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -164,10 +137,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testRetrieveFund() { public void testRetrieveFund() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -181,10 +151,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testRetrieveAllFunds() { public void testRetrieveAllFunds() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -207,10 +174,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testUpdateFund() { public void testUpdateFund() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -229,17 +193,13 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 10); String newName = Utils.randomNameGenerator("", 10);
String newExternalId = Utils.randomNameGenerator("fund-", 5); String newExternalId = Utils.randomNameGenerator("fund-", 5);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec, FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec, responseSpec);
responseSpec);
Assertions.assertNull(fh); Assertions.assertNull(fh);
} }
@Test @Test
public void testUpdateFundWithInvalidNewName() { public void testUpdateFundWithInvalidNewName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -248,18 +208,14 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 120); String newName = Utils.randomNameGenerator("", 120);
String newExternalId = Utils.randomNameGenerator("fund-", 5); String newExternalId = Utils.randomNameGenerator("fund-", 5);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, responseSpec);
responseSpec);
Assertions.assertNull(fh2); Assertions.assertNull(fh2);
} }
@Test @Test
public void testUpdateFundWithNewExternalId() { public void testUpdateFundWithNewExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -273,10 +229,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testUpdateFundWithInvalidNewExternalId() { public void testUpdateFundWithInvalidNewExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -285,18 +238,14 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 10); String newName = Utils.randomNameGenerator("", 10);
String newExternalId = Utils.randomNameGenerator("fund-", 120); String newExternalId = Utils.randomNameGenerator("fund-", 120);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, responseSpec);
responseSpec);
Assertions.assertNull(fh2); Assertions.assertNull(fh2);
} }
@Test @Test
public void testUpdateFundWithNewName() { public void testUpdateFundWithNewName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -310,10 +259,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testUpdateFundWithEmptyParams() { public void testUpdateFundWithEmptyParams() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -333,9 +279,7 @@ public class FundsIntegrationTest {
Assertions.assertEquals(fh.getExternalId(), fh3.getExternalId()); Assertions.assertEquals(fh.getExternalId(), fh3.getExternalId());
} }
private Long createFund(final String fundJSON, private Long createFund(final String fundJSON, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
String fundId = String.valueOf(FundsResourceHandler.createFund(fundJSON, requestSpec, responseSpec)); String fundId = String.valueOf(FundsResourceHandler.createFund(fundJSON, requestSpec, responseSpec));
if (fundId.equals("null")) { if (fundId.equals("null")) {
// Invalid JSON data parameters // Invalid JSON data parameters
@@ -32,7 +32,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest { public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -59,21 +58,18 @@ public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); this.responseSpec);
Assertions.assertNotNull(globalConfig); Assertions.assertNotNull(globalConfig);
String configName = "interest-charged-from-date-same-as-disbursal-date"; String configName = "interest-charged-from-date-same-as-disbursal-date";
boolean newBooleanValue = true; boolean newBooleanValue = true;
for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) {
if (globalConfig.get(configIndex).get("name") if (globalConfig.get(configIndex).get("name").equals(configName)) {
.equals(configName)) { String configId = globalConfig.get(configIndex).get("id").toString();
String configId = globalConfig.get(configIndex).get("id") Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
.toString(); this.responseSpec, configId.toString(), newBooleanValue);
Integer updateConfigId = this.globalConfigurationHelper
.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
configId.toString(), newBooleanValue);
Assertions.assertNotNull(updateConfigId); Assertions.assertNotNull(updateConfigId);
break; break;
} }
@@ -137,8 +137,8 @@ public class GlobalConfigurationTest {
cacheTypeId -= 1; cacheTypeId -= 1;
} }
HashMap changes = this.globalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec, HashMap changes = this.globalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec, this.responseSpec,
this.responseSpec, cacheTypeId.toString()); cacheTypeId.toString());
Assertions.assertEquals(cacheTypeId, changes.get("cacheType"), "Verifying Is Cache Enabled Global Config after Updation"); Assertions.assertEquals(cacheTypeId, changes.get("cacheType"), "Verifying Is Cache Enabled Global Config after Updation");
} }
} }
@@ -147,8 +147,8 @@ public class GlobalConfigurationTest {
public void testGlobalConfigForcePasswordResetDays() { public void testGlobalConfigForcePasswordResetDays() {
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); this.responseSpec);
Assertions.assertNotNull(globalConfig); Assertions.assertNotNull(globalConfig);
String configName = "force-password-reset-days"; String configName = "force-password-reset-days";
@@ -157,23 +157,18 @@ public class GlobalConfigurationTest {
for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) {
if (globalConfig.get(configIndex).get("name").equals(configName)) { if (globalConfig.get(configIndex).get("name").equals(configName)) {
Integer configId = (Integer) globalConfig.get(configIndex).get( Integer configId = (Integer) globalConfig.get(configIndex).get("id");
"id");
Assertions.assertNotNull(configId); Assertions.assertNotNull(configId);
/* /*
* Update force-password-reset-days with value as 0 and Enable * Update force-password-reset-days with value as 0 and Enable
* as true - failure case * as true - failure case
*/ */
ArrayList error = (ArrayList) this.globalConfigurationHelper ArrayList error = (ArrayList) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(this.requestSpec,
.updatePasswordResetDaysForGlobalConfiguration( this.httpStatusForidden, configId, newValue, newBooleanValue, CommonConstants.RESPONSE_ERROR);
this.requestSpec, this.httpStatusForidden,
configId, newValue, newBooleanValue,
CommonConstants.RESPONSE_ERROR);
HashMap hash = (HashMap) error.get(0); HashMap hash = (HashMap) error.get(0);
Assertions.assertEquals( Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero",
"error.msg.password.reset.days.value.must.be.greater.than.zero",
hash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), hash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"Force Password Reset days value must be greater than zero."); "Force Password Reset days value must be greater than zero.");
@@ -181,27 +176,23 @@ public class GlobalConfigurationTest {
* Update force-password-reset-days with value as 50 and Enable * Update force-password-reset-days with value as 50 and Enable
* as true - success case * as true - success case
*/ */
final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
.updatePasswordResetDaysForGlobalConfiguration( this.requestSpec, this.responseSpec, configId, "50", newBooleanValue, "changes");
this.requestSpec, this.responseSpec, configId,
"50", newBooleanValue, "changes");
Assertions.assertNotNull(updateSuccess); Assertions.assertNotNull(updateSuccess);
/* Update with value as 0 and Enable as false - success case */ /* Update with value as 0 and Enable as false - success case */
final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
.updatePasswordResetDaysForGlobalConfiguration( this.requestSpec, this.responseSpec, configId, newValue, "false", "changes");
this.requestSpec, this.responseSpec, configId,
newValue, "false", "changes");
Assertions.assertNotNull(updateSuccess1); Assertions.assertNotNull(updateSuccess1);
/* Update without sending value and Enable as true - failure case*/ /*
ArrayList failure = (ArrayList) this.globalConfigurationHelper * Update without sending value and Enable as true - failure
.updatePasswordResetDaysForGlobalConfiguration( * case
this.requestSpec, this.httpStatusForidden, configId, */
null, newBooleanValue, CommonConstants.RESPONSE_ERROR); ArrayList failure = (ArrayList) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.httpStatusForidden, configId, null, newBooleanValue, CommonConstants.RESPONSE_ERROR);
HashMap failureHash = (HashMap) failure.get(0); HashMap failureHash = (HashMap) failure.get(0);
Assertions.assertEquals( Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero",
"error.msg.password.reset.days.value.must.be.greater.than.zero",
failureHash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), failureHash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"Force Password Reset days value must be greater than zero."); "Force Password Reset days value must be greater than zero.");
@@ -211,12 +202,9 @@ public class GlobalConfigurationTest {
/* Update other global configuration property */ /* Update other global configuration property */
String otherConfigName = "maker-checker"; String otherConfigName = "maker-checker";
for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) {
if (globalConfig.get(configIndex).get("name") if (globalConfig.get(configIndex).get("name").equals(otherConfigName)) {
.equals(otherConfigName)) { String configId = globalConfig.get(configIndex).get("id").toString();
String configId = globalConfig.get(configIndex).get("id") Integer updateConfigId = this.globalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec,
.toString();
Integer updateConfigId = this.globalConfigurationHelper
.updateValueForGlobalConfiguration(this.requestSpec,
this.responseSpec, configId, newValue); this.responseSpec, configId, newValue);
Assertions.assertNotNull(updateConfigId); Assertions.assertNotNull(updateConfigId);
break; break;
@@ -98,8 +98,8 @@ public class GroupLoanIntegrationTest {
List<Map<String, Object>> approvalFormData = new ArrayList<>(); List<Map<String, Object>> approvalFormData = new ArrayList<>();
approvalFormData.add(approvalFormData(loanId, "22 September 2011")); approvalFormData.add(approvalFormData(loanId, "22 September 2011"));
HashMap loanStatusHashMap = this.loanTransactionHelper.approveGlimAccount(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = this.loanTransactionHelper.approveGlimAccount(this.requestSpec, this.responseSpec, approvalFormData,
approvalFormData, glimId); glimId);
LOG.info("glim approval loanSchedule: {} ", loanStatusHashMap); LOG.info("glim approval loanSchedule: {} ", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
@@ -174,7 +174,8 @@ public class GroupLoanIntegrationTest {
final Integer loanId = glim.get("loanId"); final Integer loanId = glim.get("loanId");
LOG.info("LoanId: {} ", loanId); LOG.info("LoanId: {} ", loanId);
final List<String> retrievedGlimAccountId=GroupHelper.verifyRetrieveGlimAccountsByGlimId(this.requestSpec, this.responseSpec, glimId); final List<String> retrievedGlimAccountId = GroupHelper.verifyRetrieveGlimAccountsByGlimId(this.requestSpec, this.responseSpec,
glimId);
Assertions.assertNotNull(retrievedGlimAccountId); Assertions.assertNotNull(retrievedGlimAccountId);
} }
@@ -236,10 +237,8 @@ public class GroupLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() // .withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() // .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
.withExpectedDisbursementDate("20 September 2011") // .withExpectedDisbursementDate("20 September 2011") //
.withSubmittedOnDate("20 September 2011") .withSubmittedOnDate("20 September 2011").withLoanType("glim").withtotalLoan("10000").withParentAccount("1")
.withLoanType("glim") .build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
.withtotalLoan("10000")
.withParentAccount("1").build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
LOG.info(GlimApplicationJSON); LOG.info(GlimApplicationJSON);
return this.loanTransactionHelper.getGlimId(GlimApplicationJSON); return this.loanTransactionHelper.getGlimId(GlimApplicationJSON);
} }
@@ -249,10 +248,8 @@ public class GroupLoanIntegrationTest {
assertEquals(new ArrayList<>(Arrays.asList(2011, 10, 20)), loanSchedule.get(1).get("dueDate"), assertEquals(new ArrayList<>(Arrays.asList(2011, 10, 20)), loanSchedule.get(1).get("dueDate"),
"Checking for Due Date for 1st Month"); "Checking for Due Date for 1st Month");
assertEquals(Float.valueOf("2911.49"), loanSchedule.get(1).get("principalOriginalDue"), assertEquals(Float.valueOf("2911.49"), loanSchedule.get(1).get("principalOriginalDue"), "Checking for Principal Due for 1st Month");
"Checking for Principal Due for 1st Month"); assertEquals(Float.valueOf("240.00"), loanSchedule.get(1).get("interestOriginalDue"), "Checking for Interest Due for 1st Month");
assertEquals(Float.valueOf("240.00"), loanSchedule.get(1).get("interestOriginalDue"),
"Checking for Interest Due for 1st Month");
assertEquals(new ArrayList<>(Arrays.asList(2011, 11, 20)), loanSchedule.get(2).get("dueDate"), assertEquals(new ArrayList<>(Arrays.asList(2011, 11, 20)), loanSchedule.get(2).get("dueDate"),
"Checking for Due Date for 2nd Month"); "Checking for Due Date for 2nd Month");
@@ -162,8 +162,8 @@ public class GroupSavingsIntegrationTest {
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false"; String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField( ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE); .closeSavingsAccountAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -267,7 +267,8 @@ public class GroupSavingsIntegrationTest {
assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date", assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
error1 = savingsAccountHelperValidationError.rejectGsimApplicationWithErrorCode(gsimID, SavingsAccountHelper.CREATED_DATE_MINUS_ONE); error1 = savingsAccountHelperValidationError.rejectGsimApplicationWithErrorCode(gsimID,
SavingsAccountHelper.CREATED_DATE_MINUS_ONE);
assertEquals("validation.msg.savingsaccount.reject.cannot.be.before.submittal.date", assertEquals("validation.msg.savingsaccount.reject.cannot.be.before.submittal.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -368,7 +369,8 @@ public class GroupSavingsIntegrationTest {
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false"; String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeGsimSavingsAccountAndGetBackRequiredField(gsimID, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE); ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
.closeGsimSavingsAccountAndGetBackRequiredField(gsimID, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -727,7 +729,8 @@ public class GroupSavingsIntegrationTest {
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount); totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived")); assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsWeeklyFeeJSON()); final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getSavingsWeeklyFeeJSON());
Assertions.assertNotNull(weeklyFeeId); Assertions.assertNotNull(weeklyFeeId);
this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId, true); this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId, true);
@@ -777,7 +780,8 @@ public class GroupSavingsIntegrationTest {
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
} }
private Map<String, Object> clientArray(final Integer clientId, final Integer groupId, final Integer productId, final String submittedOnDate) { private Map<String, Object> clientArray(final Integer clientId, final Integer groupId, final Integer productId,
final String submittedOnDate) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("clientId", clientId); map.put("clientId", clientId);
map.put("groupId", groupId); map.put("groupId", groupId);
@@ -790,7 +794,8 @@ public class GroupSavingsIntegrationTest {
return map; return map;
} }
private Map<String, Object> savingsArray(final Integer paymentId, final Integer savingsId, final Integer transactionAmount, final String transactionDate) { private Map<String, Object> savingsArray(final Integer paymentId, final Integer savingsId, final Integer transactionAmount,
final String transactionDate) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("transactionDate", transactionDate); map.put("transactionDate", transactionDate);
map.put("dateFormat", CommonConstants.DATE_FORMAT); map.put("dateFormat", CommonConstants.DATE_FORMAT);
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
* Updating & Deletion * Updating & Deletion
*/ */
public class GroupTest { public class GroupTest {
private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class); private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class HookIntegrationTest { public class HookIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(HookIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(HookIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanApplicationApprovalTest { public class LoanApplicationApprovalTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403; private ResponseSpecification responseSpecForStatusCode403;
@@ -130,14 +131,13 @@ public class LoanApplicationApprovalTest {
createTranches.add(createTrancheDetail("23 March 2014", "4000")); createTranches.add(createTrancheDetail("23 March 2014", "4000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches); this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches); this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
@@ -155,8 +155,7 @@ public class LoanApplicationApprovalTest {
approveTranches.add(createTrancheDetail("23 March 2014", "1000")); approveTranches.add(createTrancheDetail("23 March 2014", "1000"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -201,8 +200,7 @@ public class LoanApplicationApprovalTest {
approveTranche4.add(createTrancheDetail("24 March 2014", "100")); approveTranche4.add(createTrancheDetail("24 March 2014", "100"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -233,8 +231,8 @@ public class LoanApplicationApprovalTest {
/* No. of tranches exceeds the max tranche count at product level */ /* No. of tranches exceeds the max tranche count at product level */
error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount3, loanID, error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount3, loanID,
approveTranche3, CommonConstants.RESPONSE_ERROR); approveTranche3, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.disbursementData.exceeding.max.tranche.count", error.get(0) assertEquals("error.msg.disbursementData.exceeding.max.tranche.count",
.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
/* If tranches are not specified for a multi-disburse loan */ /* If tranches are not specified for a multi-disburse loan */
/** /**
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanApplicationUndoLastTrancheTest { public class LoanApplicationUndoLastTrancheTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -67,15 +68,14 @@ public class LoanApplicationUndoLastTrancheTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT // CREATE LOAN MULTIDISBURSAL PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
// CREATE TRANCHES // CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>(); List<HashMap> createTranches = new ArrayList<>();
@@ -89,8 +89,7 @@ public class LoanApplicationUndoLastTrancheTest {
// APPLY FOR LOAN WITH TRANCHES // APPLY FOR LOAN WITH TRANCHES
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanDisbursalDateValidationTest { public class LoanDisbursalDateValidationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -65,19 +66,17 @@ public class LoanDisbursalDateValidationTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
// CREATE LOAN PRODUCT // CREATE LOAN PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withSyncExpectedWithDisbursementDate(true).build(null)); .getLoanProductId(new LoanProductTestBuilder().withSyncExpectedWithDisbursementDate(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
// APPLY FOR LOAN // APPLY FOR LOAN
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
@@ -92,7 +91,8 @@ public class LoanDisbursalDateValidationTest {
// DISBURSE A LOAN // DISBURSE A LOAN
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID, this.responseForbiddenError); List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID,
this.responseForbiddenError);
Assertions.assertEquals(disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), Assertions.assertEquals(disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"error.msg.actual.disbursement.date.does.not.match.with.expected.disbursal.date"); "error.msg.actual.disbursement.date.does.not.match.with.expected.disbursal.date");
@@ -100,18 +100,11 @@ public class LoanDisbursalDateValidationTest {
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) {
final String loanApplication = new LoanApplicationTestBuilder() final String loanApplication = new LoanApplicationTestBuilder().withPrincipal(proposedAmount).withLoanTermFrequency("5")
.withPrincipal(proposedAmount).withLoanTermFrequency("5") .withLoanTermFrequencyAsMonths().withNumberOfRepayments("5").withRepaymentEveryAfter("1")
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5") .withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("1 March 2014")
.withRepaymentEveryAfter("1") .withSubmittedOnDate("26 February 2014").build(clientID.toString(), loanProductID.toString(), null);
.withRepaymentFrequencyTypeAsMonths()
.withInterestRatePerPeriod("2")
.withExpectedDisbursementDate("1 March 2014")
.withSubmittedOnDate("26 February 2014").
build(clientID.toString(), loanProductID.toString(), null);
return this.loanTransactionHelper.getLoanId(loanApplication); return this.loanTransactionHelper.getLoanId(loanApplication);
} }
} }
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class LoanDisbursementDetailsIntegrationTest { public class LoanDisbursementDetailsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursementDetailsIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursementDetailsIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -75,20 +76,19 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000")); createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------{}" LOG.info("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------{}", clientID);
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true) .withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches, final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
installmentAmount); installmentAmount);
LOG.info("-----------------------------------LOAN CREATED WITH EMI LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH EMI LOANID------------------------------------------------- {}",
, loanIDWithEmi); loanIDWithEmi);
HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec,
loanIDWithEmi, "repaymentSchedule"); loanIDWithEmi, "repaymentSchedule");
@@ -106,7 +106,8 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches); createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------"); LOG.info(
"-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches, final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
withoutInstallmentAmount); withoutInstallmentAmount);
@@ -117,8 +118,8 @@ public class LoanDisbursementDetailsIntegrationTest {
ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods"); ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods");
assertEquals(15, periods1.size()); assertEquals(15, periods1.size());
LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}",
, loanIDWithoutEmi); loanIDWithoutEmi);
/* To be uncommented once issue MIFOSX-2006 is closed. */ /* To be uncommented once issue MIFOSX-2006 is closed. */
// this.validateRepaymentScheduleWithoutEMI(periods1); // this.validateRepaymentScheduleWithoutEMI(periods1);
@@ -131,7 +132,8 @@ public class LoanDisbursementDetailsIntegrationTest {
loanIDWithoutEmi, createTranches); loanIDWithoutEmi, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------"); LOG.info(
"-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
} }
@@ -208,8 +210,8 @@ public class LoanDisbursementDetailsIntegrationTest {
assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate()); assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate());
assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding()); assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding());
LOG.info("{}", period.get("totalOriginalDueForPeriod").toString()); LOG.info("{}", period.get("totalOriginalDueForPeriod").toString());
assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()), expectedRepaymentSchedule assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()),
.getTotalOriginalDueForPeriod().floatValue(), 0.0f); expectedRepaymentSchedule.getTotalOriginalDueForPeriod().floatValue(), 0.0f);
assertEquals(Float.valueOf(period.get("totalOutstandingForPeriod").toString()).floatValue(), assertEquals(Float.valueOf(period.get("totalOutstandingForPeriod").toString()).floatValue(),
expectedRepaymentSchedule.getTotalOutstandingForPeriod(), 0.0f); expectedRepaymentSchedule.getTotalOutstandingForPeriod(), 0.0f);
@@ -220,7 +222,8 @@ public class LoanDisbursementDetailsIntegrationTest {
expectedRepaymentSchedule.getInterestOutstanding(), 0.0f); expectedRepaymentSchedule.getInterestOutstanding(), 0.0f);
assertEquals(Float.valueOf(period.get("principalOutstanding").toString()).floatValue(), assertEquals(Float.valueOf(period.get("principalOutstanding").toString()).floatValue(),
expectedRepaymentSchedule.getPrincipalOutstanding(), 0.0f); expectedRepaymentSchedule.getPrincipalOutstanding(), 0.0f);
assertEquals(Float.valueOf(period.get("principalDue").toString()).floatValue(), expectedRepaymentSchedule.getPrincipalDue(), 0.0f); assertEquals(Float.valueOf(period.get("principalDue").toString()).floatValue(), expectedRepaymentSchedule.getPrincipalDue(),
0.0f);
assertEquals(Float.valueOf(period.get("principalOriginalDue").toString()).floatValue(), assertEquals(Float.valueOf(period.get("principalOriginalDue").toString()).floatValue(),
expectedRepaymentSchedule.getPrincipalOriginalDue(), 0.0f); expectedRepaymentSchedule.getPrincipalOriginalDue(), 0.0f);
assertEquals(period.get("fromDate").toString(), expectedRepaymentSchedule.getFromDate()); assertEquals(period.get("fromDate").toString(), expectedRepaymentSchedule.getFromDate());
@@ -371,18 +374,16 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000")); createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanRepaymentRescheduleAtDisbursementTest { public class LoanRepaymentRescheduleAtDisbursementTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -75,8 +76,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION // CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION
final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY, final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY,
@@ -116,7 +116,8 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
this.loanTransactionHelper.disburseLoanWithRepaymentReschedule(disbursementDate, loanID, adjustRepaymentDate); this.loanTransactionHelper.disburseLoanWithRepaymentReschedule(disbursementDate, loanID, adjustRepaymentDate);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, loanID); ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec,
loanID);
HashMap firstInstallement = loanRepaymnetSchedule.get(1); HashMap firstInstallement = loanRepaymnetSchedule.get(1);
Map<String, Object> expectedvalues = new HashMap<>(3); Map<String, Object> expectedvalues = new HashMap<>(3);
Calendar date = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar date = Calendar.getInstance(Utils.getTimeZoneOfTenant());
@@ -170,17 +171,10 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) { final Integer recalculationRestFrequencyDayOfWeekType) {
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("12")
.withPrincipal("10000.00") .withRepaymentAfterEvery("2").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withNumberOfRepayments("12") .withInterestRateFrequencyTypeAsMonths().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentAfterEvery("2") .withRepaymentStrategy(repaymentStrategy).withInterestTypeAsDecliningBalance()
.withRepaymentTypeAsWeek()
.withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths()
.withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentStrategy(repaymentStrategy)
.withInterestTypeAsDecliningBalance()
.withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod, .withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod,
preCloseInterestCalculationStrategy) preCloseInterestCalculationStrategy)
.withInterestRecalculationRestFrequencyDetails(recalculationRestFrequencyType, recalculationRestFrequencyInterval, .withInterestRecalculationRestFrequencyDetails(recalculationRestFrequencyType, recalculationRestFrequencyInterval,
@@ -221,8 +215,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
.withRepaymentFrequencyTypeAsWeeks() // .withRepaymentFrequencyTypeAsWeeks() //
.withInterestRatePerPeriod("2") // .withInterestRatePerPeriod("2") //
.withAmortizationTypeAsEqualInstallments() // .withAmortizationTypeAsEqualInstallments() //
.withTranches(tranches) .withTranches(tranches).withFixedEmiAmount("") //
.withFixedEmiAmount("") //
.withInterestTypeAsDecliningBalance() // .withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeAsDays() // .withInterestCalculationPeriodTypeAsDays() //
.withInterestCalculationPeriodTypeAsDays() // .withInterestCalculationPeriodTypeAsDays() //
@@ -240,7 +233,6 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
private List getDateAsArray(Calendar date, int addvalue, int type) { private List getDateAsArray(Calendar date, int addvalue, int type) {
date.add(type, addvalue); date.add(type, addvalue);
return new ArrayList<>(Arrays.asList(date.get(Calendar.YEAR), date.get(Calendar.MONTH) + 1, return new ArrayList<>(Arrays.asList(date.get(Calendar.YEAR), date.get(Calendar.MONTH) + 1, date.get(Calendar.DAY_OF_MONTH)));
date.get(Calendar.DAY_OF_MONTH)));
} }
} }
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
**/ **/
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public class LoanRescheduleRequestTest { public class LoanRescheduleRequestTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
@@ -98,12 +99,9 @@ public class LoanRescheduleRequestTest {
private void createLoanProductEntity() { private void createLoanProductEntity() {
LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withPrincipal(loanPrincipalAmount) .withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withNumberOfRepayments(numberOfRepayments) .withInterestRateFrequencyTypeAsYear().build(null);
.withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear()
.build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
LOG.info("Successfully created loan product (ID:{}) ", this.loanProductId); LOG.info("Successfully created loan product (ID:{}) ", this.loanProductId);
@@ -115,21 +113,11 @@ public class LoanRescheduleRequestTest {
private void createLoanEntity() { private void createLoanEntity() {
LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------"); LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
.withPrincipal(loanPrincipalAmount) .withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsMonths().withNumberOfRepayments(numberOfRepayments)
.withLoanTermFrequency(numberOfRepayments) .withRepaymentEveryAfter("1").withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments()
.withLoanTermFrequencyAsMonths() .withInterestCalculationPeriodTypeAsDays().withInterestRatePerPeriod(interestRatePerPeriod).withLoanTermFrequencyAsMonths()
.withNumberOfRepayments(numberOfRepayments) .withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2")
.withRepaymentEveryAfter("1")
.withRepaymentFrequencyTypeAsMonths()
.withAmortizationTypeAsEqualInstallments()
.withInterestCalculationPeriodTypeAsDays()
.withInterestRatePerPeriod(interestRatePerPeriod)
.withLoanTermFrequencyAsMonths()
.withSubmittedOnDate(dateString)
.withExpectedDisbursementDate(dateString)
.withPrincipalGrace("2")
.withInterestGrace("2")
.build(this.clientId.toString(), this.loanProductId.toString(), null); .build(this.clientId.toString(), this.loanProductId.toString(), null);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
@@ -208,7 +196,8 @@ public class LoanRescheduleRequestTest {
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean) response.get("approved")); assertTrue((Boolean) response.get("approved"));
final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId, "numberOfRepayments"); final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId,
"numberOfRepayments");
final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId); final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId);
final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment"); final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment");
@@ -18,7 +18,6 @@
*/ */
package org.apache.fineract.integrationtests; package org.apache.fineract.integrationtests;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.Gson; import com.google.gson.Gson;
@@ -56,6 +55,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class LoanReschedulingWithinCenterTest { public class LoanReschedulingWithinCenterTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -114,8 +114,7 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, null, null);
null, null);
// APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION // APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION
final Integer loanId = applyForLoanApplicationForInterestRecalculation(clientId, groupId, calendarId, loanProductID, disbursalDate, final Integer loanId = applyForLoanApplicationForInterestRecalculation(clientId, groupId, calendarId, loanProductID, disbursalDate,
@@ -229,8 +228,7 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, null, null);
null, null);
Calendar seondTrancheDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar seondTrancheDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
seondTrancheDate.add(Calendar.MONTH, 1); seondTrancheDate.add(Calendar.MONTH, 1);
@@ -290,7 +288,8 @@ public class LoanReschedulingWithinCenterTest {
final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod, final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod,
final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval, final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval,
final String recalculationRestFrequencyDate, final String preCloseInterestCalculationStrategy, final Account[] accounts, final String recalculationRestFrequencyDate, final String preCloseInterestCalculationStrategy, final Account[] accounts,
final boolean isMultiTrancheLoan, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) { final boolean isMultiTrancheLoan, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) {
final String recalculationCompoundingFrequencyType = null; final String recalculationCompoundingFrequencyType = null;
final String recalculationCompoundingFrequencyInterval = null; final String recalculationCompoundingFrequencyInterval = null;
final String recalculationCompoundingFrequencyDate = null; final String recalculationCompoundingFrequencyDate = null;
@@ -300,8 +299,8 @@ public class LoanReschedulingWithinCenterTest {
rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval, rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval,
recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval, recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval,
recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, isMultiTrancheLoan, recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, isMultiTrancheLoan,
recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, recalculationRestFrequencyOnDayType, recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType,
recalculationRestFrequencyDayOfWeekType); recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType);
} }
private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy, private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy,
@@ -311,20 +310,13 @@ public class LoanReschedulingWithinCenterTest {
final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate, final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate,
final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId, final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId,
boolean isArrearsBasedOnOriginalSchedule, final boolean isMultiTrancheLoan, boolean isArrearsBasedOnOriginalSchedule, final boolean isMultiTrancheLoan,
final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) {
final Integer recalculationRestFrequencyDayOfWeekType) {
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("12")
.withPrincipal("10000.00") .withRepaymentAfterEvery("2").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withNumberOfRepayments("12") .withInterestRateFrequencyTypeAsMonths().withTranches(isMultiTrancheLoan)
.withRepaymentAfterEvery("2") .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).withRepaymentStrategy(repaymentStrategy)
.withRepaymentTypeAsWeek()
.withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths()
.withTranches(isMultiTrancheLoan)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentStrategy(repaymentStrategy)
.withInterestTypeAsDecliningBalance() .withInterestTypeAsDecliningBalance()
.withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod, .withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod,
preCloseInterestCalculationStrategy) preCloseInterestCalculationStrategy)
@@ -395,8 +387,8 @@ public class LoanReschedulingWithinCenterTest {
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", "04 March 2011"); map.put("activationDate", "04 March 2011");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec, "/fineract-provider/api/v1/groups?" groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec,
+ Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId"); "/fineract-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
} }
return groupMembers; return groupMembers;
} }
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
*/ */
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public class LoanWithWaiveInterestAndWriteOffIntegrationTest { public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -174,17 +175,21 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
"Checking for Principal paid "); "Checking for Principal paid ");
Assertions.assertTrue(Float.valueOf("180.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestPaid")))) == 0, Assertions.assertTrue(Float.valueOf("180.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestPaid")))) == 0,
"Checking for interestPaid paid "); "Checking for interestPaid paid ");
Assertions.assertTrue(Float.valueOf("680.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalRepayment")))) == 0, Assertions.assertTrue(
Float.valueOf("680.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalRepayment")))) == 0,
"Checking for total paid "); "Checking for total paid ");
// WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED // WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED
LoanStatusChecker.verifyLoanAccountIsClosed(this.loanTransactionHelper.writeOffLoan("1 January 2011", loanID)); LoanStatusChecker.verifyLoanAccountIsClosed(this.loanTransactionHelper.writeOffLoan("1 January 2011", loanID));
toLoanSummaryAfter = this.loanTransactionHelper.getLoanSummary(requestSpec, responseSpec, loanID); toLoanSummaryAfter = this.loanTransactionHelper.getLoanSummary(requestSpec, responseSpec, loanID);
Assertions.assertTrue(Float.valueOf("4000.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("principalWrittenOff")))) == 0, Assertions.assertTrue(
Float.valueOf("4000.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("principalWrittenOff")))) == 0,
"Checking for Principal written off "); "Checking for Principal written off ");
Assertions.assertTrue(Float.valueOf("1440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestWrittenOff")))) == 0, Assertions.assertTrue(
Float.valueOf("1440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestWrittenOff")))) == 0,
"Checking for interestPaid written off "); "Checking for interestPaid written off ");
Assertions.assertTrue(Float.valueOf("5440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalWrittenOff")))) == 0, Assertions.assertTrue(
Float.valueOf("5440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalWrittenOff")))) == 0,
"Checking for total written off "); "Checking for total written off ");
} }
@@ -33,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class NotificationApiTest { public class NotificationApiTest {
private final static Logger LOG = LoggerFactory.getLogger(NotificationApiTest.class); private final static Logger LOG = LoggerFactory.getLogger(NotificationApiTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -38,14 +38,9 @@ public class OfficeIntegrationTest {
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType( this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
ContentType.JSON).build(); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
.header("Authorization",
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@Test @Test
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class PasswordPreferencesIntegrationTest { public class PasswordPreferencesIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(PasswordPreferencesIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(PasswordPreferencesIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -69,8 +70,8 @@ public class PasswordPreferencesIntegrationTest {
@Test @Test
public void updateWithInvalidPolicyId() { public void updateWithInvalidPolicyId() {
String invalidValidationPolicyId = "2000"; String invalidValidationPolicyId = "2000";
final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec, invalidValidationPolicyId, final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec,
CommonConstants.RESPONSE_ERROR); invalidValidationPolicyId, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.password.validation.policy.id.invalid", error.get(0).get("userMessageGlobalisationCode"), assertEquals("error.msg.password.validation.policy.id.invalid", error.get(0).get("userMessageGlobalisationCode"),
"Password Validation Policy with identifier 2000 does not exist"); "Password Validation Policy with identifier 2000 does not exist");
} }
@@ -41,8 +41,7 @@ public class RatesTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
} }
@@ -54,20 +53,15 @@ public class RatesTest {
Assertions.assertNotNull(allRatesData); Assertions.assertNotNull(allRatesData);
// Testing Creation and Update of Loan Rate // Testing Creation and Update of Loan Rate
final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec, final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec, RatesHelper.getLoanRateJSON());
RatesHelper.getLoanRateJSON());
Assertions.assertNotNull(loanRateId); Assertions.assertNotNull(loanRateId);
// Update Rate percentage // Update Rate percentage
HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId, HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId, RatesHelper.getModifyRateJSON());
RatesHelper.getModifyRateJSON());
HashMap rateDataAfterChanges = RatesHelper HashMap rateDataAfterChanges = RatesHelper.getRateById(this.requestSpec, this.responseSpec, loanRateId);
.getRateById(this.requestSpec, this.responseSpec, loanRateId); Assertions.assertEquals(rateDataAfterChanges.get("percentage"), changes.get("percentage"), "Verifying Rate after modification");
Assertions.assertEquals(rateDataAfterChanges.get("percentage"),
changes.get("percentage"), "Verifying Rate after modification");
} }
} }
@@ -64,6 +64,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
public class RecurringDepositTest { public class RecurringDepositTest {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositTest.class); private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -101,9 +102,12 @@ public class RecurringDepositTest {
public static final Float DEPOSIT_AMOUNT = 2000.0f; public static final Float DEPOSIT_AMOUNT = 2000.0f;
// TODO Given the difference in calculation methods in test vs application, the exact values // TODO Given the difference in calculation methods in test vs application,
// returned may differ enough to cause differences in rounding. Given this, we only compare the full // the exact values
// digits. A proper solution would be to implement the exact interest calculation in this test, // returned may differ enough to cause differences in rounding. Given this,
// we only compare the full
// digits. A proper solution would be to implement the exact interest
// calculation in this test,
// and then to compare the exact results // and then to compare the exact results
@BeforeEach @BeforeEach
@@ -181,8 +185,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
/*** /***
@@ -211,10 +215,10 @@ public class RecurringDepositTest {
depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE); depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(depositTransactionId); Assertions.assertNotNull(depositTransactionId);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT));
/*** /***
* Update interest earned field for RD account * Update interest earned field for RD account
@@ -240,8 +244,8 @@ public class RecurringDepositTest {
/*** /***
* Calculate expected premature closure amount * Calculate expected premature closure amount
*/ */
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
/*** /***
* Preclose the RD account verify whether account is preClosed * Preclose the RD account verify whether account is preClosed
@@ -257,13 +261,13 @@ public class RecurringDepositTest {
/*** /***
* Verify journal entry transactions for preclosure transaction * Verify journal entry transactions for preclosure transaction
*/ */
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Float maturityAmount = Float.valueOf(recurringDepositAccountData.get("maturityAmount").toString()); Float maturityAmount = Float.valueOf(recurringDepositAccountData.get("maturityAmount").toString());
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.DEBIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT));
} }
@@ -361,8 +365,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
/*** /***
@@ -391,10 +395,10 @@ public class RecurringDepositTest {
depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE); depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(depositTransactionId); Assertions.assertNotNull(depositTransactionId);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT));
/*** /***
* Update interest earned field for RD account * Update interest earned field for RD account
@@ -423,8 +427,8 @@ public class RecurringDepositTest {
HashMap savingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap savingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
Float balanceBefore = (Float) savingsSummaryBefore.get("accountBalance"); Float balanceBefore = (Float) savingsSummaryBefore.get("accountBalance");
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
/*** /***
* Retrieve mapped financial account for liability transfer * Retrieve mapped financial account for liability transfer
@@ -443,19 +447,21 @@ public class RecurringDepositTest {
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Float maturityAmount = Float.valueOf(recurringDepositAccountData.get("maturityAmount").toString()); Float maturityAmount = Float.valueOf(recurringDepositAccountData.get("maturityAmount").toString());
/*** /***
* Verify journal entry transactions for preclosure transaction As this * Verify journal entry transactions for preclosure transaction As this
* transaction is an account transfer you should get financial account * transaction is an account transfer you should get financial account
* mapping details and verify amounts * mapping details and verify amounts
*/ */
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT), new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT),
new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(financialAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(financialAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.DEBIT), new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT));
/*** /***
* Verify rd account maturity amount and savings account balance * Verify rd account maturity amount and savings account balance
*/ */
@@ -468,8 +474,7 @@ public class RecurringDepositTest {
Double balanceAfter = Math.floor((Float) savingsSummaryAfter.get("accountBalance")); Double balanceAfter = Math.floor((Float) savingsSummaryAfter.get("accountBalance"));
Double expectedSavingsBalance = Math.floor(balanceBefore + prematurityAmount); Double expectedSavingsBalance = Math.floor(balanceBefore + prematurityAmount);
Assertions.assertEquals(expectedSavingsBalance, balanceAfter, Assertions.assertEquals(expectedSavingsBalance, balanceAfter, "Verifying Savings Account Balance after Premature Closure");
"Verifying Savings Account Balance after Premature Closure");
} }
@@ -480,7 +485,6 @@ public class RecurringDepositTest {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec); this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
/*** /***
* Create GL Accounts for product account mapping * Create GL Accounts for product account mapping
*/ */
@@ -554,8 +558,8 @@ public class RecurringDepositTest {
* Create RD product with CashBased accounting enabled * Create RD product with CashBased accounting enabled
*/ */
final Integer taxGroupId = createTaxGroup("10", liabilityAccountForTax); final Integer taxGroupId = createTaxGroup("10", liabilityAccountForTax);
Integer recurringDepositProductId = createRecurringDepositProductWithWithHoldTax(VALID_FROM, VALID_TO,String.valueOf(taxGroupId), accountingRule, assetAccount, Integer recurringDepositProductId = createRecurringDepositProductWithWithHoldTax(VALID_FROM, VALID_TO, String.valueOf(taxGroupId),
liabilityAccount, incomeAccount, expenseAccount); accountingRule, assetAccount, liabilityAccount, incomeAccount, expenseAccount);
Assertions.assertNotNull(recurringDepositProductId); Assertions.assertNotNull(recurringDepositProductId);
/*** /***
@@ -565,8 +569,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
/*** /***
@@ -595,10 +599,10 @@ public class RecurringDepositTest {
depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE); depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(depositTransactionId); Assertions.assertNotNull(depositTransactionId);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT));
/*** /***
* Update interest earned field for RD account * Update interest earned field for RD account
@@ -613,12 +617,10 @@ public class RecurringDepositTest {
.postInterestForRecurringDeposit(recurringDepositAccountId); .postInterestForRecurringDeposit(recurringDepositAccountId);
Assertions.assertNotNull(transactionIdForPostInterest); Assertions.assertNotNull(transactionIdForPostInterest);
HashMap accountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId); HashMap accountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted"); Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted");
Assertions.assertNull(accountSummary.get("totalWithholdTax")); Assertions.assertNull(accountSummary.get("totalWithholdTax"));
final JournalEntry[] expenseAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.DEBIT) }; final JournalEntry[] expenseAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liablilityAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.CREDIT) }; final JournalEntry[] liablilityAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry);
@@ -630,8 +632,8 @@ public class RecurringDepositTest {
HashMap savingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap savingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
Float balanceBefore = (Float) savingsSummaryBefore.get("accountBalance"); Float balanceBefore = (Float) savingsSummaryBefore.get("accountBalance");
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
/*** /***
* Retrieve mapped financial account for liability transfer * Retrieve mapped financial account for liability transfer
@@ -650,19 +652,21 @@ public class RecurringDepositTest {
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Float maturityAmount = Float.valueOf(recurringDepositAccountData.get("maturityAmount").toString()); Float maturityAmount = Float.valueOf(recurringDepositAccountData.get("maturityAmount").toString());
/*** /***
* Verify journal entry transactions for preclosure transaction As this * Verify journal entry transactions for preclosure transaction As this
* transaction is an account transfer you should get financial account * transaction is an account transfer you should get financial account
* mapping details and verify amounts * mapping details and verify amounts
*/ */
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT), new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT),
new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(financialAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(financialAccount, CLOSED_ON_DATE,
JournalEntry.TransactionType.DEBIT), new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(maturityAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(maturityAmount, JournalEntry.TransactionType.CREDIT));
/*** /***
* Verify rd account maturity amount and savings account balance * Verify rd account maturity amount and savings account balance
*/ */
@@ -672,21 +676,18 @@ public class RecurringDepositTest {
HashMap summary = (HashMap) recurringDepositData.get("summary"); HashMap summary = (HashMap) recurringDepositData.get("summary");
Assertions.assertNotNull(summary.get("totalWithholdTax")); Assertions.assertNotNull(summary.get("totalWithholdTax"));
Float withHoldTax = (Float) summary.get("totalWithholdTax"); Float withHoldTax = (Float) summary.get("totalWithholdTax");
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(withHoldTax, JournalEntry.TransactionType.CREDIT));
HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
Double balanceAfter = Math.floor((Float) savingsSummaryAfter.get("accountBalance")); Double balanceAfter = Math.floor((Float) savingsSummaryAfter.get("accountBalance"));
Double expectedSavingsBalance = Math.floor(balanceBefore + prematurityAmount); Double expectedSavingsBalance = Math.floor(balanceBefore + prematurityAmount);
Assertions.assertEquals(expectedSavingsBalance, balanceAfter, Assertions.assertEquals(expectedSavingsBalance, balanceAfter, "Verifying Savings Account Balance after Premature Closure");
"Verifying Savings Account Balance after Premature Closure");
} }
@Test @Test
public void testRecurringDepositAccountWithClosureTypeTransferToSavings_WITH_HOLD_TAX() throws InterruptedException { public void testRecurringDepositAccountWithClosureTypeTransferToSavings_WITH_HOLD_TAX() throws InterruptedException {
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
@@ -694,7 +695,6 @@ public class RecurringDepositTest {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec); this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
/*** /***
* Create GL Accounts for product account mapping * Create GL Accounts for product account mapping
*/ */
@@ -770,8 +770,8 @@ public class RecurringDepositTest {
* Create RD product with CashBased accounting enabled * Create RD product with CashBased accounting enabled
*/ */
final Integer taxGroupId = createTaxGroup("10", liabilityAccountForTax); final Integer taxGroupId = createTaxGroup("10", liabilityAccountForTax);
Integer recurringDepositProductId = createRecurringDepositProductWithWithHoldTax(VALID_FROM, VALID_TO,String.valueOf(taxGroupId), accountingRule, assetAccount, Integer recurringDepositProductId = createRecurringDepositProductWithWithHoldTax(VALID_FROM, VALID_TO, String.valueOf(taxGroupId),
liabilityAccount, incomeAccount, expenseAccount); accountingRule, assetAccount, liabilityAccount, incomeAccount, expenseAccount);
Assertions.assertNotNull(recurringDepositProductId); Assertions.assertNotNull(recurringDepositProductId);
/*** /***
@@ -781,8 +781,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
/*** /***
@@ -815,8 +815,8 @@ public class RecurringDepositTest {
depositAmount, dateFormat.format(todaysDate.getTime())); depositAmount, dateFormat.format(todaysDate.getTime()));
Assertions.assertNotNull(depositTransactionId); Assertions.assertNotNull(depositTransactionId);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, dateFormat.format(todaysDate.getTime()), new JournalEntry( this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, dateFormat.format(todaysDate.getTime()),
depositAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, dateFormat.format(todaysDate.getTime()), this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, dateFormat.format(todaysDate.getTime()),
new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT));
todaysDate.add(Calendar.MONTH, 1); todaysDate.add(Calendar.MONTH, 1);
@@ -836,19 +836,15 @@ public class RecurringDepositTest {
HashMap summary = (HashMap) accountDetails.get("summary"); HashMap summary = (HashMap) accountDetails.get("summary");
Assertions.assertNotNull(summary.get("totalWithholdTax")); Assertions.assertNotNull(summary.get("totalWithholdTax"));
Float withHoldTax = (Float) summary.get("totalWithholdTax"); Float withHoldTax = (Float) summary.get("totalWithholdTax");
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(withHoldTax, JournalEntry.TransactionType.CREDIT));
recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(this.requestSpec, recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(this.requestSpec,
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsMatured(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsMatured(recurringDepositAccountStatusHashMap);
} }
/*** /***
* Test case for Recurring Deposit Account premature closure with * Test case for Recurring Deposit Account premature closure with
* transaction type ReInvest and Cash Based accounting enabled * transaction type ReInvest and Cash Based accounting enabled
@@ -910,8 +906,8 @@ public class RecurringDepositTest {
liabilityAccount, incomeAccount, expenseAccount); liabilityAccount, incomeAccount, expenseAccount);
Assertions.assertNotNull(recurringDepositProductId); Assertions.assertNotNull(recurringDepositProductId);
ArrayList<HashMap> allRecurringDepositProductsData = this.recurringDepositProductHelper.retrieveAllRecurringDepositProducts( ArrayList<HashMap> allRecurringDepositProductsData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec); .retrieveAllRecurringDepositProducts(this.requestSpec, this.responseSpec);
HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec, HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec,
this.responseSpec, recurringDepositProductId.toString()); this.responseSpec, recurringDepositProductId.toString());
@@ -922,8 +918,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
/*** /***
@@ -952,10 +948,10 @@ public class RecurringDepositTest {
DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE); DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(depositTransactionId); Assertions.assertNotNull(depositTransactionId);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.DEBIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
depositAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT));
/*** /***
* Update interest earned field for RD account * Update interest earned field for RD account
@@ -981,8 +977,8 @@ public class RecurringDepositTest {
/*** /***
* Calculate expected premature closure amount * Calculate expected premature closure amount
*/ */
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
/*** /***
* Expected to get an error response from api because re-invest option * Expected to get an error response from api because re-invest option
@@ -1075,8 +1071,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -1123,8 +1119,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.rejectApplication(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.rejectApplication(recurringDepositAccountId,
@@ -1170,8 +1166,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.withdrawApplication(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.withdrawApplication(recurringDepositAccountId,
@@ -1214,12 +1210,12 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountId = (Integer) this.recurringDepositAccountHelper.deleteRecurringDepositApplication( recurringDepositAccountId = (Integer) this.recurringDepositAccountHelper
recurringDepositAccountId, "resourceId"); .deleteRecurringDepositApplication(recurringDepositAccountId, "resourceId");
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
} }
@@ -1280,8 +1276,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
/*** /***
@@ -1309,10 +1305,10 @@ public class RecurringDepositTest {
DEPOSIT_AMOUNT, DEPOSIT_DATE); DEPOSIT_AMOUNT, DEPOSIT_DATE);
Assertions.assertNotNull(transactionIdForDeposit); Assertions.assertNotNull(transactionIdForDeposit);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, DEPOSIT_DATE, new JournalEntry(DEPOSIT_AMOUNT, this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, DEPOSIT_DATE,
JournalEntry.TransactionType.DEBIT)); new JournalEntry(DEPOSIT_AMOUNT, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, DEPOSIT_DATE, new JournalEntry(DEPOSIT_AMOUNT, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, DEPOSIT_DATE,
JournalEntry.TransactionType.CREDIT)); new JournalEntry(DEPOSIT_AMOUNT, JournalEntry.TransactionType.CREDIT));
/*** /***
* verify account balances after transactions * verify account balances after transactions
@@ -1331,10 +1327,10 @@ public class RecurringDepositTest {
transactionIdForDeposit, DEPOSIT_DATE, updatedTransactionAmount); transactionIdForDeposit, DEPOSIT_DATE, updatedTransactionAmount);
Assertions.assertNotNull(updateTransactionId); Assertions.assertNotNull(updateTransactionId);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, DEPOSIT_DATE, new JournalEntry(updatedTransactionAmount, this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, DEPOSIT_DATE,
JournalEntry.TransactionType.DEBIT)); new JournalEntry(updatedTransactionAmount, JournalEntry.TransactionType.DEBIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, DEPOSIT_DATE, new JournalEntry( this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, DEPOSIT_DATE,
updatedTransactionAmount, JournalEntry.TransactionType.CREDIT)); new JournalEntry(updatedTransactionAmount, JournalEntry.TransactionType.CREDIT));
expectedBalanceAfter = DEPOSIT_AMOUNT - updatedTransactionAmount; expectedBalanceAfter = DEPOSIT_AMOUNT - updatedTransactionAmount;
recurringDepositSummaryAfter = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId); recurringDepositSummaryAfter = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
@@ -1394,8 +1390,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -1409,8 +1405,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
HashMap recurringDepositSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId); HashMap recurringDepositSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
Float principal = (Float) recurringDepositSummary.get("accountBalance"); Float principal = (Float) recurringDepositSummary.get("accountBalance");
@@ -1477,8 +1473,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -1492,8 +1488,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
HashMap recurringDepositSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId); HashMap recurringDepositSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
Float principal = (Float) recurringDepositSummary.get("accountBalance"); Float principal = (Float) recurringDepositSummary.get("accountBalance");
@@ -1552,8 +1548,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -1569,8 +1565,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE); DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE);
@@ -1603,7 +1599,8 @@ public class RecurringDepositTest {
Float principalAfter = (float) Math.floor((Float) recurringDepositAccountSummary.get("accountBalance")); Float principalAfter = (float) Math.floor((Float) recurringDepositAccountSummary.get("accountBalance"));
interestToBePosted = (float) Math.floor(interestToBePosted); interestToBePosted = (float) Math.floor(interestToBePosted);
Assertions.assertEquals(interestToBePosted, interestAmountPosted, "Verifying Amount of Interest Posted to Recurring Deposit Account"); Assertions.assertEquals(interestToBePosted, interestAmountPosted,
"Verifying Amount of Interest Posted to Recurring Deposit Account");
Assertions.assertEquals(expectedBalanceAfter, principalAfter, "Verifying Principal Amount after Interest Posting"); Assertions.assertEquals(expectedBalanceAfter, principalAfter, "Verifying Principal Amount after Interest Posting");
} }
@@ -1655,8 +1652,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -1674,8 +1671,8 @@ public class RecurringDepositTest {
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE); DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE);
@@ -1712,8 +1709,8 @@ public class RecurringDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit( Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -1723,8 +1720,8 @@ public class RecurringDepositTest {
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); principal = (float) Math.floor(principal);
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -1785,8 +1782,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -1804,8 +1801,8 @@ public class RecurringDepositTest {
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE); DEPOSIT_AMOUNT, EXPECTED_FIRST_DEPOSIT_ON_DATE);
@@ -1842,8 +1839,8 @@ public class RecurringDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit( Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -1853,8 +1850,8 @@ public class RecurringDepositTest {
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); principal = (float) Math.floor(principal);
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -1913,8 +1910,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, TILL_PREMATURE_WITHDRAWAL, EXPECTED_FIRST_DEPOSIT_ON_DATE); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, TILL_PREMATURE_WITHDRAWAL, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -1931,8 +1928,8 @@ public class RecurringDepositTest {
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Calendar activationDate = Calendar.getInstance(); Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1); activationDate.add(Calendar.MONTH, -1);
@@ -1980,8 +1977,8 @@ public class RecurringDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit( Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -1991,8 +1988,8 @@ public class RecurringDepositTest {
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); principal = (float) Math.floor(principal);
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2056,8 +2053,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_360, TILL_PREMATURE_WITHDRAWAL, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY, VALID_FROM, VALID_TO, DAYS_360, TILL_PREMATURE_WITHDRAWAL, INTEREST_CALCULATION_USING_DAILY_BALANCE, MONTHLY, MONTHLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2074,8 +2071,8 @@ public class RecurringDepositTest {
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest"); Float preClosurePenalInterestRate = (Float) recurringDepositAccountData.get("preClosurePenalInterest");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Calendar activationDate = Calendar.getInstance(); Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1); activationDate.add(Calendar.MONTH, -1);
@@ -2123,8 +2120,8 @@ public class RecurringDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
LOG.info("principal = {}", principal); LOG.info("principal = {}", principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper
recurringDepositAccountId, CLOSED_ON_DATE); .calculatePrematureAmountForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE);
Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit( Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID); recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -2134,8 +2131,8 @@ public class RecurringDepositTest {
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); principal = (float) Math.floor(principal);
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2188,8 +2185,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2205,8 +2202,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2271,8 +2268,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, MONTHLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2288,8 +2285,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2361,8 +2358,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2377,8 +2374,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2389,8 +2386,8 @@ public class RecurringDepositTest {
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, BIANNULLY_INTERVAL, BIANNULLY_INTERVAL); depositPeriod, interestPerDay, BIANNULLY_INTERVAL, BIANNULLY_INTERVAL);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Double expectedPrematureAmount = Math.floor(principal);
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2451,8 +2448,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, BI_ANNUALLY, BI_ANNUALLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2467,8 +2464,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2479,8 +2476,8 @@ public class RecurringDepositTest {
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, BIANNULLY_INTERVAL, BIANNULLY_INTERVAL); depositPeriod, interestPerDay, BIANNULLY_INTERVAL, BIANNULLY_INTERVAL);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Double expectedPrematureAmount = Math.floor(principal);
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2540,8 +2537,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2557,8 +2554,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2569,8 +2566,8 @@ public class RecurringDepositTest {
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, ANNUL_INTERVAL); depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, ANNUL_INTERVAL);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Double expectedPrematureAmount = Math.floor(principal);
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2630,8 +2627,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, DAILY, ANNUALLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2647,8 +2644,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2659,8 +2656,8 @@ public class RecurringDepositTest {
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, ANNUL_INTERVAL); depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, ANNUL_INTERVAL);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Double expectedPrematureAmount = Math.floor(principal);
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2721,8 +2718,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY, VALID_FROM, VALID_TO, DAYS_365, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2737,8 +2734,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2749,8 +2746,8 @@ public class RecurringDepositTest {
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, QUARTERLY_INTERVAL, QUARTERLY_INTERVAL); depositPeriod, interestPerDay, QUARTERLY_INTERVAL, QUARTERLY_INTERVAL);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Double expectedPrematureAmount = Math.floor(principal);
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2811,8 +2808,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY, VALID_FROM, VALID_TO, DAYS_360, WHOLE_TERM, INTEREST_CALCULATION_USING_DAILY_BALANCE, QUARTERLY, QUARTERLY,
EXPECTED_FIRST_DEPOSIT_ON_DATE); EXPECTED_FIRST_DEPOSIT_ON_DATE);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -2827,8 +2824,8 @@ public class RecurringDepositTest {
Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod"); Integer depositPeriod = (Integer) recurringDepositAccountData.get("depositPeriod");
HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType"); HashMap daysInYearMap = (HashMap) recurringDepositAccountData.get("interestCalculationDaysInYearType");
Integer daysInYear = (Integer) daysInYearMap.get("id"); Integer daysInYear = (Integer) daysInYearMap.get("id");
ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper.getInterestRateChartSlabsByProductId( ArrayList<ArrayList<HashMap>> interestRateChartData = this.recurringDepositProductHelper
this.requestSpec, this.responseSpec, recurringDepositProductId); .getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = interestRate / 100; double interestRateInFraction = interestRate / 100;
@@ -2839,8 +2836,8 @@ public class RecurringDepositTest {
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, QUARTERLY_INTERVAL, QUARTERLY_INTERVAL); depositPeriod, interestPerDay, QUARTERLY_INTERVAL, QUARTERLY_INTERVAL);
recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
this.responseSpec, recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Double expectedPrematureAmount = Math.floor(principal);
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
@@ -2988,8 +2985,8 @@ public class RecurringDepositTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, SUBMITTED_ON_DATE, depositAmount, depositPeriod); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, SUBMITTED_ON_DATE, depositAmount, depositPeriod);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
/*** /***
@@ -3015,7 +3012,8 @@ public class RecurringDepositTest {
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule,
Account... accounts) { Account... accounts) {
LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec,
this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
} else if (accountingRule.equals(NONE)) { } else if (accountingRule.equals(NONE)) {
@@ -3025,17 +3023,17 @@ public class RecurringDepositTest {
return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec); return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec);
} }
private Integer createRecurringDepositProductWithWithHoldTax(final String validFrom, final String validTo,final String taxGroupId, final String accountingRule, private Integer createRecurringDepositProductWithWithHoldTax(final String validFrom, final String validTo, final String taxGroupId,
Account... accounts) { final String accountingRule, Account... accounts) {
LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec,
this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
} else if (accountingRule.equals(NONE)) { } else if (accountingRule.equals(NONE)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsNone(); recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsNone();
} }
final String recurringDepositProductJSON = recurringDepositProductHelper.withPeriodRangeChart() final String recurringDepositProductJSON = recurringDepositProductHelper.withPeriodRangeChart().withWithHoldTax(taxGroupId)//
.withWithHoldTax(taxGroupId)//
.build(validFrom, validTo); .build(validFrom, validTo);
return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec); return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec);
} }
@@ -3043,7 +3041,8 @@ public class RecurringDepositTest {
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule,
final String chartToBePicked, Account... accounts) { final String chartToBePicked, Account... accounts) {
LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec,
this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
} else if (accountingRule.equals(NONE)) { } else if (accountingRule.equals(NONE)) {
@@ -3151,11 +3150,13 @@ public class RecurringDepositTest {
LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityAccountForMapping.getAccountID(), this.responseSpec, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityAccountForMapping.getAccountID(), this.responseSpec,
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(financialActivityAccountId); Assertions.assertNotNull(financialActivityAccountId);
assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityAccountForMapping); assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID,
liabilityAccountForMapping);
return liabilityAccountForMapping; return liabilityAccountForMapping;
} }
private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId, Account glAccount) { private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId,
Account glAccount) {
HashMap mappingDetails = this.financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId, HashMap mappingDetails = this.financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId,
this.responseSpec); this.responseSpec);
Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id")); Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
@@ -3164,11 +3165,11 @@ public class RecurringDepositTest {
private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax) { private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax) {
final Integer liabilityAccountId = liabilityAccountForTax.getAccountID(); final Integer liabilityAccountId = liabilityAccountForTax.getAccountID();
final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId); final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage,
liabilityAccountId);
return TaxGroupHelper.createTaxGroup(this.requestSpec, this.responseSpec, Arrays.asList(taxComponentId)); return TaxGroupHelper.createTaxGroup(this.requestSpec, this.responseSpec, Arrays.asList(taxComponentId));
} }
/** /**
* Delete the Liability transfer account * Delete the Liability transfer account
*/ */
@@ -3177,8 +3178,8 @@ public class RecurringDepositTest {
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec); List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
for (HashMap financialActivity : financialActivities) { for (HashMap financialActivity : financialActivities) {
Integer financialActivityAccountId = (Integer) financialActivity.get("id"); Integer financialActivityAccountId = (Integer) financialActivity.get("id");
Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper
financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
} }
@@ -38,6 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class RolesTest { public class RolesTest {
private final static Logger LOG = LoggerFactory.getLogger(RolesTest.class); private final static Logger LOG = LoggerFactory.getLogger(RolesTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -67,12 +67,12 @@ public class SchedulerJobsTest {
@Test // FINERACT-926 @Test // FINERACT-926
public void testDateFormat() { public void testDateFormat() {
// must start scheduler and make job active to have nextRunTime (which is a // must start scheduler and make job active to have nextRunTime (which
// is a
// java.util.Date) // java.util.Date)
schedulerJobHelper.updateSchedulerStatus(true); schedulerJobHelper.updateSchedulerStatus(true);
schedulerJobHelper.updateSchedulerJob(1, true); schedulerJobHelper.updateSchedulerJob(1, true);
String nextRunTimeText = await().until( String nextRunTimeText = await().until(() -> (String) schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"),
() -> (String) schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"),
nextRunTime -> nextRunTime != null); nextRunTime -> nextRunTime != null);
DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText); DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText);
} }
@@ -102,7 +102,8 @@ public class SchedulerJobsTest {
@Test @Test
public void testFlippingJobsActiveStatus() throws InterruptedException { public void testFlippingJobsActiveStatus() throws InterruptedException {
// Stop the Scheduler while we test flapping jobs' active on/off, to avoid side // Stop the Scheduler while we test flapping jobs' active on/off, to
// avoid side
// effects // effects
schedulerJobHelper.updateSchedulerStatus(false); schedulerJobHelper.updateSchedulerStatus(false);
@@ -97,8 +97,7 @@ public class SchedulerJobsTestResults {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default"); this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.responseSpecForSchedulerJob = new ResponseSpecBuilder().expectStatusCode(202).build(); this.responseSpecForSchedulerJob = new ResponseSpecBuilder().expectStatusCode(202).build();
@@ -124,12 +123,11 @@ public class SchedulerJobsTestResults {
ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
final Integer annualFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, final Integer annualFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
@@ -149,20 +147,18 @@ public class SchedulerJobsTestResults {
String JobName = "Apply Annual Fee For Savings"; String JobName = "Apply Annual Fee For Savings";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, annualFeeChargeId);
annualFeeChargeId);
Float chargeAmount = (Float) chargeData.get("amount"); Float chargeAmount = (Float) chargeData.get("amount");
final HashMap savingsDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); final HashMap savingsDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
final HashMap annualFeeDetails = (HashMap) savingsDetails.get("annualFee"); final HashMap annualFeeDetails = (HashMap) savingsDetails.get("annualFee");
ArrayList<Integer> annualFeeDueDateAsArrayList = (ArrayList<Integer>) annualFeeDetails.get("dueDate"); ArrayList<Integer> annualFeeDueDateAsArrayList = (ArrayList<Integer>) annualFeeDetails.get("dueDate");
LocalDate nextDueDateForAnnualFee = LocalDate.of(annualFeeDueDateAsArrayList.get(0), LocalDate nextDueDateForAnnualFee = LocalDate.of(annualFeeDueDateAsArrayList.get(0), annualFeeDueDateAsArrayList.get(1),
annualFeeDueDateAsArrayList.get(1), annualFeeDueDateAsArrayList.get(2)); annualFeeDueDateAsArrayList.get(2));
LocalDate todaysDate = LocalDate.now(ZoneId.of("Asia/Kolkata")); LocalDate todaysDate = LocalDate.now(ZoneId.of("Asia/Kolkata"));
Assertions.assertTrue(nextDueDateForAnnualFee.isAfter(todaysDate), Assertions.assertTrue(nextDueDateForAnnualFee.isAfter(todaysDate), "Verifying that all due Annual Fees have been paid ");
"Verifying that all due Annual Fees have been paid ");
} }
@@ -178,12 +174,11 @@ public class SchedulerJobsTestResults {
ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
@@ -217,12 +212,11 @@ public class SchedulerJobsTestResults {
ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
@@ -234,16 +228,13 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProduct(null); final Integer loanProductID = createLoanProduct(null);
Assertions.assertNotNull(loanProductID); Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), savingsId.toString());
savingsId.toString());
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
@@ -251,13 +242,11 @@ public class SchedulerJobsTestResults {
Assertions.assertNotNull(specifiedDueDateChargeId); Assertions.assertNotNull(specifiedDueDateChargeId);
this.loanTransactionHelper.addChargesForLoan(loanID, this.loanTransactionHelper.addChargesForLoan(loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(specifiedDueDateChargeId.toString(), "12 March 2013", "100"));
specifiedDueDateChargeId.toString(), "12 March 2013", "100"));
ArrayList<HashMap> chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID); ArrayList<HashMap> chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID);
Assertions.assertEquals(1, chargesPendingState.size()); Assertions.assertEquals(1, chargesPendingState.size());
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
@@ -265,8 +254,7 @@ public class SchedulerJobsTestResults {
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
specifiedDueDateChargeId);
Float chargeAmount = (Float) chargeData.get("amount"); Float chargeAmount = (Float) chargeData.get("amount");
@@ -296,21 +284,18 @@ public class SchedulerJobsTestResults {
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null);
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); this.responseSpec);
Assertions.assertNotNull(globalConfig); Assertions.assertNotNull(globalConfig);
// Updating Value for reschedule-repayments-on-holidays Global // Updating Value for reschedule-repayments-on-holidays Global
@@ -318,37 +303,33 @@ public class SchedulerJobsTestResults {
Integer configId = (Integer) globalConfig.get(3).get("id"); Integer configId = (Integer) globalConfig.get(3).get("id");
Assertions.assertNotNull(configId); Assertions.assertNotNull(configId);
HashMap configData = this.globalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, HashMap configData = this.globalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
this.responseSpec, configId.toString()); configId.toString());
Assertions.assertNotNull(configData); Assertions.assertNotNull(configData);
Boolean enabled = (Boolean) globalConfig.get(3).get("enabled"); Boolean enabled = (Boolean) globalConfig.get(3).get("enabled");
if (enabled == false) { if (enabled == false) {
enabled = true; enabled = true;
configId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration( configId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
this.requestSpec, this.responseSpec, configId.toString(), enabled); configId.toString(), enabled);
} }
final ArrayList<HashMap> repaymentScheduleDataBeforeJob = this.loanTransactionHelper final ArrayList<HashMap> repaymentScheduleDataBeforeJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); this.responseSpec, loanID);
holidayId = this.holidayHelper.activateHolidays(this.requestSpec, this.responseSpec, holidayId = this.holidayHelper.activateHolidays(this.requestSpec, this.responseSpec, holidayId.toString());
holidayId.toString());
Assertions.assertNotNull(holidayId); Assertions.assertNotNull(holidayId);
String JobName = "Apply Holidays To Loans"; String JobName = "Apply Holidays To Loans";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
final ArrayList<HashMap> repaymentScheduleDataAfterJob = this.loanTransactionHelper final ArrayList<HashMap> repaymentScheduleDataAfterJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); this.responseSpec, loanID);
HashMap holidayData = this.holidayHelper.getHolidayById(this.requestSpec, this.responseSpec, HashMap holidayData = this.holidayHelper.getHolidayById(this.requestSpec, this.responseSpec, holidayId.toString());
holidayId.toString()); ArrayList<Integer> repaymentsRescheduledDate = (ArrayList<Integer>) holidayData.get("repaymentsRescheduledTo");
ArrayList<Integer> repaymentsRescheduledDate = (ArrayList<Integer>) holidayData
.get("repaymentsRescheduledTo");
ArrayList<Integer> rescheduleDateAfter = (ArrayList<Integer>) repaymentScheduleDataAfterJob.get(2) ArrayList<Integer> rescheduleDateAfter = (ArrayList<Integer>) repaymentScheduleDataAfterJob.get(2).get("fromDate");
.get("fromDate");
Assertions.assertEquals(repaymentsRescheduledDate, repaymentsRescheduledDate, Assertions.assertEquals(repaymentsRescheduledDate, repaymentsRescheduledDate,
"Verifying Repayment Rescheduled Date after Running Apply Holidays to Loans Scheduler Job"); "Verifying Repayment Rescheduled Date after Running Apply Holidays to Loans Scheduler Job");
@@ -367,16 +348,15 @@ public class SchedulerJobsTestResults {
ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
final Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, final Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
this.responseSpec, ChargesHelper.getSavingsSpecifiedDueDateJSON()); ChargesHelper.getSavingsSpecifiedDueDateJSON());
Assertions.assertNotNull(specifiedDueDateChargeId); Assertions.assertNotNull(specifiedDueDateChargeId);
this.savingsAccountHelper.addChargesForSavings(savingsId, specifiedDueDateChargeId, true); this.savingsAccountHelper.addChargesForSavings(savingsId, specifiedDueDateChargeId, true);
@@ -396,8 +376,7 @@ public class SchedulerJobsTestResults {
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
specifiedDueDateChargeId);
Float chargeAmount = (Float) chargeData.get("amount"); Float chargeAmount = (Float) chargeData.get("amount");
@@ -419,16 +398,13 @@ public class SchedulerJobsTestResults {
final Integer accountID = assetAccount.getAccountID(); final Integer accountID = assetAccount.getAccountID();
final Integer savingsProductID = createSavingsProduct(MINIMUM_OPENING_BALANCE, assetAccount, final Integer savingsProductID = createSavingsProduct(MINIMUM_OPENING_BALANCE, assetAccount, incomeAccount, expenseAccount,
incomeAccount, expenseAccount, liabilityAccount); liabilityAccount);
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
this.DATE_OF_JOINING); final Integer savingsID = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
final Integer savingsID = this.savingsAccountHelper.applyForSavingsApplication(clientID,
savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsID);
this.responseSpec, savingsID);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsID); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsID);
@@ -438,20 +414,16 @@ public class SchedulerJobsTestResults {
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
// Checking initial Account entries. // Checking initial Account entries.
final JournalEntry[] assetAccountInitialEntry = { final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) };
new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) }; final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] liablilityAccountInitialEntry = { this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountInitialEntry);
new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE,
assetAccountInitialEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liablilityAccountInitialEntry); liablilityAccountInitialEntry);
String JobName = "Update Accounting Running Balances"; String JobName = "Update Accounting Running Balances";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
final HashMap runningBalanceAfter = this.accountHelper final HashMap runningBalanceAfter = this.accountHelper.getAccountingWithRunningBalanceById(accountID.toString());
.getAccountingWithRunningBalanceById(accountID.toString());
final Integer INT_BALANCE = Integer.valueOf(MINIMUM_OPENING_BALANCE); final Integer INT_BALANCE = Integer.valueOf(MINIMUM_OPENING_BALANCE);
@@ -474,26 +446,21 @@ public class SchedulerJobsTestResults {
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null);
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
String JobName = "Update Loan Arrears Ageing"; String JobName = "Update Loan Arrears Ageing";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
HashMap loanSummaryData = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, HashMap loanSummaryData = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
loanID);
Float totalLoanArrearsAging = (Float) loanSummaryData.get("principalOverdue") Float totalLoanArrearsAging = (Float) loanSummaryData.get("principalOverdue") + (Float) loanSummaryData.get("interestOverdue");
+ (Float) loanSummaryData.get("interestOverdue");
Assertions.assertEquals(totalLoanArrearsAging, loanSummaryData.get("totalOverdue"), Assertions.assertEquals(totalLoanArrearsAging, loanSummaryData.get("totalOverdue"),
"Verifying Arrears Aging after Running Update Loan Arrears Aging Scheduler Job"); "Verifying Arrears Aging after Running Update Loan Arrears Aging Scheduler Job");
@@ -526,34 +493,31 @@ public class SchedulerJobsTestResults {
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null);
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
ArrayList<HashMap> loanScheduleBefore = this.loanTransactionHelper ArrayList<HashMap> loanScheduleBefore = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); loanID);
Float totalDueForCurrentPeriod = (Float) loanScheduleBefore.get(1).get("totalDueForPeriod"); Float totalDueForCurrentPeriod = (Float) loanScheduleBefore.get(1).get("totalDueForPeriod");
this.loanTransactionHelper.makeRepayment(LOAN_FIRST_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID); this.loanTransactionHelper.makeRepayment(LOAN_FIRST_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
loanID);
String JobName = "Update Loan Paid In Advance"; String JobName = "Update Loan Paid In Advance";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
// Retrieving Loan Repayment Schedule after the successful // Retrieving Loan Repayment Schedule after the successful
// completion of // completion of
// Update Loan Paid in Advance Scheduler Job // Update Loan Paid in Advance Scheduler Job
ArrayList<HashMap> loanScheduleAfter = this.loanTransactionHelper ArrayList<HashMap> loanScheduleAfter = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); loanID);
loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID); loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
@@ -602,26 +566,22 @@ public class SchedulerJobsTestResults {
ArrayList<HashMap> chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID); ArrayList<HashMap> chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID);
Assertions.assertEquals(1, chargesPendingState.size()); Assertions.assertEquals(1, chargesPendingState.size());
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
HashMap loanSummaryBefore = this.loanTransactionHelper.getLoanSummary(this.requestSpec, HashMap loanSummaryBefore = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
this.responseSpec, loanID);
String JobName = "Update loan Summary"; String JobName = "Update loan Summary";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
Float expectedSummaryAfterJob = (Float) loanSummaryBefore.get("totalExpectedRepayment") Float expectedSummaryAfterJob = (Float) loanSummaryBefore.get("totalExpectedRepayment")
/* - (Float) loanSummaryBefore.get("feeChargesPaid") */; /* - (Float) loanSummaryBefore.get("feeChargesPaid") */;
HashMap loanSummaryAfter = this.loanTransactionHelper.getLoanSummary(this.requestSpec, HashMap loanSummaryAfter = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
this.responseSpec, loanID);
Assertions.assertEquals(expectedSummaryAfterJob, (Float) loanSummaryAfter.get("totalExpectedRepayment"), Assertions.assertEquals(expectedSummaryAfterJob, (Float) loanSummaryAfter.get("totalExpectedRepayment"),
"Verifying Loan Summary after Running Update Loan Summary Scheduler Job"); "Verifying Loan Summary after Running Update Loan Summary Scheduler Job");
@@ -652,12 +612,11 @@ public class SchedulerJobsTestResults {
ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer fromSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, final Integer fromSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap fromSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap fromSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, fromSavingsId);
this.responseSpec, fromSavingsId);
SavingsStatusChecker.verifySavingsIsPending(fromSavingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(fromSavingsStatusHashMap);
fromSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(fromSavingsId); fromSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(fromSavingsId);
@@ -666,12 +625,11 @@ public class SchedulerJobsTestResults {
fromSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(fromSavingsId); fromSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(fromSavingsId);
SavingsStatusChecker.verifySavingsIsActive(fromSavingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(fromSavingsStatusHashMap);
final Integer toSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, final Integer toSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
HashMap toSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap toSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, toSavingsId);
this.responseSpec, toSavingsId);
SavingsStatusChecker.verifySavingsIsPending(toSavingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(toSavingsStatusHashMap);
toSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(toSavingsId); toSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(toSavingsId);
@@ -686,9 +644,9 @@ public class SchedulerJobsTestResults {
HashMap toSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(toSavingsId); HashMap toSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(toSavingsId);
Float toSavingsBalanceBefore = (Float) toSavingsSummaryBefore.get("accountBalance"); Float toSavingsBalanceBefore = (Float) toSavingsSummaryBefore.get("accountBalance");
Integer standingInstructionId = this.standingInstructionsHelper.createStandingInstruction( Integer standingInstructionId = this.standingInstructionsHelper.createStandingInstruction(clientID.toString(),
clientID.toString(), fromSavingsId.toString(), toSavingsId.toString(), fromSavingsId.toString(), toSavingsId.toString(), FROM_ACCOUNT_TYPE_SAVINGS, TO_ACCOUNT_TYPE_SAVINGS, VALID_FROM, VALID_TO,
FROM_ACCOUNT_TYPE_SAVINGS, TO_ACCOUNT_TYPE_SAVINGS, VALID_FROM, VALID_TO, MONTH_DAY); MONTH_DAY);
Assertions.assertNotNull(standingInstructionId); Assertions.assertNotNull(standingInstructionId);
String JobName = "Execute Standing Instruction"; String JobName = "Execute Standing Instruction";
@@ -701,8 +659,7 @@ public class SchedulerJobsTestResults {
final HashMap standingInstructionData = this.standingInstructionsHelper final HashMap standingInstructionData = this.standingInstructionsHelper
.getStandingInstructionById(standingInstructionId.toString()); .getStandingInstructionById(standingInstructionId.toString());
Float expectedFromSavingsBalance = fromSavingsBalanceBefore Float expectedFromSavingsBalance = fromSavingsBalanceBefore - (Float) standingInstructionData.get("amount");
- (Float) standingInstructionData.get("amount");
Float expectedToSavingsBalance = toSavingsBalanceBefore + (Float) standingInstructionData.get("amount"); Float expectedToSavingsBalance = toSavingsBalanceBefore + (Float) standingInstructionData.get("amount");
Assertions.assertEquals(expectedFromSavingsBalance, fromSavingsBalanceAfter, Assertions.assertEquals(expectedFromSavingsBalance, fromSavingsBalanceAfter,
@@ -711,8 +668,8 @@ public class SchedulerJobsTestResults {
"Verifying To Savings Balance after Successful completion of Scheduler Job"); "Verifying To Savings Balance after Successful completion of Scheduler Job");
Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue(); Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue();
Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue(); Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue();
List<HashMap> standinInstructionHistoryData = this.standingInstructionsHelper List<HashMap> standinInstructionHistoryData = this.standingInstructionsHelper.getStandingInstructionHistory(fromSavingsId,
.getStandingInstructionHistory(fromSavingsId, fromAccountType, clientID, transferType); fromAccountType, clientID, transferType);
Assertions.assertEquals(1, standinInstructionHistoryData.size(), Assertions.assertEquals(1, standinInstructionHistoryData.size(),
"Verifying the no of stainding instruction transactions logged for the client"); "Verifying the no of stainding instruction transactions logged for the client");
HashMap loggedTransaction = standinInstructionHistoryData.get(0); HashMap loggedTransaction = standinInstructionHistoryData.get(0);
@@ -741,31 +698,27 @@ public class SchedulerJobsTestResults {
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null);
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID);
.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
ArrayList<HashMap> repaymentScheduleDataBefore = this.loanTransactionHelper ArrayList<HashMap> repaymentScheduleDataBefore = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); this.responseSpec, loanID);
String JobName = "Apply penalty to overdue loans"; String JobName = "Apply penalty to overdue loans";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
overdueFeeChargeId);
Float chargeAmount = (Float) chargeData.get("amount"); Float chargeAmount = (Float) chargeData.get("amount");
ArrayList<HashMap> repaymentScheduleDataAfter = this.loanTransactionHelper ArrayList<HashMap> repaymentScheduleDataAfter = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); this.responseSpec, loanID);
Assertions.assertEquals(chargeAmount, (Float) repaymentScheduleDataAfter.get(1).get("penaltyChargesDue"), Assertions.assertEquals(chargeAmount, (Float) repaymentScheduleDataAfter.get(1).get("penaltyChargesDue"),
"Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job"); "Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job");
@@ -795,20 +748,17 @@ public class SchedulerJobsTestResults {
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null);
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID);
.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
ArrayList<HashMap> repaymentScheduleDataBefore = this.loanTransactionHelper ArrayList<HashMap> repaymentScheduleDataBefore = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); this.responseSpec, loanID);
String JobName = "Apply penalty to overdue loans"; String JobName = "Apply penalty to overdue loans";
Integer jobId = 12; Integer jobId = 12;
@@ -824,17 +774,15 @@ public class SchedulerJobsTestResults {
Assertions.assertNotNull(schedulerJob); Assertions.assertNotNull(schedulerJob);
} }
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
overdueFeeChargeId);
ArrayList<HashMap> repaymentScheduleDataAfter = this.loanTransactionHelper ArrayList<HashMap> repaymentScheduleDataAfter = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); this.responseSpec, loanID);
Assertions.assertEquals(0, repaymentScheduleDataAfter.get(1).get("penaltyChargesDue"), Assertions.assertEquals(0, repaymentScheduleDataAfter.get(1).get("penaltyChargesDue"),
"Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job"); "Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job");
final ArrayList loanCharges = this.loanTransactionHelper.getLoanCharges(this.requestSpec, final ArrayList loanCharges = this.loanTransactionHelper.getLoanCharges(this.requestSpec, this.responseSpec, loanID);
this.responseSpec, loanID);
Assertions.assertNull(loanCharges, "Verifying that charge isn't created when the amount is 0"); Assertions.assertNull(loanCharges, "Verifying that charge isn't created when the amount is 0");
@@ -858,26 +806,21 @@ public class SchedulerJobsTestResults {
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null);
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID);
loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final Boolean isNPABefore = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, final Boolean isNPABefore = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA");
responseSpec, loanID, "isNPA");
Assertions.assertFalse(isNPABefore); Assertions.assertFalse(isNPABefore);
// Integer jobId = (Integer) allSchedulerJobsData.get(1).get("jobId"); // Integer jobId = (Integer) allSchedulerJobsData.get(1).get("jobId");
String JobName = "Update Non Performing Assets"; String JobName = "Update Non Performing Assets";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
final Boolean isNPAAfter = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, final Boolean isNPAAfter = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA");
loanID, "isNPA");
Assertions.assertTrue(isNPAAfter); Assertions.assertTrue(isNPAAfter);
} }
@@ -889,11 +832,11 @@ public class SchedulerJobsTestResults {
// FixedDepositProductHelper(this.requestSpec,this.responseSpec); // FixedDepositProductHelper(this.requestSpec,this.responseSpec);
// AccountHelper accountHelper = new AccountHelper(this.requestSpec, // AccountHelper accountHelper = new AccountHelper(this.requestSpec,
// this.responseSpec); // this.responseSpec);
FixedDepositAccountHelper fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, FixedDepositAccountHelper fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
this.responseSpec);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
// DateFormat monthDayFormat = new SimpleDateFormat("dd MMM", Locale.US); // DateFormat monthDayFormat = new SimpleDateFormat("dd MMM",
// Locale.US);
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
todaysDate.add(Calendar.MONTH, -3); todaysDate.add(Calendar.MONTH, -3);
@@ -911,18 +854,15 @@ public class SchedulerJobsTestResults {
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
Float balance = Float.valueOf(MINIMUM_OPENING_BALANCE) Float balance = Float.valueOf(MINIMUM_OPENING_BALANCE) + Float.valueOf(FixedDepositAccountHelper.DEPOSIT_AMOUNT);
+ Float.valueOf(FixedDepositAccountHelper.DEPOSIT_AMOUNT); final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, String.valueOf(balance));
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec,
String.valueOf(balance));
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientId, final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientId, savingsProductID,
savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
Assertions.assertNotNull(savingsId); Assertions.assertNotNull(savingsId);
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
@@ -936,22 +876,18 @@ public class SchedulerJobsTestResults {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO); Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
Assertions.assertNotNull(fixedDepositProductId); Assertions.assertNotNull(fixedDepositProductId);
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
fixedDepositProductId.toString(), VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, savingsId.toString(), true, fixedDepositAccountHelper);
savingsId.toString(), true, fixedDepositAccountHelper);
Assertions.assertNotNull(fixedDepositAccountId); Assertions.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
.getStatusOfFixedDepositAccount(this.requestSpec, this.responseSpec, this.responseSpec, fixedDepositAccountId.toString());
fixedDepositAccountId.toString());
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap); FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE);
APPROVED_ON_DATE);
FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap); FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap);
fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE);
ACTIVATION_DATE);
FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap); FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap);
summary = savingsAccountHelper.getSavingsSummary(savingsId); summary = savingsAccountHelper.getSavingsSummary(savingsId);
balance = Float.valueOf(MINIMUM_OPENING_BALANCE); balance = Float.valueOf(MINIMUM_OPENING_BALANCE);
@@ -960,25 +896,23 @@ public class SchedulerJobsTestResults {
fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId); fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId);
HashMap fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId); HashMap fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId);
Float interestPosted = (Float) fixedDepositSummary.get("accountBalance") Float interestPosted = (Float) fixedDepositSummary.get("accountBalance") - Float.valueOf(FixedDepositAccountHelper.DEPOSIT_AMOUNT);
- Float.valueOf(FixedDepositAccountHelper.DEPOSIT_AMOUNT);
String JobName = "Transfer Interest To Savings"; String JobName = "Transfer Interest To Savings";
this.schedulerJobHelper.executeAndAwaitJob(JobName); this.schedulerJobHelper.executeAndAwaitJob(JobName);
fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId); fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId);
assertEquals(Float.valueOf(FixedDepositAccountHelper.DEPOSIT_AMOUNT), assertEquals(Float.valueOf(FixedDepositAccountHelper.DEPOSIT_AMOUNT), fixedDepositSummary.get("accountBalance"),
fixedDepositSummary.get("accountBalance"),
"Verifying opening Balance"); "Verifying opening Balance");
summary = savingsAccountHelper.getSavingsSummary(savingsId); summary = savingsAccountHelper.getSavingsSummary(savingsId);
balance = Float.valueOf(MINIMUM_OPENING_BALANCE) + interestPosted; balance = Float.valueOf(MINIMUM_OPENING_BALANCE) + interestPosted;
validateNumberForEqualExcludePrecission(String.valueOf(balance), validateNumberForEqualExcludePrecission(String.valueOf(balance), String.valueOf(summary.get("accountBalance")));
String.valueOf(summary.get("accountBalance")));
} }
private Integer createSavingsProduct(final RequestSpecification requestSpec, private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String minOpenningBalance) { final String minOpenningBalance) {
// system.out.println("------------------------------CREATING NEW SAVINGS // system.out.println("------------------------------CREATING NEW
// SAVINGS
// PRODUCT ---------------------------------------"); // PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
final String savingsProductJSON = savingsProductHelper // final String savingsProductJSON = savingsProductHelper //
@@ -990,18 +924,19 @@ public class SchedulerJobsTestResults {
} }
private static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) { private static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) {
// system.out.println("------------------------------CREATING NEW SAVINGS // system.out.println("------------------------------CREATING NEW
// SAVINGS
// PRODUCT ---------------------------------------"); // PRODUCT ---------------------------------------");
final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() // final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() //
.withInterestPostingPeriodTypeAsQuarterly() // .withInterestPostingPeriodTypeAsQuarterly() //
.withInterestCalculationPeriodTypeAsDailyBalance() // .withInterestCalculationPeriodTypeAsDailyBalance() //
.withMinimumOpenningBalance(minOpenningBalance).withAccountingRuleAsCashBased(accounts) .withMinimumOpenningBalance(minOpenningBalance).withAccountingRuleAsCashBased(accounts).build();
.build();
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
} }
private Integer createLoanProduct(final String chargeId) { private Integer createLoanProduct(final String chargeId) {
// system.out.println("------------------------------CREATING NEW LOAN PRODUCT // system.out.println("------------------------------CREATING NEW LOAN
// PRODUCT
// ---------------------------------------"); // ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("15,000.00") // .withPrincipal("15,000.00") //
@@ -1016,8 +951,7 @@ public class SchedulerJobsTestResults {
return this.loanTransactionHelper.getLoanProductId(loanProductJSON); return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
} }
private Integer applyForLoanApplication(final String clientID, final String loanProductID, private Integer applyForLoanApplication(final String clientID, final String loanProductID, final String savingsID) {
final String savingsID) {
// system.out.println("--------------------------------APPLYING FOR LOAN // system.out.println("--------------------------------APPLYING FOR LOAN
// APPLICATION--------------------------------"); // APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
@@ -1038,38 +972,33 @@ public class SchedulerJobsTestResults {
} }
private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) { private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) {
// system.out.println("------------------------------CREATING NEW FIXED DEPOSIT // system.out.println("------------------------------CREATING NEW FIXED
// DEPOSIT
// PRODUCT ---------------------------------------"); // PRODUCT ---------------------------------------");
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.responseSpec);
final String fixedDepositProductJSON = fixedDepositProductHelper // final String fixedDepositProductJSON = fixedDepositProductHelper //
// .withAccountingRuleAsCashBased(accounts) // .withAccountingRuleAsCashBased(accounts)
.withPeriodRangeChart()// .withPeriodRangeChart()//
.build(validFrom, validTo); .build(validFrom, validTo);
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
responseSpec);
} }
private Integer applyForFixedDepositApplication(final String clientID, final String productID, private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom,
final String validFrom, final String validTo, final String submittedOnDate, final String validTo, final String submittedOnDate, final String penalInterestType, String savingsId,
final String penalInterestType, String savingsId, final boolean transferInterest, final boolean transferInterest, final FixedDepositAccountHelper fixedDepositAccountHelper) {
final FixedDepositAccountHelper fixedDepositAccountHelper) { // system.out.println("--------------------------------APPLYING FOR
// system.out.println("--------------------------------APPLYING FOR FIXED // FIXED
// DEPOSIT ACCOUNT --------------------------------"); // DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec)
this.responseSpec)
// //
.withSubmittedOnDate(submittedOnDate).withSavings(savingsId) .withSubmittedOnDate(submittedOnDate).withSavings(savingsId).transferInterest(true)
.transferInterest(true) .withLockinPeriodFrequency("1", FixedDepositAccountHelper.DAYS).build(clientID, productID, penalInterestType);
.withLockinPeriodFrequency("1", FixedDepositAccountHelper.DAYS) return fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec);
.build(clientID, productID, penalInterestType);
return fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON,
this.requestSpec, this.responseSpec);
} }
private void validateNumberForEqualExcludePrecission(String val, String val2) { private void validateNumberForEqualExcludePrecission(String val, String val2) {
DecimalFormat twoDForm = new DecimalFormat("#", new DecimalFormatSymbols(Locale.US)); DecimalFormat twoDForm = new DecimalFormat("#", new DecimalFormatSymbols(Locale.US));
Assertions.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val))) Assertions.assertTrue(
.compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0); Float.valueOf(twoDForm.format(Float.valueOf(val))).compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0);
} }
} }
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" }) @SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" })
public class SkipRepaymentOnMonthFirstTest { public class SkipRepaymentOnMonthFirstTest {
private final static Logger LOG = LoggerFactory.getLogger(SkipRepaymentOnMonthFirstTest.class); private final static Logger LOG = LoggerFactory.getLogger(SkipRepaymentOnMonthFirstTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -56,8 +57,7 @@ public class SkipRepaymentOnMonthFirstTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
} }
@@ -72,8 +72,8 @@ public class SkipRepaymentOnMonthFirstTest {
this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); this.responseSpec);
Assertions.assertNotNull(globalConfig); Assertions.assertNotNull(globalConfig);
String configName = "skip-repayment-on-first-day-of-month"; String configName = "skip-repayment-on-first-day-of-month";
@@ -82,8 +82,8 @@ public class SkipRepaymentOnMonthFirstTest {
for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) {
if (globalConfig.get(configIndex).get("name").equals(configName)) { if (globalConfig.get(configIndex).get("name").equals(configName)) {
String configId = globalConfig.get(configIndex).get("id").toString(); String configId = globalConfig.get(configIndex).get("id").toString();
Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration( Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
this.requestSpec, this.responseSpec, configId.toString(), newBooleanValue); this.responseSpec, configId.toString(), newBooleanValue);
Assertions.assertNotNull(updateConfigId); Assertions.assertNotNull(updateConfigId);
break; break;
} }
@@ -97,26 +97,23 @@ public class SkipRepaymentOnMonthFirstTest {
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true); Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
clientID.toString());
final String startDate = "15 September 2011"; final String startDate = "15 September 2011";
final String frequency = "3"; // Monthly final String frequency = "3"; // Monthly
final String interval = "1"; // Every One Moth final String interval = "1"; // Every One Moth
Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency, Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency, interval, null);
interval, null);
LOG.info("caladerId -------------------- {}", calendarID); LOG.info("caladerId -------------------- {}", calendarID);
final Integer loanProductID = createLoanProduct(); final Integer loanProductID = createLoanProduct();
final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID); final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID);
LOG.info("loanID---- {}", loanID); LOG.info("loanID---- {}", loanID);
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
this.responseSpec, loanID); loanID);
verifyLoanRepaymentSchedule(loanSchedule); verifyLoanRepaymentSchedule(loanSchedule);
} }
private Integer createLoanProduct() { private Integer createLoanProduct() {
LOG.info( LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
"------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -130,10 +127,8 @@ public class SkipRepaymentOnMonthFirstTest {
return this.loanTransactionHelper.getLoanProductId(loanProductJSON); return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
} }
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID, private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID, Integer clientID) {
Integer clientID) { LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info(
"--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -90,8 +90,8 @@ public class SystemCodeTest {
assertEquals(createResponseId, deleteResponseId, "Verify code deleted"); assertEquals(createResponseId, deleteResponseId, "Verify code deleted");
// verify code deleted // verify code deleted
final HashMap deletedCodeValues = (HashMap) CodeHelper final HashMap deletedCodeValues = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId,
.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId, ""); "");
Assertions.assertNotNull(deletedCodeValues); Assertions.assertNotNull(deletedCodeValues);
assertNull(deletedCodeValues.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId"); assertNull(deletedCodeValues.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId");
@@ -132,8 +132,8 @@ public class SystemCodeTest {
assertEquals(createResponseId, deleteResponseId, "Verify code deleted"); assertEquals(createResponseId, deleteResponseId, "Verify code deleted");
// verify code deleted // verify code deleted
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId,
deleteResponseId, ""); "");
Assertions.assertNotNull(deletedCodeAttributes); Assertions.assertNotNull(deletedCodeAttributes);
assertNull(deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId"); assertNull(deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId");
@@ -206,11 +206,10 @@ public class SystemCodeTest {
createCodeResponseId, createCodeValueResponseId1, ""); createCodeResponseId, createCodeValueResponseId1, "");
Assertions.assertNotNull(codeValuesAttributes1); Assertions.assertNotNull(codeValuesAttributes1);
assertEquals(createCodeValueResponseId1, assertEquals(createCodeValueResponseId1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME),
codeValuesAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME), "Verify value of codeValueId"); "Verify value of codeValueId");
assertEquals(codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME), assertEquals(codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME), "Verify value of code name");
"Verify value of code name");
assertEquals(codeDescription1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME), assertEquals(codeDescription1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME),
"Verify value of code description"); "Verify value of code description");
@@ -64,11 +64,13 @@ public class TemplateIntegrationTest {
ArrayList<?> get = Utils.performServerGet(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, ""); ArrayList<?> get = Utils.performServerGet(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, "");
final int entriesBeforeTest = get.size(); final int entriesBeforeTest = get.size();
final Integer id = Utils.performServerPost(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, new Gson().toJson(map), "resourceId"); final Integer id = Utils.performServerPost(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, new Gson().toJson(map),
"resourceId");
final String templateUrlForId = String.format(this.GET_TEMPLATE_ID_URL, id); final String templateUrlForId = String.format(this.GET_TEMPLATE_ID_URL, id);
final String getrequest2 = Utils.performServerGet(this.requestSpec, this.responseSpec, templateUrlForId, this.RESPONSE_ATTRIBUTE_NAME); final String getrequest2 = Utils.performServerGet(this.requestSpec, this.responseSpec, templateUrlForId,
this.RESPONSE_ATTRIBUTE_NAME);
Assertions.assertTrue(getrequest2.equals("foo")); Assertions.assertTrue(getrequest2.equals("foo"));
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class UserAdministrationTest { public class UserAdministrationTest {
private final static Logger LOG = LoggerFactory.getLogger(UserAdministrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(UserAdministrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -74,7 +75,8 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId); Assertions.assertNotNull(staffId);
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet", "resourceId"); final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet",
"resourceId");
Assertions.assertNotNull(userId); Assertions.assertNotNull(userId);
this.transientUsers.add(userId); this.transientUsers.add(userId);
@@ -94,7 +96,8 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId); Assertions.assertNotNull(staffId);
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet", "resourceId"); final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet",
"resourceId");
Assertions.assertNotNull(userId); Assertions.assertNotNull(userId);
this.transientUsers.add(userId); this.transientUsers.add(userId);
@@ -113,11 +116,13 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId); Assertions.assertNotNull(staffId);
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet", "resourceId"); final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet",
"resourceId");
Assertions.assertNotNull(userId); Assertions.assertNotNull(userId);
this.transientUsers.add(userId); this.transientUsers.add(userId);
final Integer userId2 = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "bilingual", "resourceId"); final Integer userId2 = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "bilingual",
"resourceId");
Assertions.assertNotNull(userId2); Assertions.assertNotNull(userId2);
this.transientUsers.add(userId2); this.transientUsers.add(userId2);
@@ -126,6 +131,7 @@ public class UserAdministrationTest {
Assertions.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage")); Assertions.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage"));
Assertions.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode")); Assertions.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode"));
} }
@Test @Test
public void testCreateNewUserBlocksDuplicateClientId() { public void testCreateNewUserBlocksDuplicateClientId() {
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
@@ -137,13 +143,16 @@ public class UserAdministrationTest {
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
final Integer userId = (Integer) UserHelper.createUserForSelfService(this.requestSpec, this.responseSpec, roleId, staffId, clientId, "resourceId"); final Integer userId = (Integer) UserHelper.createUserForSelfService(this.requestSpec, this.responseSpec, roleId, staffId, clientId,
"resourceId");
Assertions.assertNotNull(userId); Assertions.assertNotNull(userId);
this.transientUsers.add(userId); this.transientUsers.add(userId);
final List errors = (List) UserHelper.createUserForSelfService(this.requestSpec, expectStatusCode(403), roleId, staffId, clientId, "errors"); final List errors = (List) UserHelper.createUserForSelfService(this.requestSpec, expectStatusCode(403), roleId, staffId, clientId,
"errors");
Map reason = (Map) errors.get(0); Map reason = (Map) errors.get(0);
Assertions.assertEquals("Self Service User Id is already created. Go to Admin->Users to edit or delete the self-service user.", reason.get("defaultUserMessage")); Assertions.assertEquals("Self Service User Id is already created. Go to Admin->Users to edit or delete the self-service user.",
reason.get("defaultUserMessage"));
} }
} }
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class XBRLIntegrationTest { public class XBRLIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(XBRLIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(XBRLIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -52,6 +52,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClientEntityImportHandlerTest { public class ClientEntityImportHandlerTest {
private final static Logger LOG = LoggerFactory.getLogger(ClientEntityImportHandlerTest.class); private final static Logger LOG = LoggerFactory.getLogger(ClientEntityImportHandlerTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -110,17 +111,22 @@ public class ClientEntityImportHandlerTest {
Date validTill = simpleDateFormat.parse("14 May 2019"); Date validTill = simpleDateFormat.parse("14 May 2019");
firstClientRow.createCell(ClientEntityConstants.INCOPORATION_VALID_TILL_COL).setCellValue(validTill); firstClientRow.createCell(ClientEntityConstants.INCOPORATION_VALID_TILL_COL).setCellValue(validTill);
firstClientRow.createCell(ClientEntityConstants.MOBILE_NO_COL).setCellValue(Utils.randomNumberGenerator(7)); firstClientRow.createCell(ClientEntityConstants.MOBILE_NO_COL).setCellValue(Utils.randomNumberGenerator(7));
firstClientRow.createCell(ClientEntityConstants.CLIENT_TYPE_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_TYPES).getStringCellValue()); firstClientRow.createCell(ClientEntityConstants.CLIENT_TYPE_COL)
firstClientRow.createCell(ClientEntityConstants.CLIENT_CLASSIFICATION_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_CLASSIFICATION).getStringCellValue()); .setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_TYPES).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.CLIENT_CLASSIFICATION_COL)
.setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_CLASSIFICATION).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.INCOPORATION_NUMBER_COL).setCellValue(Utils.randomNumberGenerator(6)); firstClientRow.createCell(ClientEntityConstants.INCOPORATION_NUMBER_COL).setCellValue(Utils.randomNumberGenerator(6));
firstClientRow.createCell(ClientEntityConstants.MAIN_BUSINESS_LINE).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_MAIN_BUSINESS_LINE).getStringCellValue()); firstClientRow.createCell(ClientEntityConstants.MAIN_BUSINESS_LINE)
firstClientRow.createCell(ClientEntityConstants.CONSTITUTION_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CONSTITUTION_COL).getStringCellValue()); .setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_MAIN_BUSINESS_LINE).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.CONSTITUTION_COL)
.setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CONSTITUTION_COL).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.ACTIVE_COL).setCellValue("False"); firstClientRow.createCell(ClientEntityConstants.ACTIVE_COL).setCellValue("False");
Date submittedDate = simpleDateFormat.parse("28 September 2017"); Date submittedDate = simpleDateFormat.parse("28 September 2017");
firstClientRow.createCell(ClientEntityConstants.SUBMITTED_ON_COL).setCellValue(submittedDate); firstClientRow.createCell(ClientEntityConstants.SUBMITTED_ON_COL).setCellValue(submittedDate);
firstClientRow.createCell(ClientEntityConstants.ADDRESS_ENABLED).setCellValue("False"); firstClientRow.createCell(ClientEntityConstants.ADDRESS_ENABLED).setCellValue("False");
File directory=new File(System.getProperty("user.home")+File.separator+"Fineract"+File.separator+"bulkimport"+File.separator+"integration_tests"+File.separator+"importhandler"+File.separator+"client") ; File directory = new File(System.getProperty("user.home") + File.separator + "Fineract" + File.separator + "bulkimport"
+ File.separator + "integration_tests" + File.separator + "importhandler" + File.separator + "client");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
@@ -134,7 +134,8 @@ public class LoanImportHandlerTest {
String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5); String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5);
String paymentTypeDescription = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); String paymentTypeDescription = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15);
Integer outcome_payment_creation= PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, paymentTypeName, paymentTypeDescription, true,1); Integer outcome_payment_creation = PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, paymentTypeName,
paymentTypeDescription, true, 1);
Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type"); Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
@@ -145,7 +146,8 @@ public class LoanImportHandlerTest {
Row firstLoanRow = loanSheet.getRow(1); Row firstLoanRow = loanSheet.getRow(1);
firstLoanRow.createCell(LoanConstants.OFFICE_NAME_COL).setCellValue(office.getName()); firstLoanRow.createCell(LoanConstants.OFFICE_NAME_COL).setCellValue(office.getName());
firstLoanRow.createCell(LoanConstants.LOAN_TYPE_COL).setCellValue("Individual"); firstLoanRow.createCell(LoanConstants.LOAN_TYPE_COL).setCellValue("Individual");
firstLoanRow.createCell(LoanConstants.CLIENT_NAME_COL).setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")"); firstLoanRow.createCell(LoanConstants.CLIENT_NAME_COL)
.setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
firstLoanRow.createCell(LoanConstants.CLIENT_EXTERNAL_ID).setCellValue(externalId); firstLoanRow.createCell(LoanConstants.CLIENT_EXTERNAL_ID).setCellValue(externalId);
firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name")); firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name"));
firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName")); firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
@@ -159,16 +161,22 @@ public class LoanImportHandlerTest {
firstLoanRow.createCell(LoanConstants.PRINCIPAL_COL).setCellValue(loanProductJson.getFloat("principal")); firstLoanRow.createCell(LoanConstants.PRINCIPAL_COL).setCellValue(loanProductJson.getFloat("principal"));
firstLoanRow.createCell(LoanConstants.NO_OF_REPAYMENTS_COL).setCellValue(loanProductJson.getInt("numberOfRepayments")); firstLoanRow.createCell(LoanConstants.NO_OF_REPAYMENTS_COL).setCellValue(loanProductJson.getInt("numberOfRepayments"));
firstLoanRow.createCell(LoanConstants.REPAID_EVERY_COL).setCellValue(loanProductJson.getInt("repaymentEvery")); firstLoanRow.createCell(LoanConstants.REPAID_EVERY_COL).setCellValue(loanProductJson.getInt("repaymentEvery"));
firstLoanRow.createCell(LoanConstants.REPAID_EVERY_FREQUENCY_COL).setCellValue(loanProductJson.getString("repaymentFrequencyType.value")); firstLoanRow.createCell(LoanConstants.REPAID_EVERY_FREQUENCY_COL)
firstLoanRow.createCell(LoanConstants.LOAN_TERM_COL).setCellValue(loanProductJson.getInt("repaymentEvery") * loanProductJson.getInt("numberOfRepayments")); .setCellValue(loanProductJson.getString("repaymentFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.LOAN_TERM_FREQUENCY_COL).setCellValue(loanProductJson.getString("repaymentFrequencyType.value")); firstLoanRow.createCell(LoanConstants.LOAN_TERM_COL)
.setCellValue(loanProductJson.getInt("repaymentEvery") * loanProductJson.getInt("numberOfRepayments"));
firstLoanRow.createCell(LoanConstants.LOAN_TERM_FREQUENCY_COL)
.setCellValue(loanProductJson.getString("repaymentFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.NOMINAL_INTEREST_RATE_COL).setCellValue(loanProductJson.getDouble("interestRatePerPeriod")); firstLoanRow.createCell(LoanConstants.NOMINAL_INTEREST_RATE_COL).setCellValue(loanProductJson.getDouble("interestRatePerPeriod"));
firstLoanRow.createCell(LoanConstants.NOMINAL_INTEREST_RATE_FREQUENCY_COL).setCellValue(loanProductJson.getString("interestRateFrequencyType.value")); firstLoanRow.createCell(LoanConstants.NOMINAL_INTEREST_RATE_FREQUENCY_COL)
.setCellValue(loanProductJson.getString("interestRateFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.AMORTIZATION_COL).setCellValue(loanProductJson.getString("amortizationType.value")); firstLoanRow.createCell(LoanConstants.AMORTIZATION_COL).setCellValue(loanProductJson.getString("amortizationType.value"));
firstLoanRow.createCell(LoanConstants.INTEREST_METHOD_COL).setCellValue(loanProductJson.getString("interestType.value")); firstLoanRow.createCell(LoanConstants.INTEREST_METHOD_COL).setCellValue(loanProductJson.getString("interestType.value"));
firstLoanRow.createCell(LoanConstants.INTEREST_CALCULATION_PERIOD_COL).setCellValue(loanProductJson.getString("interestCalculationPeriodType.value")); firstLoanRow.createCell(LoanConstants.INTEREST_CALCULATION_PERIOD_COL)
.setCellValue(loanProductJson.getString("interestCalculationPeriodType.value"));
firstLoanRow.createCell(LoanConstants.ARREARS_TOLERANCE_COL).setCellValue(0); firstLoanRow.createCell(LoanConstants.ARREARS_TOLERANCE_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.REPAYMENT_STRATEGY_COL).setCellValue(loanProductJson.getString("transactionProcessingStrategyName")); firstLoanRow.createCell(LoanConstants.REPAYMENT_STRATEGY_COL)
.setCellValue(loanProductJson.getString("transactionProcessingStrategyName"));
firstLoanRow.createCell(LoanConstants.GRACE_ON_PRINCIPAL_PAYMENT_COL).setCellValue(0); firstLoanRow.createCell(LoanConstants.GRACE_ON_PRINCIPAL_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0); firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_CHARGED_COL).setCellValue(0); firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_CHARGED_COL).setCellValue(0);
@@ -178,8 +186,8 @@ public class LoanImportHandlerTest {
firstLoanRow.createCell(LoanConstants.REPAYMENT_TYPE_COL).setCellValue(paymentTypeName); firstLoanRow.createCell(LoanConstants.REPAYMENT_TYPE_COL).setCellValue(paymentTypeName);
String currentdirectory = new File("").getAbsolutePath(); String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+ File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"loan") ; + "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "loan");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
@@ -55,12 +55,8 @@ public class OfficeImportHandlerTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().build(); this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
.header("Authorization", this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@Test @Test
@@ -72,15 +68,17 @@ public class OfficeImportHandlerTest {
Sheet sheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME); Sheet sheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow = sheet.getRow(1); Row firstOfficeRow = sheet.getRow(1);
firstOfficeRow.createCell(OfficeConstants.OFFICE_NAME_COL).setCellValue(Utils.randomNameGenerator("Test_Off_", 6)); firstOfficeRow.createCell(OfficeConstants.OFFICE_NAME_COL).setCellValue(Utils.randomNameGenerator("Test_Off_", 6));
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_NAME_COL).setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue()); firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_NAME_COL)
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_ID_COL).setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_ID_COL).getNumericCellValue()); .setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue());
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_ID_COL)
.setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_ID_COL).getNumericCellValue());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date date = simpleDateFormat.parse("14 May 2001"); Date date = simpleDateFormat.parse("14 May 2001");
firstOfficeRow.createCell(OfficeConstants.OPENED_ON_COL).setCellValue(date); firstOfficeRow.createCell(OfficeConstants.OPENED_ON_COL).setCellValue(date);
String currentdirectory = new File("").getAbsolutePath(); String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+ File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"office"); + "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "office");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
@@ -127,33 +127,44 @@ public class SavingsImportHandlerTest {
Row firstSavingsRow = savingsSheet.getRow(1); Row firstSavingsRow = savingsSheet.getRow(1);
firstSavingsRow.createCell(SavingsConstants.OFFICE_NAME_COL).setCellValue(office.getName()); firstSavingsRow.createCell(SavingsConstants.OFFICE_NAME_COL).setCellValue(office.getName());
firstSavingsRow.createCell(SavingsConstants.SAVINGS_TYPE_COL).setCellValue("Individual"); firstSavingsRow.createCell(SavingsConstants.SAVINGS_TYPE_COL).setCellValue("Individual");
firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL).setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")"); firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL)
.setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
Sheet savingsProductSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME); Sheet savingsProductSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
firstSavingsRow.createCell(SavingsConstants.PRODUCT_COL).setCellValue(savingsProductSheet.getRow(1).getCell(1).getStringCellValue()); firstSavingsRow.createCell(SavingsConstants.PRODUCT_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(1).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.FIELD_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName")); firstSavingsRow.createCell(SavingsConstants.FIELD_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date date = simpleDateFormat.parse("13 May 2017"); Date date = simpleDateFormat.parse("13 May 2017");
firstSavingsRow.createCell(SavingsConstants.SUBMITTED_ON_DATE_COL).setCellValue(date); firstSavingsRow.createCell(SavingsConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.APPROVED_DATE_COL).setCellValue(date); firstSavingsRow.createCell(SavingsConstants.APPROVED_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.ACTIVATION_DATE_COL).setCellValue(date); firstSavingsRow.createCell(SavingsConstants.ACTIVATION_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.CURRENCY_COL).setCellValue(savingsProductSheet.getRow(1).getCell(10).getStringCellValue()); firstSavingsRow.createCell(SavingsConstants.CURRENCY_COL)
firstSavingsRow.createCell(SavingsConstants.DECIMAL_PLACES_COL).setCellValue(savingsProductSheet.getRow(1).getCell(11).getNumericCellValue()); .setCellValue(savingsProductSheet.getRow(1).getCell(10).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.IN_MULTIPLES_OF_COL).setCellValue(savingsProductSheet.getRow(1).getCell(12).getNumericCellValue()); firstSavingsRow.createCell(SavingsConstants.DECIMAL_PLACES_COL)
firstSavingsRow.createCell(SavingsConstants.NOMINAL_ANNUAL_INTEREST_RATE_COL).setCellValue(savingsProductSheet.getRow(1).getCell(2).getNumericCellValue()); .setCellValue(savingsProductSheet.getRow(1).getCell(11).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_COMPOUNDING_PERIOD_COL).setCellValue(savingsProductSheet.getRow(1).getCell(3).getStringCellValue()); firstSavingsRow.createCell(SavingsConstants.IN_MULTIPLES_OF_COL)
firstSavingsRow.createCell(SavingsConstants.INTEREST_POSTING_PERIOD_COL).setCellValue(savingsProductSheet.getRow(1).getCell(4).getStringCellValue()); .setCellValue(savingsProductSheet.getRow(1).getCell(12).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_COL).setCellValue(savingsProductSheet.getRow(1).getCell(5).getStringCellValue()); firstSavingsRow.createCell(SavingsConstants.NOMINAL_ANNUAL_INTEREST_RATE_COL)
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_DAYS_IN_YEAR_COL).setCellValue(savingsProductSheet.getRow(1).getCell(6).getStringCellValue()); .setCellValue(savingsProductSheet.getRow(1).getCell(2).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_COMPOUNDING_PERIOD_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(3).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_POSTING_PERIOD_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(4).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(5).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_DAYS_IN_YEAR_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(6).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.MIN_OPENING_BALANCE_COL).setCellValue(1000.0); firstSavingsRow.createCell(SavingsConstants.MIN_OPENING_BALANCE_COL).setCellValue(1000.0);
firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_COL).setCellValue(1); firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_COL).setCellValue(1);
firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_FREQUENCY_COL).setCellValue("Weeks"); firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_FREQUENCY_COL).setCellValue("Weeks");
firstSavingsRow.createCell(SavingsConstants.APPLY_WITHDRAWAL_FEE_FOR_TRANSFERS).setCellValue("False"); firstSavingsRow.createCell(SavingsConstants.APPLY_WITHDRAWAL_FEE_FOR_TRANSFERS).setCellValue("False");
firstSavingsRow.createCell(SavingsConstants.ALLOW_OVER_DRAFT_COL).setCellValue("False"); firstSavingsRow.createCell(SavingsConstants.ALLOW_OVER_DRAFT_COL).setCellValue("False");
firstSavingsRow.createCell(SavingsConstants.OVER_DRAFT_LIMIT_COL).setCellValue(savingsProductSheet.getRow(1).getCell(15).getNumericCellValue()); firstSavingsRow.createCell(SavingsConstants.OVER_DRAFT_LIMIT_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(15).getNumericCellValue());
String currentdirectory = new File("").getAbsolutePath(); String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+ File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"savings") ; + "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "savings");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
@@ -47,13 +47,8 @@ public class ClientEntityWorkbookPopulatorTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().build(); this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
.header("Authorization", this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@@ -55,6 +55,7 @@ public class LoanWorkbookPopulatorTest {
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
} }
@Test @Test
public void testLoanWorkbookPopulate() throws IOException { public void testLoanWorkbookPopulate() throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
@@ -85,9 +86,7 @@ public class LoanWorkbookPopulatorTest {
Assertions.assertNotNull(outcome_lp_creaion, "Could not create Loan Product"); Assertions.assertNotNull(outcome_lp_creaion, "Could not create Loan Product");
FundsResourceHandler fundsResourceHandler = new FundsResourceHandler(); FundsResourceHandler fundsResourceHandler = new FundsResourceHandler();
String jsonFund="{\n" + String jsonFund = "{\n" + "\t\"name\": \"" + Utils.randomNameGenerator("Fund_Name", 9) + "\"\n" + "}";
"\t\"name\": \""+Utils.randomNameGenerator("Fund_Name",9)+"\"\n" +
"}";
Integer outcome_fund_creation = fundsResourceHandler.createFund(jsonFund, requestSpec, responseSpec); Integer outcome_fund_creation = fundsResourceHandler.createFund(jsonFund, requestSpec, responseSpec);
Assertions.assertNotNull(outcome_fund_creation, "Could not create Fund"); Assertions.assertNotNull(outcome_fund_creation, "Could not create Fund");
@@ -96,7 +95,8 @@ public class LoanWorkbookPopulatorTest {
String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15);
Boolean isCashPayment = true; Boolean isCashPayment = true;
Integer position = 1; Integer position = 1;
Integer outcome_payment_creation= paymentTypeHelper.createPaymentType(requestSpec, responseSpec,name,description,isCashPayment,position); Integer outcome_payment_creation = paymentTypeHelper.createPaymentType(requestSpec, responseSpec, name, description, isCashPayment,
position);
Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type"); Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
Workbook workbook = loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy"); Workbook workbook = loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy");
@@ -35,6 +35,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class OfficeWorkBookPopulatorTest { public class OfficeWorkBookPopulatorTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -42,12 +43,8 @@ public class OfficeWorkBookPopulatorTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().build(); this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
.header("Authorization", this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@Test @Test
@@ -42,6 +42,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class SavingsWorkbookPopulateTest { public class SavingsWorkbookPopulateTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -32,15 +32,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It * Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}.
* takes care of creation of {@code BatchRequest} list and posting this list to * It takes care of creation of {@code BatchRequest} list and posting this list
* the server. * to the server.
* *
* @author Rishabh Shukla * @author Rishabh Shukla
* *
* @see org.apache.fineract.integrationtests.BatchApiTest * @see org.apache.fineract.integrationtests.BatchApiTest
*/ */
public class BatchHelper { public class BatchHelper {
private final static Logger LOG = LoggerFactory.getLogger(BatchHelper.class); private final static Logger LOG = LoggerFactory.getLogger(BatchHelper.class);
private static final String BATCH_API_URL = "/fineract-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER; private static final String BATCH_API_URL = "/fineract-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER;
private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true"; private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true";
@@ -190,14 +191,14 @@ public class BatchHelper {
} }
final String body = "{ \"officeId\": 1, \"firstname\": \"Petra\", \"lastname\": \"Yton\"," + "\"externalId\": \"" + externalId final String body = "{ \"officeId\": 1, \"firstname\": \"Petra\", \"lastname\": \"Yton\"," + "\"externalId\": \"" + externalId
+ "\", \"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en\"," + "\"active\": true, \"activationDate\": \"04 March 2010\", \"submittedOnDate\": \"04 March 2010\"}"; + "\", \"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en\","
+ "\"active\": true, \"activationDate\": \"04 March 2010\", \"submittedOnDate\": \"04 March 2010\"}";
br.setBody(body); br.setBody(body);
return br; return br;
} }
/** /**
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy} * {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy}
@@ -408,8 +409,8 @@ public class BatchHelper {
br.setReference(reference); br.setReference(reference);
br.setRelativeUrl("loans/$.loanId/transactions?command=repayment"); br.setRelativeUrl("loans/$.loanId/transactions?command=repayment");
br.setMethod("POST"); br.setMethod("POST");
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", " + br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", "
"\"transactionDate\": \"15 September 2013\", \"transactionAmount\": 500}"); + "\"transactionDate\": \"15 September 2013\", \"transactionAmount\": 500}");
return br; return br;
} }
@@ -29,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class CalendarHelper { public class CalendarHelper {
private final static Logger LOG = LoggerFactory.getLogger(CalendarHelper.class); private final static Logger LOG = LoggerFactory.getLogger(CalendarHelper.class);
private static final String BASE_URL = "/fineract-provider/api/v1/"; private static final String BASE_URL = "/fineract-provider/api/v1/";
private static final String PARENT_ENTITY_NAME = "groups/"; private static final String PARENT_ENTITY_NAME = "groups/";
@@ -26,7 +26,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class CenterDomain implements Comparable<CenterDomain> { public class CenterDomain implements Comparable<CenterDomain> {
private final static Logger LOG = LoggerFactory.getLogger(CenterDomain.class); private final static Logger LOG = LoggerFactory.getLogger(CenterDomain.class);
public static class Builder { public static class Builder {
private final Integer id; private final Integer id;
@@ -84,9 +86,9 @@ public class CenterDomain implements Comparable<CenterDomain> {
/* super(); */ /* super(); */
} }
private CenterDomain(final Integer id, final String accountNo, final Integer statusid, final String statuscode, final String statusvalue, final boolean active, private CenterDomain(final Integer id, final String accountNo, final Integer statusid, final String statuscode,
final String name, final String externalId, final Integer staffId, final Integer officeId, final String officeName, final String statusvalue, final boolean active, final String name, final String externalId, final Integer staffId,
final String hierarchy, final ArrayList<HashMap> groupMembers) { final Integer officeId, final String officeName, final String hierarchy, final ArrayList<HashMap> groupMembers) {
this.id = id; this.id = id;
this.accountNo = accountNo; this.accountNo = accountNo;
this.status = new HashMap<>(); this.status = new HashMap<>();
@@ -256,15 +258,11 @@ public class CenterDomain implements Comparable<CenterDomain> {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { return true; } if (obj == this) { return true; }
if (!(obj instanceof CenterDomain)) { if (!(obj instanceof CenterDomain)) { return false; }
return false;
}
CenterDomain cd = (CenterDomain) obj; CenterDomain cd = (CenterDomain) obj;
if (this.hashCode() == cd.hashCode()) { if (this.hashCode() == cd.hashCode()) { return true; }
return true;
}
return false; return false;
} }
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class CenterHelper { public class CenterHelper {
private final static Logger LOG = LoggerFactory.getLogger(CenterHelper.class); private final static Logger LOG = LoggerFactory.getLogger(CenterHelper.class);
private static final String CENTERS_URL = "/fineract-provider/api/v1/centers"; private static final String CENTERS_URL = "/fineract-provider/api/v1/centers";
@@ -122,8 +123,8 @@ public class CenterHelper {
HashMap groupMemberHashMap = new HashMap(); HashMap groupMemberHashMap = new HashMap();
groupMemberHashMap.put("groupMembers", groupMembers); groupMemberHashMap.put("groupMembers", groupMembers);
LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------", id); LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------", id);
HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL, HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL, new Gson().toJson(groupMemberHashMap),
new Gson().toJson(groupMemberHashMap), "changes"); "changes");
LOG.info("{}", hash.toString()); LOG.info("{}", hash.toString());
ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers"); ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers");
int[] ret = new int[arr.size()]; int[] ret = new int[arr.size()];
@@ -182,7 +183,8 @@ public class CenterHelper {
public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String centerId) { final String centerId) {
final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&" + Utils.TENANT_IDENTIFIER; final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&"
+ Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------ACTIVATE A CENTER---------------------------------------------"); LOG.info("---------------------------------ACTIVATE A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId"); return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId");
} }
@@ -257,8 +259,8 @@ public class CenterHelper {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix); return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
} }
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,
final String groupId, final Long staffId) { final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff"; + "&command=assignStaff";
LOG.info("---------------------------------Assign Staff---------------------------------------------"); LOG.info("---------------------------------Assign Staff---------------------------------------------");
@@ -96,8 +96,8 @@ public class ClientChargesTest {
* Revert the paid client charge transaction by passing the * Revert the paid client charge transaction by passing the
* clientChargePaidTransactionId and ensure the same is reverted. * clientChargePaidTransactionId and ensure the same is reverted.
*/ */
final Integer undoTrxnId = ClientHelper.revertClientChargeTransaction(this.requestSpec, this.responseSpec, final Integer undoTrxnId = ClientHelper.revertClientChargeTransaction(this.requestSpec, this.responseSpec, clientId.toString(),
clientId.toString(), clientChargePaidTransactionId); clientChargePaidTransactionId);
Assertions.assertNotNull(undoTrxnId); Assertions.assertNotNull(undoTrxnId);
isReversedTransaction(clientId.toString(), undoTrxnId.toString()); isReversedTransaction(clientId.toString(), undoTrxnId.toString());
/** /**
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClientHelper { public class ClientHelper {
private final static Logger LOG = LoggerFactory.getLogger(ClientHelper.class); private final static Logger LOG = LoggerFactory.getLogger(ClientHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -69,8 +70,7 @@ public class ClientHelper {
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public static Integer createClient(final RequestSpecification requestSpec, public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClient(requestSpec, responseSpec, "04 March 2011"); return createClient(requestSpec, responseSpec, "04 March 2011");
} }
@@ -82,79 +82,72 @@ public class ClientHelper {
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) { final String activationDate, final String officeId) {
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------"); LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(activationDate, officeId),
getTestClientAsJSON(activationDate, officeId), "clientId"); "clientId");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClientPending(requestSpec, responseSpec, "04 March 2014"); return createClientPending(requestSpec, responseSpec, "04 March 2014");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String submittedOnDate) { final String submittedOnDate) {
return createClientPending(requestSpec, responseSpec, submittedOnDate, "1"); return createClientPending(requestSpec, responseSpec, submittedOnDate, "1");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String submittedOnDate, final String officeId) { final String submittedOnDate, final String officeId) {
LOG.info( LOG.info("---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------");
"---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSONPending(submittedOnDate, officeId),
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, "clientId");
getTestClientAsJSONPending(submittedOnDate, officeId), "clientId");
} }
public Object createClientPendingWithError(final String jsonAttributeToGetBack) { public Object createClientPendingWithError(final String jsonAttributeToGetBack) {
LOG.info( LOG.info("---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------");
"---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------");
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL,
getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack); getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack);
} }
public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec, public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String registeredTableName) { final String registeredTableName) {
LOG.info( LOG.info("-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------");
"-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId"); getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClientAsPerson(requestSpec, responseSpec, "04 March 2011"); return createClientAsPerson(requestSpec, responseSpec, "04 March 2011");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate) { final String activationDate) {
return createClientAsPerson(requestSpec, responseSpec, activationDate, "1"); return createClientAsPerson(requestSpec, responseSpec, activationDate, "1");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate, final String officeId) { final String activationDate, final String officeId) {
LOG.info( LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId),
getTestPersonClientAsJSON(activationDate, officeId), "clientId"); "clientId");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011"); return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate) { final String activationDate) {
return createClientAsEntity(requestSpec, responseSpec, activationDate, "1"); return createClientAsEntity(requestSpec, responseSpec, activationDate, "1");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate, final String officeId) { final String activationDate, final String officeId) {
Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution") Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec)
.get("id"); .get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper
.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
LOG.info( LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
@@ -162,29 +155,27 @@ public class ClientHelper {
getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "clientId"); getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "clientId");
} }
public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientType, String jsonAttributeToGetBack) { final Integer clientType, String jsonAttributeToGetBack) {
final String activationDate = "04 March 2011"; final String activationDate = "04 March 2011";
final String officeId = "1"; final String officeId = "1";
LOG.info( LOG.info(
"---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------"); "---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
public static Object assignStaffToClient(final RequestSpecification requestSpec, public static Object assignStaffToClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, final String staffId) { final String clientId, final String staffId) {
final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER
+ Utils.TENANT_IDENTIFIER + "&command=assignStaff"; + "&command=assignStaff";
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------"); LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes");
assignStaffToClientAsJson(staffId), "changes");
} }
public static Integer getClientsStaffId(final RequestSpecification requestSpec, public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId) { final String clientId) {
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId"); return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
} }
@@ -283,8 +274,7 @@ public class ClientHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, final String clientType) {
final String clientType) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("officeId", officeId); map.put("officeId", officeId);
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5)); map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
@@ -306,17 +296,16 @@ public class ClientHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer generatedClientID) { final Integer generatedClientID) {
LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id"); final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT"); assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT");
} }
public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId,
final String clientId, final String jsonReturn) { final String jsonReturn) {
final String GET_CLIENT_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER; final String GET_CLIENT_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------GET A CLIENT---------------------------------------------"); LOG.info("---------------------------------GET A CLIENT---------------------------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn); return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn);
@@ -325,8 +314,8 @@ public class ClientHelper {
/* Client status is a map.So adding SuppressWarnings */ /* Client status is a map.So adding SuppressWarnings */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId) { final String clientId) {
return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status"); return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status");
} }
@@ -343,8 +332,7 @@ public class ClientHelper {
Integer clientClosureCodeId = (Integer) code.get("id"); Integer clientClosureCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientClosureReason" */ /* Retrieve/Create Code Values for the Code "ClientClosureReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, this.responseSpec);
this.responseSpec);
Integer closureReasonId = (Integer) codeValue.get("id"); Integer closureReasonId = (Integer) codeValue.get("id");
map.put("closureReasonId", closureReasonId.toString()); map.put("closureReasonId", closureReasonId.toString());
@@ -399,8 +387,8 @@ public class ClientHelper {
Integer clientRejectionReasonCodeId = (Integer) code.get("id"); Integer clientRejectionReasonCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientRejectReason" */ /* Retrieve/Create Code Values for the Code "ClientRejectReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId, HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId, this.requestSpec,
this.requestSpec, this.responseSpec); this.responseSpec);
Integer rejectionReasonId = (Integer) codeValue.get("id"); Integer rejectionReasonId = (Integer) codeValue.get("id");
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
@@ -431,8 +419,8 @@ public class ClientHelper {
Integer clientWithdrawReasonCodeId = (Integer) code.get("id"); Integer clientWithdrawReasonCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */ /* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, this.requestSpec,
this.requestSpec, this.responseSpec); this.responseSpec);
Integer withdrawalReasonId = (Integer) codeValue.get("id"); Integer withdrawalReasonId = (Integer) codeValue.get("id");
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
@@ -479,20 +467,17 @@ public class ClientHelper {
public HashMap<String, Object> closeClient(final Integer clientId) { public HashMap<String, Object> closeClient(final Integer clientId) {
LOG.info("--------------------------------- CLOSE CLIENT -------------------------------"); LOG.info("--------------------------------- CLOSE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
clientId);
} }
public HashMap<String, Object> reactivateClient(final Integer clientId) { public HashMap<String, Object> reactivateClient(final Integer clientId) {
LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
getReactivateClientAsJSON(), clientId);
} }
public HashMap<String, Object> rejectClient(final Integer clientId) { public HashMap<String, Object> rejectClient(final Integer clientId) {
LOG.info("--------------------------------- REJECT CLIENT -------------------------------"); LOG.info("--------------------------------- REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
clientId);
} }
public HashMap<String, Object> activateClient(final Integer clientId) { public HashMap<String, Object> activateClient(final Integer clientId) {
@@ -503,8 +488,7 @@ public class ClientHelper {
public HashMap<String, Object> withdrawClient(final Integer clientId) { public HashMap<String, Object> withdrawClient(final Integer clientId) {
LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------"); LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
getWithdrawClientAsJSON(), clientId);
} }
private String createClientOperationURL(final String command, final Integer clientId) { private String createClientOperationURL(final String command, final Integer clientId) {
@@ -523,113 +507,102 @@ public class ClientHelper {
getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId); getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId);
} }
public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId, public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId, final String jsonAttributeToGetBack,
final String jsonAttributeToGetBack, final String rejectedDate) { final String rejectedDate) {
LOG.info("----------------------------------UNDO REJECT CLIENT ----------------------------------"); LOG.info("----------------------------------UNDO REJECT CLIENT ----------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId), return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId),
getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack); getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack);
} }
public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId, public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId, final String jsonAttributeToGetBack,
final String jsonAttributeToGetBack, final String rejectedDate) { final String rejectedDate) {
LOG.info("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------"); LOG.info("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------");
return performClientActionsWithValidationErrors( return performClientActionsWithValidationErrors(createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack); getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack);
} }
public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId, public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId, final String jsonAttributeToGetBack) {
final String jsonAttributeToGetBack) {
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack); getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack);
} }
public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId, public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId, final String activationDate) {
final String activationDate) {
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(activationDate),
getActivateClientAsJSON(activationDate), clientId); clientId);
} }
private ArrayList<HashMap<String, Object>> performClientActionsWithValidationErrors(final String postURLForClient, private ArrayList<HashMap<String, Object>> performClientActionsWithValidationErrors(final String postURLForClient,
final String jsonToBeSent, final String jsonAttributeToGetBack) { final String jsonToBeSent, final String jsonAttributeToGetBack) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
final Integer clientId) { Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS);
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
CommonConstants.RESPONSE_STATUS);
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
return response; return response;
} }
public static Integer addChargesForClient(final RequestSpecification requestSpec, public static Integer addChargesForClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientId, final String request) { final Integer clientId, final String request) {
LOG.info("--------------------------------- ADD CHARGES FOR Client --------------------------------"); LOG.info("--------------------------------- ADD CHARGES FOR Client --------------------------------");
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public static String payChargesForClients(final RequestSpecification requestSpec, public static String payChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId, final Integer clientId, final Integer clientChargeId, final String json) {
final String json) {
LOG.info("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------"); LOG.info("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=paycharge&"
+ "?command=paycharge&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return response.get("transactionId") != null ? response.get("transactionId").toString() : null; return response.get("transactionId") != null ? response.get("transactionId").toString() : null;
} }
public static String waiveChargesForClients(final RequestSpecification requestSpec, public static String waiveChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId, final Integer clientId, final Integer clientChargeId, final String json) {
final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------"); LOG.info("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=waive&"
+ "?command=waive&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return response.get("transactionId").toString(); return response.get("transactionId").toString();
} }
public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, String clientChargeId) { final String clientId, String clientChargeId) {
LOG.info("---------------------------------UNDO TRANSACTION---------------------------------------------"); LOG.info("---------------------------------UNDO TRANSACTION---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId + "?command=undo&"
+ "?command=undo&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public static Object getClientCharge(final RequestSpecification requestSpec, public static Object getClientCharge(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, final String clientChargeId) { final String clientId, final String clientChargeId) {
LOG.info("---------------------------------GET CLIENT CHARGE---------------------------------------------"); LOG.info("---------------------------------GET CLIENT CHARGE---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?" final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding"); return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding");
} }
public static Boolean getClientTransactions(final RequestSpecification requestSpec, public static Boolean getClientTransactions(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, final String transactionId) { final String clientId, final String transactionId) {
LOG.info( LOG.info("---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------");
"---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------"); final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + "?"
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + Utils.TENANT_IDENTIFIER;
+ "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed"); return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed");
} }
public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException { public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel"); requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate" byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate" + "?"
+ "?" + Utils.TENANT_IDENTIFIER + "&legalFormType=" + clientsEntity + "&dateFormat=" + dateFormat); + Utils.TENANT_IDENTIFIER + "&legalFormType=" + clientsEntity + "&dateFormat=" + dateFormat);
InputStream inputStream = new ByteArrayInputStream(byteArray); InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook = new HSSFWorkbook(inputStream); Workbook workbook = new HSSFWorkbook(inputStream);
return workbook; return workbook;
@@ -638,8 +611,7 @@ public class ClientHelper {
public String getOutputTemplateLocation(final String importDocumentId) { public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec, return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
"/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
importDocumentId);
} }
public String importClientEntityTemplate(File file) { public String importClientEntityTemplate(File file) {
@@ -647,8 +619,7 @@ public class ClientHelper {
String dateFormat = "dd MMMM yyyy"; String dateFormat = "dd MMMM yyyy";
String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString(); String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString();
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec, responseSpec, return Utils.performServerTemplatePost(requestSpec, responseSpec, CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale, legalFormType, file, locale, dateFormat);
dateFormat);
} }
} }
@@ -18,7 +18,6 @@
*/ */
package org.apache.fineract.integrationtests.common; package org.apache.fineract.integrationtests.common;
public interface CommonConstants { public interface CommonConstants {
public final static String LOCALE = "en"; public final static String LOCALE = "en";
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class CurrenciesHelper { public class CurrenciesHelper {
private final static Logger LOG = LoggerFactory.getLogger(CurrenciesHelper.class); private final static Logger LOG = LoggerFactory.getLogger(CurrenciesHelper.class);
private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies"; private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies";
@@ -57,9 +58,7 @@ public class CurrenciesHelper {
final String code) { final String code) {
ArrayList<CurrencyDomain> currenciesList = getAllCurrencies(requestSpec, responseSpec); ArrayList<CurrencyDomain> currenciesList = getAllCurrencies(requestSpec, responseSpec);
for (CurrencyDomain e : currenciesList) { for (CurrencyDomain e : currenciesList) {
if (e.getCode().equals(code)) { if (e.getCode().equals(code)) { return e; }
return e;
}
} }
return null; return null;
} }
@@ -57,8 +57,8 @@ public class CurrencyDomain implements Comparable<CurrencyDomain> {
super(); super();
} }
private CurrencyDomain(final String code, final String name, final int decimalPlaces, final String displaySymbol, private CurrencyDomain(final String code, final String name, final int decimalPlaces, final String displaySymbol, final String nameCode,
final String nameCode, final String displayLabel) { final String displayLabel) {
super(); super();
this.code = code; this.code = code;
this.name = name; this.name = name;
@@ -135,9 +135,7 @@ public class CurrencyDomain implements Comparable<CurrencyDomain> {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { return true; } if (obj == this) { return true; }
if (!(obj instanceof CurrencyDomain)) { if (!(obj instanceof CurrencyDomain)) { return false; }
return false;
}
CurrencyDomain cd = (CurrencyDomain) obj; CurrencyDomain cd = (CurrencyDomain) obj;
@@ -29,27 +29,27 @@ public class ExternalServicesConfigurationHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName( public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(final RequestSpecification requestSpec,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final ResponseSpecification responseSpec, final String serviceName) {
final String serviceName) { final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?"
final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + Utils.TENANT_IDENTIFIER;
+ serviceName + "?" + Utils.TENANT_IDENTIFIER; // system.out.println("------------------------ RETRIEVING GLOBAL
// system.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION // CONFIGURATION
// BY ID -------------------------"); // BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, "");
} }
public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec, public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) { final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) {
final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?"
+ "?" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------UPDATE VALUE FOR GLOBAL // system.out.println("---------------------------------UPDATE VALUE FOR
// GLOBAL
// CONFIG---------------------------------------------"); // CONFIG---------------------------------------------");
HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL, HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL,
updateExternalServicesConfigUpdateValueAsJSON(name, value), ""); updateExternalServicesConfigUpdateValueAsJSON(name, value), "");
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class GlobalConfigurationHelper { public class GlobalConfigurationHelper {
private final static Logger LOG = LoggerFactory.getLogger(GlobalConfigurationHelper.class); private final static Logger LOG = LoggerFactory.getLogger(GlobalConfigurationHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -38,10 +39,12 @@ public class GlobalConfigurationHelper {
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public static ArrayList<HashMap> getAllGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList<HashMap> getAllGlobalConfigurations(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER; final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------"); LOG.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------");
final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, ""); final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL,
"");
return response.get("globalConfiguration"); return response.get("globalConfiguration");
} }
@@ -52,7 +55,8 @@ public class GlobalConfigurationHelper {
return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, "");
} }
public static void resetAllDefaultGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static void resetAllDefaultGlobalConfigurations(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
final ArrayList<HashMap> defaults = getAllDefaultGlobalConfigurations(); final ArrayList<HashMap> defaults = getAllDefaultGlobalConfigurations();
for (HashMap configDefault : defaults) { for (HashMap configDefault : defaults) {
@@ -66,16 +70,20 @@ public class GlobalConfigurationHelper {
continue; continue;
} }
// Currently only values and enabled flags are modified by the integration test suite. // Currently only values and enabled flags are modified by the
// If any other column is modified by the integration test suite in the future, it needs to be reset here. // integration test suite.
// If any other column is modified by the integration test suite in
// the future, it needs to be reset here.
final Integer configDefaultId = (Integer) configDefault.get("id"); final Integer configDefaultId = (Integer) configDefault.get("id");
final Integer configDefaultValue = (Integer) configDefault.get("value"); final Integer configDefaultValue = (Integer) configDefault.get("value");
updateValueForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), configDefaultValue.toString()); updateValueForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), configDefaultValue.toString());
updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), (Boolean)configDefault.get("enabled")); updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(),
(Boolean) configDefault.get("enabled"));
} }
} }
public static void verifyAllDefaultGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static void verifyAllDefaultGlobalConfigurations(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
ArrayList<HashMap> expectedGlobalConfigurations = getAllDefaultGlobalConfigurations(); ArrayList<HashMap> expectedGlobalConfigurations = getAllDefaultGlobalConfigurations();
ArrayList<HashMap> actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec); ArrayList<HashMap> actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec);
@@ -92,19 +100,26 @@ public class GlobalConfigurationHelper {
Assertions.assertEquals(expectedGlobalConfiguration.get("id"), actualGlobalConfiguration.get("id")); Assertions.assertEquals(expectedGlobalConfiguration.get("id"), actualGlobalConfiguration.get("id"));
final String assertionFailedMessage = "Assertion failed for configID:<" + expectedGlobalConfiguration.get("id") + ">"; final String assertionFailedMessage = "Assertion failed for configID:<" + expectedGlobalConfiguration.get("id") + ">";
Assertions.assertEquals(expectedGlobalConfiguration.get("name"), actualGlobalConfiguration.get("name"), assertionFailedMessage); Assertions.assertEquals(expectedGlobalConfiguration.get("name"), actualGlobalConfiguration.get("name"), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.get("value"), assertionFailedMessage); Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.get("value"),
Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.get("enabled"), assertionFailedMessage); assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.get("trapDoor"), assertionFailedMessage); Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.get("enabled"),
assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.get("trapDoor"),
assertionFailedMessage);
} }
} }
/** /**
* Helper method to get the current default instance data of the /configurations endpoint. * Helper method to get the current default instance data of the
* Used to reset and verify that no global configuration affects state between integration tests. * /configurations endpoint. Used to reset and verify that no global
* @see <a href="https://issues.apache.org/jira/browse/FINERACT-722">FINERACT-722</a> * configuration affects state between integration tests.
* This is a quick, fail fast and early implementation to resolve this issue. *
* TODO: A more robust future solution would be isolating all integration test state using Spring Framework's * @see <a href=
* integration test infrastructure for transaction commits and rollbacks. * "https://issues.apache.org/jira/browse/FINERACT-722">FINERACT-722</a>
* This is a quick, fail fast and early implementation to resolve this
* issue. TODO: A more robust future solution would be isolating all
* integration test state using Spring Framework's integration test
* infrastructure for transaction commits and rollbacks.
*/ */
private static ArrayList<HashMap> getAllDefaultGlobalConfigurations() { private static ArrayList<HashMap> getAllDefaultGlobalConfigurations() {
@@ -370,11 +385,12 @@ public class GlobalConfigurationHelper {
} }
public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec, public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled,
final String jsonAttributeToGetBack) {
final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------"); LOG.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, updatePasswordResetDaysGlobalConfigAsJSON(value, enabled),
updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack); jsonAttributeToGetBack);
} }
public static String updateGlobalConfigUpdateValueAsJSON(final String value) { public static String updateGlobalConfigUpdateValueAsJSON(final String value) {
@@ -70,25 +70,25 @@ public class GroupHelper {
jsonAttributeToGetBack); jsonAttributeToGetBack);
} }
public static Integer createGroupPendingWithDatatable(final RequestSpecification requestSpec, public static Integer createGroupPendingWithDatatable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String registeredTableName) { final String registeredTableName) {
LOG.info("-------------------------- CREATING A GROUP WITH DATATABLES --------------------------------"); LOG.info("-------------------------- CREATING A GROUP WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL, getTestGroupWithDatatableAsJson(registeredTableName),
getTestGroupWithDatatableAsJson(registeredTableName), "groupId"); "groupId");
} }
public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final String clientMember) { final String groupId, final String clientMember) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?command=associateClients&"
+ "?command=associateClients&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------Associate Client To A GROUP---------------------------------------------"); LOG.info("---------------------------------Associate Client To A GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
} }
public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final String clientMember) { final String groupId, final String clientMember) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?command=disassociateClients&"
+ "?command=disassociateClients&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------Disassociate Client To A GROUP---------------------------------------------"); LOG.info("---------------------------------Disassociate Client To A GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
} }
@@ -107,23 +107,29 @@ public class GroupHelper {
return Utils.performServerPut(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, updateGroupAsJSON(name), "groupId"); return Utils.performServerPut(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, updateGroupAsJSON(name), "groupId");
} }
public static Integer deleteGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId) { public static Integer deleteGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER; final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------DELETE GROUP---------------------------------------------"); LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId"); return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId");
} }
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,final Long staffId){ public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff"; final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
LOG.info("---------------------------------DELETE GROUP---------------------------------------------"); LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, assignStaffAsJSON(staffId), "changes"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, assignStaffAsJSON(staffId), "changes");
} }
public static Object assignStaffInheritStaffForClientAccounts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,final String staffId){
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff";
LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,assignStaffAndInheritStaffForClientAccountsAsJSON(staffId),"changes");
}
public static Object assignStaffInheritStaffForClientAccounts(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String groupId, final String staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,
assignStaffAndInheritStaffForClientAccountsAsJSON(staffId), "changes");
}
public static String getTestGroupAsJSON(final boolean active, final String activationDate) { public static String getTestGroupAsJSON(final boolean active, final String activationDate) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
@@ -173,12 +179,14 @@ public class GroupHelper {
LOG.debug("map : {}", map); LOG.debug("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String assignStaffAsJSON(final Long staffId) { public static String assignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
LOG.debug("map : {}", map); LOG.debug("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String assignStaffAndInheritStaffForClientAccountsAsJSON(final String staffId) { public static String assignStaffAndInheritStaffForClientAccountsAsJSON(final String staffId) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
@@ -187,7 +195,6 @@ public class GroupHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedGroupID) { final Integer generatedGroupID) {
LOG.info("------------------------------CHECK GROUP DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK GROUP DETAILS------------------------------------\n");
@@ -216,8 +223,8 @@ public class GroupHelper {
final Integer generatedGroupID, final Integer groupMember) { final Integer generatedGroupID, final Integer groupMember) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP MEMBERS------------------------------------\n"); LOG.info("------------------------------CHECK GROUP MEMBERS------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&"
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers"); list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
LOG.debug("the list of verifyEmptyGroupMembers : {} ", list); LOG.debug("the list of verifyEmptyGroupMembers : {} ", list);
assertTrue(list.toString().contains("id=" + groupMember.toString()), "ERROR IN GROUP MEMBER"); assertTrue(list.toString().contains("id=" + groupMember.toString()), "ERROR IN GROUP MEMBER");
@@ -227,8 +234,8 @@ public class GroupHelper {
final Integer generatedGroupID) { final Integer generatedGroupID) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n"); LOG.info("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&"
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers"); list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
LOG.debug("the list of verifyEmptyGroupMembers : {} ", list); LOG.debug("the list of verifyEmptyGroupMembers : {} ", list);
assertEquals(list, null, "GROUP MEMBER LIST NOT EMPTY"); assertEquals(list, null, "GROUP MEMBER LIST NOT EMPTY");
@@ -244,8 +251,8 @@ public class GroupHelper {
} }
// Glim_Gsim_testing // Glim_Gsim_testing
public static List<String> verifyRetrieveGlimAccountsByGroupId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static List<String> verifyRetrieveGlimAccountsByGroupId(final RequestSpecification requestSpec,
final Integer groupID) { final ResponseSpecification responseSpec, final Integer groupID) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n"); LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + groupID + "/glimaccounts?" + Utils.TENANT_IDENTIFIER; final String GROUP_URL = "/fineract-provider/api/v1/groups/" + groupID + "/glimaccounts?" + Utils.TENANT_IDENTIFIER;
@@ -254,8 +261,8 @@ public class GroupHelper {
return list; return list;
} }
public static List<String> verifyRetrieveGlimAccountsByGlimId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static List<String> verifyRetrieveGlimAccountsByGlimId(final RequestSpecification requestSpec,
final Integer glimId) { final ResponseSpecification responseSpec, final Integer glimId) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n"); LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" + Utils.TENANT_IDENTIFIER; final String GROUP_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" + Utils.TENANT_IDENTIFIER;
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class HolidayHelper { public class HolidayHelper {
private final static Logger LOG = LoggerFactory.getLogger(HolidayHelper.class); private final static Logger LOG = LoggerFactory.getLogger(HolidayHelper.class);
private static final String HOLIDAYS_URL = "/fineract-provider/api/v1/holidays"; private static final String HOLIDAYS_URL = "/fineract-provider/api/v1/holidays";
private static final String CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
@@ -74,7 +75,8 @@ public class HolidayHelper {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOLIDAY_URL, getCreateHolidayDataAsJSON(), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOLIDAY_URL, getCreateHolidayDataAsJSON(), "resourceId");
} }
public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String holidayID) { public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String holidayID) {
final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER; final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId");
} }
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class HookHelper { public class HookHelper {
private final static Logger LOG = LoggerFactory.getLogger(HookHelper.class); private final static Logger LOG = LoggerFactory.getLogger(HookHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -43,8 +44,7 @@ public class HookHelper {
public Integer createHook(final String payloadURL) { public Integer createHook(final String payloadURL) {
LOG.info("---------------------------------CREATING A HOOK---------------------------------------------"); LOG.info("---------------------------------CREATING A HOOK---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId");
"resourceId");
} }
public String getTestHookAsJson(final String payloadURL) { public String getTestHookAsJson(final String payloadURL) {
@@ -88,7 +88,8 @@ public class HookHelper {
public void verifyUpdateHook(final String updateURL, final Long hookId) { public void verifyUpdateHook(final String updateURL, final Long hookId) {
LOG.info("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
ArrayList<HashMap<String, String>> map = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, this.responseSpec, GET_URL, "config"); ArrayList<HashMap<String, String>> map = Utils.<ArrayList<HashMap<String, String>>> performServerGet(this.requestSpec,
this.responseSpec, GET_URL, "config");
HashMap<String, String> hash = map.get(1); HashMap<String, String> hash = map.get(1);
assertEquals(updateURL, hash.get("fieldValue")); assertEquals(updateURL, hash.get("fieldValue"));
} }
@@ -97,7 +98,8 @@ public class HookHelper {
LOG.info("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build(); ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build();
ArrayList<HashMap<String, String>> array = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, responseSpec404, GET_URL, "errors"); ArrayList<HashMap<String, String>> array = Utils.<ArrayList<HashMap<String, String>>> performServerGet(this.requestSpec,
responseSpec404, GET_URL, "errors");
HashMap<String, String> map = array.get(0); HashMap<String, String> map = array.get(0);
assertEquals("error.msg.hook.identifier.not.found", map.get("userMessageGlobalisationCode")); assertEquals("error.msg.hook.identifier.not.found", map.get("userMessageGlobalisationCode"));
} }
@@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ImageHelper { public class ImageHelper {
private final static Logger LOG = LoggerFactory.getLogger(ImageHelper.class); private final static Logger LOG = LoggerFactory.getLogger(ImageHelper.class);
private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/"; private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/";
private static final String IMAGES_URI = "/images"; private static final String IMAGES_URI = "/images";
@@ -59,7 +60,8 @@ public class ImageHelper {
return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL); return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL);
} }
public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer staffId) {
LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId");
@@ -24,6 +24,7 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
public class LoanRescheduleRequestHelper { public class LoanRescheduleRequestHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -24,6 +24,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class NotificationHelper { public class NotificationHelper {
private final static Logger LOG = LoggerFactory.getLogger(NotificationHelper.class); private final static Logger LOG = LoggerFactory.getLogger(NotificationHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -32,9 +32,8 @@ public class OfficeDomain {
private String[] openingDate; private String[] openingDate;
private String hierarchy; private String hierarchy;
private Builder(final int id, final String name, private Builder(final int id, final String name, final String nameDecorated, final String externalId, final String[] openingDate,
final String nameDecorated, final String externalId, final String hierarchy) {
final String[] openingDate, final String hierarchy) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.nameDecorated = nameDecorated; this.nameDecorated = nameDecorated;
@@ -44,8 +43,7 @@ public class OfficeDomain {
} }
public OfficeDomain build() { public OfficeDomain build() {
return new OfficeDomain(this.id, this.name, this.nameDecorated, return new OfficeDomain(this.id, this.name, this.nameDecorated, this.externalId, this.openingDate, this.hierarchy);
this.externalId, this.openingDate, this.hierarchy);
} }
} }
@@ -60,9 +58,8 @@ public class OfficeDomain {
super(); super();
} }
private OfficeDomain(final int id, final String name, private OfficeDomain(final int id, final String name, final String nameDecorated, final String externalId, final String[] openingDate,
final String nameDecorated, final String externalId, final String hierarchy) {
final String[] openingDate, final String hierarchy) {
super(); super();
this.id = id; this.id = id;
this.name = name; this.name = name;
@@ -80,11 +77,9 @@ public class OfficeDomain {
return new Gson().fromJson(jsonData, OfficeDomain.class); return new Gson().fromJson(jsonData, OfficeDomain.class);
} }
public static Builder create(final int id, final String name, public static Builder create(final int id, final String name, final String nameDecorated, final String externalId,
final String nameDecorated, final String externalId,
final String[] openingDate, final String hierarchy) { final String[] openingDate, final String hierarchy) {
return new Builder(id, name, nameDecorated, externalId, openingDate, return new Builder(id, name, nameDecorated, externalId, openingDate, hierarchy);
hierarchy);
} }
public int getId() { public int getId() {
@@ -139,20 +134,14 @@ public class OfficeDomain {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) { return true; }
return true;
}
if (!(obj instanceof OfficeDomain)) { if (!(obj instanceof OfficeDomain)) { return false; }
return false;
}
OfficeDomain od = (OfficeDomain) obj; OfficeDomain od = (OfficeDomain) obj;
if (this.id == od.getId() && this.name.equals(od.getName()) if (this.id == od.getId() && this.name.equals(od.getName()) && this.nameDecorated.equals(od.getName())
&& this.nameDecorated.equals(od.getName()) && this.externalId.equals(od.getExternalId()) && Arrays.equals(this.openingDate, od.getOpeningDate())
&& this.externalId.equals(od.getExternalId())
&& Arrays.equals(this.openingDate, od.getOpeningDate())
&& this.hierarchy.equals(od.getHierarchy())) { && this.hierarchy.equals(od.getHierarchy())) {
return true; return true;
} }
@@ -35,30 +35,26 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class OfficeHelper { public class OfficeHelper {
private final static Logger LOG = LoggerFactory.getLogger(OfficeHelper.class); private final static Logger LOG = LoggerFactory.getLogger(OfficeHelper.class);
private static final String OFFICE_URL = "/fineract-provider/api/v1/offices"; private static final String OFFICE_URL = "/fineract-provider/api/v1/offices";
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public OfficeHelper(final RequestSpecification requestSpec, public OfficeHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public OfficeDomain retrieveOfficeByID(int id) { public OfficeDomain retrieveOfficeByID(int id) {
Object get = Utils.performServerGet( Object get = Utils.performServerGet(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER, "");
requestSpec, responseSpec, OFFICE_URL + "/" + id + "?"
+ Utils.TENANT_IDENTIFIER, "");
final String json = new Gson().toJson(get); final String json = new Gson().toJson(get);
return new Gson().fromJson(json, new TypeToken<OfficeDomain>() { return new Gson().fromJson(json, new TypeToken<OfficeDomain>() {}.getType());
}.getType());
} }
public Integer createOffice(final String openingDate) { public Integer createOffice(final String openingDate) {
String json = getAsJSON(openingDate); String json = getAsJSON(openingDate);
return Utils.performServerPost(this.requestSpec, this.responseSpec, return Utils.performServerPost(this.requestSpec, this.responseSpec, OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
@@ -71,8 +67,7 @@ public class OfficeHelper {
LOG.info("map : {}", map); LOG.info("map : {}", map);
return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER,
+ "/" + id + "?" + Utils.TENANT_IDENTIFIER,
new Gson().toJson(map), "resourceId"); new Gson().toJson(map), "resourceId");
} }
@@ -98,13 +93,14 @@ public class OfficeHelper {
public String getOutputTemplateLocation(final String importDocumentId) { public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?" return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
+Utils.TENANT_IDENTIFIER,importDocumentId); "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
} }
public Workbook getOfficeWorkBook(final String dateFormat) throws IOException { public Workbook getOfficeWorkBook(final String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel"); requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte[] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,OFFICE_URL+"/downloadtemplate"+"?"+ byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec,
Utils.TENANT_IDENTIFIER+"&dateFormat="+dateFormat); OFFICE_URL + "/downloadtemplate" + "?" + Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
InputStream inputStream = new ByteArrayInputStream(byteArray); InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook = new HSSFWorkbook(inputStream); Workbook workbook = new HSSFWorkbook(inputStream);
return workbook; return workbook;
@@ -27,8 +27,8 @@ public class PasswordPreferencesHelper {
private static final String PASSWORD_PREFERENCES_URL = "/fineract-provider/api/v1/passwordpreferences"; private static final String PASSWORD_PREFERENCES_URL = "/fineract-provider/api/v1/passwordpreferences";
public static Object updatePasswordPreferences(final RequestSpecification requestSpec, public static Object updatePasswordPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, String validationPolicyId) { String validationPolicyId) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------UPDATE PASSWORD // system.out.println("---------------------------------UPDATE PASSWORD
// PREFERENCE---------------------------------------------"); // PREFERENCE---------------------------------------------");
@@ -40,9 +40,11 @@ public class PasswordPreferencesHelper {
final ResponseSpecification responseSpec, String invalidValidationPolicyId, String jsonAttributeToGetback) { final ResponseSpecification responseSpec, String invalidValidationPolicyId, String jsonAttributeToGetback) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
// system.out // system.out
//.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------"); // .println("---------------------------------UPDATE PASSWORD
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId), // PREFERENCES WITH INVALID
jsonAttributeToGetback); // ID-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL,
updatePreferencesWithInvalidId(invalidValidationPolicyId), jsonAttributeToGetback);
} }
public static String updatePreferencesAsJson(String validationPolicyId) { public static String updatePreferencesAsJson(String validationPolicyId) {
@@ -57,17 +59,15 @@ public class PasswordPreferencesHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static int getActivePasswordPreference(final RequestSpecification requestSpec, public static int getActivePasswordPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) { return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id");
return Utils.performServerGet(requestSpec, responseSpec,
PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id");
} }
public static HashMap<String, Object> getAllPreferences(final RequestSpecification requestSpec, public static HashMap<String, Object> getAllPreferences(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER,
PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER, ""); "");
} }
@@ -29,21 +29,20 @@ import java.util.HashMap;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class PaymentTypeHelper { public class PaymentTypeHelper {
private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?" private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes"; private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes";
public static Integer createPaymentType(final RequestSpecification requestSpec, public static Integer createPaymentType(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String name, final String description, final String name, final String description, final Boolean isCashPayment, final Integer position) {
final Boolean isCashPayment, final Integer position) { // system.out.println("---------------------------------CREATING A
// system.out.println("---------------------------------CREATING A PAYMENT // PAYMENT
// TYPE---------------------------------------------"); // TYPE---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL,
getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId"); getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId");
} }
public static String getJsonToCreatePaymentType(final String name, final String description, public static String getJsonToCreatePaymentType(final String name, final String description, final Boolean isCashPayment,
final Boolean isCashPayment, final Integer position) { final Integer position) {
HashMap hm = new HashMap(); HashMap hm = new HashMap();
hm.put("name", name); hm.put("name", name);
if (description != null) { if (description != null) {
@@ -59,14 +58,12 @@ public class PaymentTypeHelper {
return new Gson().toJson(hm); return new Gson().toJson(hm);
} }
public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer generatedPaymentTypeID) { final Integer generatedPaymentTypeID) {
// system.out.println("------------------------------CHECK PAYMENT // system.out.println("------------------------------CHECK PAYMENT
// DETAILS------------------------------------\n"); // DETAILS------------------------------------\n");
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER; final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id");
final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL,
"id");
assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN CREATING THE PAYMENT TYPE"); assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN CREATING THE PAYMENT TYPE");
} }
@@ -77,25 +74,26 @@ public class PaymentTypeHelper {
// TYPE---------------------------------------------"); // TYPE---------------------------------------------");
Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, ""); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "");
final String jsonData = new Gson().toJson(get); final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() { return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() {}.getType());
}.getType());
} }
public static HashMap<String, String> updatePaymentType(final int id, HashMap request, public static HashMap<String, String> updatePaymentType(final int id, HashMap request, final RequestSpecification requestSpec,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------UPDATE PAYMENT TYPE " + // system.out.println("---------------------------------UPDATE PAYMENT
// TYPE " +
// id + "---------------------------------------------"); // id + "---------------------------------------------");
HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL, HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL, new Gson().toJson(request),
new Gson().toJson(request), "changes"); "changes");
return hash; return hash;
} }
public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec, public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------DELETING PAYMENT TYPE " // system.out.println("---------------------------------DELETING PAYMENT
// TYPE "
// + id + "--------------------------------------------"); // + id + "--------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId");
} }
@@ -49,6 +49,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class ProvisioningIntegrationTest { public class ProvisioningIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ProvisioningIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(ProvisioningIntegrationTest.class);
private static final String NONE = "1"; private static final String NONE = "1";
private final static int LOANPRODUCTS_SIZE = 10; private final static int LOANPRODUCTS_SIZE = 10;
@@ -43,6 +43,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class SchedulerJobHelper { public class SchedulerJobHelper {
private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class); private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification response200Spec; private final ResponseSpecification response200Spec;
@@ -133,12 +134,17 @@ public class SchedulerJobHelper {
return (Integer) allSchedulerJobsData.get(jobIndex).get("jobId"); return (Integer) allSchedulerJobsData.get(jobIndex).get("jobId");
} }
} }
throw new IllegalArgumentException("No such named Job (see org.apache.fineract.infrastructure.jobs.service.JobName enum):" + jobName); throw new IllegalArgumentException(
"No such named Job (see org.apache.fineract.infrastructure.jobs.service.JobName enum):" + jobName);
} }
/** /**
* Launches a Job and awaits its completion. * Launches a Job and awaits its completion.
* @param jobName displayName (see {@link org.apache.fineract.infrastructure.jobs.service.JobName}) of Scheduler Job *
* @param jobName
* displayName (see
* {@link org.apache.fineract.infrastructure.jobs.service.JobName})
* of Scheduler Job
* *
* @author Michael Vorburger.ch * @author Michael Vorburger.ch
*/ */
@@ -148,29 +154,29 @@ public class SchedulerJobHelper {
DateTimeFormatter df = DateTimeFormatter.ISO_INSTANT; // FINERACT-926 DateTimeFormatter df = DateTimeFormatter.ISO_INSTANT; // FINERACT-926
Instant beforeExecuteTime = now().truncatedTo(ChronoUnit.SECONDS); Instant beforeExecuteTime = now().truncatedTo(ChronoUnit.SECONDS);
// Stop the Scheduler while we manually trigger execution of job, to avoid side effects and simplify debugging when readings logs // Stop the Scheduler while we manually trigger execution of job, to
// avoid side effects and simplify debugging when readings logs
updateSchedulerStatus(false); updateSchedulerStatus(false);
// Executing Scheduler Job // Executing Scheduler Job
int jobId = getSchedulerJobIdByName(jobName); int jobId = getSchedulerJobIdByName(jobName);
runSchedulerJob(jobId); runSchedulerJob(jobId);
// Await JobDetailData.lastRunHistory [JobDetailHistoryData] jobRunStartTime >= beforeExecuteTime (or timeout) // Await JobDetailData.lastRunHistory [JobDetailHistoryData]
// jobRunStartTime >= beforeExecuteTime (or timeout)
await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> { await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> {
String jobRunStartText = lastRunHistory.get("jobRunStartTime"); String jobRunStartText = lastRunHistory.get("jobRunStartTime");
if (jobRunStartText == null) { if (jobRunStartText == null) { return false; }
return false;
}
Instant jobRunStartTime = df.parse(jobRunStartText, Instant::from); Instant jobRunStartTime = df.parse(jobRunStartText, Instant::from);
return jobRunStartTime.equals(beforeExecuteTime) || jobRunStartTime.isAfter(beforeExecuteTime); return jobRunStartTime.equals(beforeExecuteTime) || jobRunStartTime.isAfter(beforeExecuteTime);
}); });
// Await JobDetailData.lastRunHistory [JobDetailHistoryData] jobRunEndTime to be both set and >= jobRunStartTime (or timeout) // Await JobDetailData.lastRunHistory [JobDetailHistoryData]
Map<String, String> finalLastRunHistory = await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> { // jobRunEndTime to be both set and >= jobRunStartTime (or timeout)
Map<String, String> finalLastRunHistory = await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId),
lastRunHistory -> {
String jobRunEndText = lastRunHistory.get("jobRunEndTime"); String jobRunEndText = lastRunHistory.get("jobRunEndTime");
if (jobRunEndText == null) { if (jobRunEndText == null) { return false; }
return false;
}
Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from); Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from);
Instant jobRunStartTime = df.parse(lastRunHistory.get("jobRunStartTime"), Instant::from); Instant jobRunStartTime = df.parse(lastRunHistory.get("jobRunStartTime"), Instant::from);
return jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime); return jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime);
@@ -179,22 +185,23 @@ public class SchedulerJobHelper {
// Verify triggerType // Verify triggerType
assertThat(finalLastRunHistory.get("triggerType"), is("application")); assertThat(finalLastRunHistory.get("triggerType"), is("application"));
// Verify status & propagate jobRunErrorMessage and/or jobRunErrorLog (if any) // Verify status & propagate jobRunErrorMessage and/or jobRunErrorLog
// (if any)
String status = finalLastRunHistory.get("status"); String status = finalLastRunHistory.get("status");
if (!status.equals("success")) { if (!status.equals("success")) {
fail("Job status is not success: " + finalLastRunHistory.toString()); fail("Job status is not success: " + finalLastRunHistory.toString());
} }
// PS: Checking getSchedulerJobHistory() [/runhistory] is pointless, because the lastRunHistory JobDetailHistoryData is already part of JobDetailData anyway. // PS: Checking getSchedulerJobHistory() [/runhistory] is pointless,
// because the lastRunHistory JobDetailHistoryData is already part of
// JobDetailData anyway.
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Callable<Map<String, String>> jobLastRunHistorySupplier(int jobId) { private Callable<Map<String, String>> jobLastRunHistorySupplier(int jobId) {
return () -> { return () -> {
Map<String, Object> job = getSchedulerJobById(jobId); Map<String, Object> job = getSchedulerJobById(jobId);
if (job == null) { if (job == null) { return null; }
return null;
}
return (Map<String, String>) job.get("lastRunHistory"); return (Map<String, String>) job.get("lastRunHistory");
}; };
} }
@@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class StandingInstructionsHelper { public class StandingInstructionsHelper {
private final static Logger LOG = LoggerFactory.getLogger(StandingInstructionsHelper.class); private final static Logger LOG = LoggerFactory.getLogger(StandingInstructionsHelper.class);
private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions"; private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions";
private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory"; private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory";
@@ -113,10 +114,11 @@ public class StandingInstructionsHelper {
return response; return response;
} }
public List<HashMap> getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, Integer fromClientId, Integer transferType) { public List<HashMap> getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, Integer fromClientId,
Integer transferType) {
final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&transferType="
+ "&transferType=" + transferType; + transferType;
LOG.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}", STANDING_INSTRUCTIONS_HISTORY_URL); LOG.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}", STANDING_INSTRUCTIONS_HISTORY_URL);
final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec, final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec,
STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems"); STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems");
@@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class SurveyHelper { public class SurveyHelper {
private final static Logger LOG = LoggerFactory.getLogger(SurveyHelper.class); private final static Logger LOG = LoggerFactory.getLogger(SurveyHelper.class);
private static final String FULFIL_SURVEY_URL = "/fineract-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER; private static final String FULFIL_SURVEY_URL = "/fineract-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER;
@@ -66,10 +67,10 @@ public class SurveyHelper {
public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedClientID) { final Integer generatedClientID) {
LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER; final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?"
+ Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id"); final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id");
assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT"); assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT");
} }
} }
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class TaxComponentHelper { public class TaxComponentHelper {
private final static Logger LOG = LoggerFactory.getLogger(TaxComponentHelper.class); private final static Logger LOG = LoggerFactory.getLogger(TaxComponentHelper.class);
private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/component?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/component?" + Utils.TENANT_IDENTIFIER;
@@ -29,13 +29,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class TaxGroupHelper { public class TaxGroupHelper {
private final static Logger LOG = LoggerFactory.getLogger(TaxGroupHelper.class); private final static Logger LOG = LoggerFactory.getLogger(TaxGroupHelper.class);
private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/group?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/group?" + Utils.TENANT_IDENTIFIER;
public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Collection<Integer> taxComponentIds) { final Collection<Integer> taxComponentIds) {
LOG.info("---------------------------------CREATING A TAX GROUP---------------------------------------------"); LOG.info("---------------------------------CREATING A TAX GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds),
"resourceId");
} }
public static String getTaxGroupAsJSON(final Collection<Integer> taxComponentIds) { public static String getTaxGroupAsJSON(final Collection<Integer> taxComponentIds) {
@@ -83,13 +83,11 @@ public class Utils {
LOG.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL); LOG.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL);
return; return;
} else { } else {
LOG.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, LOG.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, healthHttpStatus, attempt++);
healthHttpStatus, attempt++);
sleep(3); sleep(3);
} }
} catch (Exception e) { } catch (Exception e) {
LOG.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), LOG.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), attempt++);
attempt++);
lastException = e; lastException = e;
sleep(3); sleep(3);
} }
@@ -99,8 +97,7 @@ public class Utils {
LOG.error("{} still not reachable, giving up", HEALTH_URL, lastException); LOG.error("{} still not reachable, giving up", HEALTH_URL, lastException);
throw new AssertionError(HEALTH_URL + " not reachable", lastException); throw new AssertionError(HEALTH_URL + " not reachable", lastException);
} else { } else {
LOG.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, LOG.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, response.prettyPrint());
response.prettyPrint());
fail(HEALTH_URL + " returned " + response.prettyPrint()); fail(HEALTH_URL + " returned " + response.prettyPrint());
} }
} }
@@ -119,9 +116,8 @@ public class Utils {
try { try {
LOG.info("Logging in, for integration test..."); LOG.info("Logging in, for integration test...");
// system.out.println("-----------------------------------LOGIN-----------------------------------------"); // system.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.given().contentType(ContentType.JSON) String json = RestAssured.given().contentType(ContentType.JSON).body("{\"username\":\"mifos\", \"password\":\"password\"}")
.body("{\"username\":\"mifos\", \"password\":\"password\"}").expect().log().ifError().when() .expect().log().ifError().when().post(LOGIN_URL).asString();
.post(LOGIN_URL).asString();
assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false)); assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false));
String key = JsonPath.with(json).get("base64EncodedAuthenticationKey"); String key = JsonPath.with(json).get("base64EncodedAuthenticationKey");
assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false)); assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false));
@@ -136,59 +132,49 @@ public class Utils {
} }
} }
public static <T> T performServerGet(final RequestSpecification requestSpec, public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String getURL, final String jsonAttributeToGetBack) { final String getURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL) final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
if (jsonAttributeToGetBack == null) { return (T) json; }
return (T) from(json).get(jsonAttributeToGetBack);
}
public static String performGetTextResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String getURL) {
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
}
public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String getURL) {
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asByteArray();
}
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
.andReturn().asString(); .andReturn().asString();
if (jsonAttributeToGetBack == null) { if (jsonAttributeToGetBack == null) { return (T) json; }
return (T) json;
}
return (T) from(json).get(jsonAttributeToGetBack); return (T) from(json).get(jsonAttributeToGetBack);
} }
public static String performGetTextResponse(final RequestSpecification requestSpec, public static <T> T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String getURL) { final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn() final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().put(putURL)
.andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String deleteURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().delete(deleteURL).andReturn()
.asString(); .asString();
}
public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String getURL) {
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn()
.asByteArray();
}
public static <T> T performServerPost(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String postURL, final String jsonBodyToSend,
final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().post(postURL).andReturn().asString();
if (jsonAttributeToGetBack == null) {
return (T) json;
}
return (T) from(json).get(jsonAttributeToGetBack); return (T) from(json).get(jsonAttributeToGetBack);
} }
public static <T> T performServerPut(final RequestSpecification requestSpec, public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String putURL, final String jsonBodyToSend, final String deleteURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
final String jsonAttributeToGetBack) { final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when()
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().put(putURL).andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String deleteURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when()
.delete(deleteURL).andReturn().asString(); .delete(deleteURL).andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String deleteURL, final String jsonBodyToSend,
final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().delete(deleteURL).andReturn().asString();
return (T) (jsonAttributeToGetBack == null ? json : from(json).get(jsonAttributeToGetBack)); return (T) (jsonAttributeToGetBack == null ? json : from(json).get(jsonAttributeToGetBack));
} }
@@ -250,20 +236,19 @@ public class Utils {
return TimeZone.getTimeZone(TENANT_TIME_ZONE); return TimeZone.getTimeZone(TENANT_TIME_ZONE);
} }
public static String performServerTemplatePost(final RequestSpecification requestSpec, public static String performServerTemplatePost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String postURL, final String legalFormType, final File file, final String postURL, final String legalFormType, final File file, final String locale, final String dateFormat) {
final String locale, final String dateFormat) {
final String importDocumentId = given().spec(requestSpec).queryParam("legalFormType", legalFormType) final String importDocumentId = given().spec(requestSpec).queryParam("legalFormType", legalFormType).multiPart("file", file)
.multiPart("file", file).formParam("locale", locale).formParam("dateFormat", dateFormat).expect() .formParam("locale", locale).formParam("dateFormat", dateFormat).expect().spec(responseSpec).log().ifError().when()
.spec(responseSpec).log().ifError().when().post(postURL).andReturn().asString(); .post(postURL).andReturn().asString();
return importDocumentId; return importDocumentId;
} }
public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec, public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String getURL, final String importDocumentId) { final ResponseSpecification responseSpec, final String getURL, final String importDocumentId) {
final String templateLocation = given().spec(requestSpec).queryParam("importDocumentId", importDocumentId) final String templateLocation = given().spec(requestSpec).queryParam("importDocumentId", importDocumentId).expect()
.expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString(); .spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
return templateLocation.substring(1, templateLocation.length() - 1); return templateLocation.substring(1, templateLocation.length() - 1);
} }
} }
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class WorkingDaysHelper { public class WorkingDaysHelper {
private final static Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class); private final static Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class);
private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays"; private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays";
@@ -69,7 +70,8 @@ public class WorkingDaysHelper {
return (int) workingDays.get("id"); return (int) workingDays.get("id");
} }
public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER, ""); return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER, "");
@@ -21,6 +21,7 @@ package org.apache.fineract.integrationtests.common.accounting;
public class Account { public class Account {
public enum AccountType { public enum AccountType {
ASSET("1"), INCOME("4"), EXPENSE("5"), LIABILITY("2"), EQUITY("3"); ASSET("1"), INCOME("4"), EXPENSE("5"), LIABILITY("2"), EQUITY("3");
private final String accountValue; private final String accountValue;
@@ -40,22 +40,22 @@ public class AccountHelper {
public Account createAssetAccount() { public Account createAssetAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsAsset().build(); final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsAsset().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE); this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.ASSET); return new Account(accountID, Account.AccountType.ASSET);
} }
public Account createIncomeAccount() { public Account createIncomeAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsIncome().build(); final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsIncome().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE); this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.INCOME); return new Account(accountID, Account.AccountType.INCOME);
} }
public Account createExpenseAccount() { public Account createExpenseAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsExpense().build(); final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsExpense().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE); this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.EXPENSE); return new Account(accountID, Account.AccountType.EXPENSE);
} }
@@ -68,7 +68,8 @@ public class AccountHelper {
public ArrayList getAccountingWithRunningBalances() { public ArrayList getAccountingWithRunningBalances() {
final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts?fetchRunningBalance=true"; final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts?fetchRunningBalance=true";
final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_RUNNING_BALANCE_URL, ""); final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec,
GET_RUNNING_BALANCE_URL, "");
return accountRunningBalance; return accountRunningBalance;
} }
@@ -37,18 +37,19 @@ public class FinancialActivityAccountHelper {
public Object createFinancialActivityAccount(Integer financialActivityId, Integer glAccountId, public Object createFinancialActivityAccount(Integer financialActivityId, Integer glAccountId,
final ResponseSpecification responseSpecification, String jsonBack) { final ResponseSpecification responseSpecification, String jsonBack) {
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId); String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
return Utils.performServerPost(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?" return Utils.performServerPost(this.requestSpec, responseSpecification,
+ Utils.TENANT_IDENTIFIER, json, jsonBack); FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack);
} }
public Object updateFinancialActivityAccount(Integer financialActivityAccountId, Integer financialActivityId, Integer glAccountId, public Object updateFinancialActivityAccount(Integer financialActivityAccountId, Integer financialActivityId, Integer glAccountId,
final ResponseSpecification responseSpecification, String jsonBack) { final ResponseSpecification responseSpecification, String jsonBack) {
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId); String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
return Utils.performServerPut(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" return Utils.performServerPut(this.requestSpec, responseSpecification,
+ financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack); FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack);
} }
public HashMap getFinancialActivityAccount(final Integer financialActivityAccountId, final ResponseSpecification responseSpecification) { public HashMap getFinancialActivityAccount(final Integer financialActivityAccountId,
final ResponseSpecification responseSpecification) {
final String url = FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER; final String url = FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpecification, url, ""); return Utils.performServerGet(requestSpec, responseSpecification, url, "");
} }
@@ -21,6 +21,7 @@ package org.apache.fineract.integrationtests.common.accounting;
public class JournalEntry { public class JournalEntry {
public enum TransactionType { public enum TransactionType {
CREDIT("CREDIT"), DEBIT("DEBIT"); CREDIT("CREDIT"), DEBIT("DEBIT");
private TransactionType(final String type) { private TransactionType(final String type) {
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class ChargesHelper { public class ChargesHelper {
private final static Logger LOG = LoggerFactory.getLogger(ChargesHelper.class); private final static Logger LOG = LoggerFactory.getLogger(ChargesHelper.class);
private static final String CHARGES_URL = "/fineract-provider/api/v1/charges"; private static final String CHARGES_URL = "/fineract-provider/api/v1/charges";
private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER;
@@ -168,14 +169,11 @@ public class ChargesHelper {
return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, final String amount) {
final String amount) { return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
return getLoanDisbursementJSON(chargeCalculationType, amount,
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount, public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount, final Integer paymentmode) {
final Integer paymentmode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE); map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE);
map.put("chargePaymentMode", paymentmode); map.put("chargePaymentMode", paymentmode);
@@ -187,18 +185,15 @@ public class ChargesHelper {
} }
public static String getLoanSpecifiedDueDateJSON() { public static String getLoanSpecifiedDueDateJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, ChargesHelper.PENALTY);
ChargesHelper.PENALTY);
} }
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, boolean penalty) {
boolean penalty) { return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, final boolean penalty,
final boolean penalty, final Integer paymentMode) { final Integer paymentMode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE); map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE);
map.put("chargePaymentMode", paymentMode); map.put("chargePaymentMode", paymentMode);
@@ -211,25 +206,22 @@ public class ChargesHelper {
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, final String amount,
final String amount, boolean penalty) { boolean penalty) {
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanSpecifiedDueDateWithAccountTransferJSON() { public static String getLoanSpecifiedDueDateWithAccountTransferJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, ChargesHelper.PENALTY,
ChargesHelper.PENALTY, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, boolean penalty) {
boolean penalty) { return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, final boolean penalty,
final boolean penalty, final Integer paymentMode) { final Integer paymentMode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE); map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE);
map.put("chargePaymentMode", paymentMode); map.put("chargePaymentMode", paymentMode);
@@ -242,15 +234,13 @@ public class ChargesHelper {
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, final String amount,
final String amount, boolean penalty) { boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanInstallmentFeeJSON() { public static String getLoanInstallmentFeeJSON() {
return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, ChargesHelper.PENALTY);
ChargesHelper.PENALTY);
} }
public static String getShareAccountActivationChargeJson() { public static String getShareAccountActivationChargeJson() {
@@ -365,40 +355,36 @@ public class ChargesHelper {
return map; return map;
} }
public static Integer createCharges(final RequestSpecification requestSpec, public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String request) { final String request) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
} }
public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec, public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) { return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec,
CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
} }
public static HashMap getChargeById(final RequestSpecification requestSpec, public static HashMap getChargeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer chargeId) { final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
} }
public static HashMap getChargeChanges(final RequestSpecification requestSpec, public static HashMap getChargeChanges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer chargeId) { final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public static HashMap updateCharges(final RequestSpecification requestSpec, public static HashMap updateCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer chargeId, final String request) { final Integer chargeId, final String request) {
return Utils.performServerPut(requestSpec, responseSpec, return Utils.performServerPut(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec, public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec,
final Integer chargeId) { final Integer chargeId) {
return Utils.performServerDelete(requestSpec, responseSpec, return Utils.performServerDelete(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static String getModifyChargeJSON() { public static String getModifyChargeJSON() {
@@ -496,10 +482,9 @@ public class ChargesHelper {
return chargesCreateJson; return chargesCreateJson;
} }
public static String applyCharge(RequestSpecification requestSpec, ResponseSpecification responseSpec, public static String applyCharge(RequestSpecification requestSpec, ResponseSpecification responseSpec, String chargeId, String json) {
String chargeId, String json) { return Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json,
return Utils.performServerPost(requestSpec, responseSpec, "status");
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json, "status");
} }
} }
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositAccountHelper { public class FixedDepositAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountHelper.class); private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -41,8 +42,7 @@ public class FixedDepositAccountHelper {
} }
private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts"; private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts";
private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve"; private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve";
private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval"; private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval";
private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject"; private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject";
@@ -135,17 +135,16 @@ public class FixedDepositAccountHelper {
return fixedDepositAccountJson; return fixedDepositAccountJson;
} }
public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, final RequestSpecification requestSpec,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
LOG.info("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------"); LOG.info("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, fixedDepositAccountAsJson,
fixedDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer accountID) { final Integer accountID) {
final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------"); LOG.info("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, "");
} }
@@ -179,8 +178,8 @@ public class FixedDepositAccountHelper {
return annualInterestRate; return annualInterestRate;
} }
public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Integer depositPeriod,
Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval) { double interestPerDay, Integer compoundingInterval, Integer postingInterval) {
Float totalInterest = 0.0f; Float totalInterest = 0.0f;
Float interestEarned = 0.0f; Float interestEarned = 0.0f;
@@ -209,23 +208,22 @@ public class FixedDepositAccountHelper {
return principal; return principal;
} }
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom,
final String validFrom, final String validTo, final String penalInterestType, final String validTo, final String penalInterestType, final String submittedOnDate) {
final String submittedOnDate) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) // .withSubmittedOnDate(submittedOnDate) //
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, return Utils.performServerPut(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID,
final String accountID, final String submittedOnDate, final String validFrom, final String validTo, final String submittedOnDate, final String validFrom, final String validTo, final String numberOfDaysPerYear,
final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType, final String penalInterestType, final String interestCalculationType, final String interestCompoundingPeriodType,
final String interestCompoundingPeriodType, final String interestPostingPeriodType) { final String interestPostingPeriodType) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) // .withSubmittedOnDate(submittedOnDate) //
@@ -236,63 +234,51 @@ public class FixedDepositAccountHelper {
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, return Utils.performServerPut(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) { public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) {
LOG.info( LOG.info("--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------");
"--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------"); return performFixedDepositApplicationActions(createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getApproveFixedDepositAccountAsJSON(approvedOnDate)); getApproveFixedDepositAccountAsJSON(approvedOnDate));
} }
public HashMap undoApproval(final Integer fixedDepositAccountID) { public HashMap undoApproval(final Integer fixedDepositAccountID) {
LOG.info( LOG.info("--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
"--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
final String undoBodyJson = "{'note':'UNDO APPROVAL'}"; final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(
createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), undoBodyJson);
undoBodyJson);
} }
public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) { public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) {
LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------"); LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getRejectedFixedDepositAsJSON(rejectedOnDate)); getRejectedFixedDepositAsJSON(rejectedOnDate));
} }
public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) { public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) {
LOG.info( LOG.info("--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
"--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(
createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate)); getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate));
} }
public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) { public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) {
LOG.info( LOG.info("---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------");
"---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------"); return performFixedDepositApplicationActions(createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getActivatedFixedDepositAccountAsJSON(activationDate)); getActivatedFixedDepositAccountAsJSON(activationDate));
} }
public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, final String jsonAttributeToGetBack) {
final String jsonAttributeToGetBack) { LOG.info("---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
LOG.info(
"---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec, return Utils.performServerDelete(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) { public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) {
LOG.info( LOG.info("--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
"--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
return (Integer) performFixedDepositActions( return (Integer) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId), createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
@@ -305,21 +291,18 @@ public class FixedDepositAccountHelper {
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate) {
final String closedOnDate) {
LOG.info("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------"); LOG.info("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------");
return (HashMap) performFixedDepositActions( return (HashMap) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId), createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId),
getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), ""); getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), "");
} }
public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, final String closureType,
final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) { final Integer toSavingsId, final String jsonAttributeToGetBack) {
LOG.info("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------"); LOG.info("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------");
return performFixedDepositActions( return performFixedDepositActions(createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId),
createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId), getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack);
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId),
jsonAttributeToGetBack);
} }
private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) { private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) {
@@ -399,21 +382,18 @@ public class FixedDepositAccountHelper {
} }
private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) { private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) {
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent, private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent,
final String jsonAttributeToGetBack) { final String jsonAttributeToGetBack) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, final String jsonToBeSent) {
final String jsonToBeSent) {
HashMap status = null; HashMap status = null;
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDepositAction, jsonToBeSent,
postURLForFixedDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
if (response != null) { if (response != null) {
status = (HashMap) response.get("status"); status = (HashMap) response.get("status");
} }
@@ -421,8 +401,7 @@ public class FixedDepositAccountHelper {
} }
private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) { private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) {
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec, public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec,
@@ -486,9 +465,7 @@ public class FixedDepositAccountHelper {
} }
private String getDepositAmount() { private String getDepositAmount() {
if (this.newDepositAmount == null) { if (this.newDepositAmount == null) { return DEPOSIT_AMOUNT; }
return DEPOSIT_AMOUNT;
}
return this.newDepositAmount; return this.newDepositAmount;
} }
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class FixedDepositAccountStatusChecker { public class FixedDepositAccountStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountStatusChecker.class); private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountStatusChecker.class);
private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts"; private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts";
@@ -41,8 +42,7 @@ public class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------"); LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"), assertTrue(getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"), "FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE");
"FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
@@ -54,15 +54,13 @@ public class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------"); LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "rejected"), assertTrue(getStatus(fixedDepositStatusHashMap, "rejected"), "ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION");
"ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) {
LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------"); LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"), assertTrue(getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"), "ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION");
"ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
@@ -78,24 +76,22 @@ public class FixedDepositAccountStatusChecker {
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String fixedDepositAccountID) { final String fixedDepositAccountID) {
final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?"
+ "?" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status"); return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status");
} }
public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "prematureClosed"), assertTrue(getStatus(fixedDepositStatusHashMap, "prematureClosed"), "ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT");
"ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------"); LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "matured"), assertTrue(getStatus(fixedDepositStatusHashMap, "matured"), "ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT");
"ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositProductHelper { public class FixedDepositProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositProductHelper.class); private final static Logger LOG = LoggerFactory.getLogger(FixedDepositProductHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -70,7 +71,6 @@ public class FixedDepositProductHelper {
private static final String WHOLE_TERM = "1"; private static final String WHOLE_TERM = "1";
private static final String TILL_PREMATURE_WITHDRAWAL = "2"; private static final String TILL_PREMATURE_WITHDRAWAL = "2";
private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6); private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6);
private String shortName = Utils.randomNameGenerator("", 4); private String shortName = Utils.randomNameGenerator("", 4);
private String description = Utils.randomNameGenerator("", 20); private String description = Utils.randomNameGenerator("", 20);
@@ -142,8 +142,6 @@ public class FixedDepositProductHelper {
map.put("taxGroupId", taxGroupId); map.put("taxGroupId", taxGroupId);
} }
if (this.accountingRule.equals(CASH_BASED)) { if (this.accountingRule.equals(CASH_BASED)) {
map.putAll(getAccountMappingForCashBased()); map.putAll(getAccountMappingForCashBased());
} }
@@ -393,7 +391,6 @@ public class FixedDepositProductHelper {
return this; return this;
} }
private Map<String, String> getAccountMappingForCashBased() { private Map<String, String> getAccountMappingForCashBased() {
final Map<String, String> map = new HashMap<>(); final Map<String, String> map = new HashMap<>();
if (accountList != null) { if (accountList != null) {
@@ -428,10 +425,11 @@ public class FixedDepositProductHelper {
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------"); LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_PRODUCT_URL + "?" final ArrayList response = Utils.performServerGet(requestSpec, responseSpec,
+ Utils.TENANT_IDENTIFIER, ""); FIXED_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER, "");
return response; return response;
} }
@@ -50,8 +50,7 @@ public class FundsHelper {
super(); super();
} }
private FundsHelper(final String name, private FundsHelper(final String name, final String externalId) {
final String externalId) {
super(); super();
this.name = name; this.name = name;
this.externalId = externalId; this.externalId = externalId;
@@ -83,27 +82,19 @@ public class FundsHelper {
@Override @Override
public int hashCode() { public int hashCode() {
if (this.name != null) { if (this.name != null) { return this.name.hashCode(); }
return this.name.hashCode();
}
return super.hashCode(); return super.hashCode();
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == this) { if (o == this) { return true; }
return true;
}
if (!(o instanceof FundsHelper)) { if (!(o instanceof FundsHelper)) { return false; }
return false;
}
FundsHelper fh = (FundsHelper) o; FundsHelper fh = (FundsHelper) o;
if (this.name.equals(fh.name)) { if (this.name.equals(fh.name)) { return true; }
return true;
}
return false; return false;
} }
@@ -31,33 +31,26 @@ public class FundsResourceHandler {
private static final String FUNDS_URL = "/fineract-provider/api/v1/funds"; private static final String FUNDS_URL = "/fineract-provider/api/v1/funds";
private static final String CREATE_FUNDS_URL = FUNDS_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_FUNDS_URL = FUNDS_URL + "?" + Utils.TENANT_IDENTIFIER;
public static Integer createFund(final String fundJSON, public static Integer createFund(final String fundJSON, final RequestSpecification requestSpec,
final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_FUNDS_URL, fundJSON, "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_FUNDS_URL, fundJSON, "resourceId");
} }
public static List<FundsHelper> retrieveAllFunds(final RequestSpecification requestSpec, public static List<FundsHelper> retrieveAllFunds(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
final String URL = FUNDS_URL + "?" + Utils.TENANT_IDENTIFIER; final String URL = FUNDS_URL + "?" + Utils.TENANT_IDENTIFIER;
List<HashMap<String, Object>> list = Utils.performServerGet(requestSpec, responseSpec, URL, ""); List<HashMap<String, Object>> list = Utils.performServerGet(requestSpec, responseSpec, URL, "");
final String jsonData = new Gson().toJson(list); final String jsonData = new Gson().toJson(list);
return new Gson().fromJson(jsonData, new TypeToken<List<FundsHelper>>() {}.getType()); return new Gson().fromJson(jsonData, new TypeToken<List<FundsHelper>>() {}.getType());
} }
public static String retrieveFund(final Long fundID, public static String retrieveFund(final Long fundID, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
final String URL = FUNDS_URL + "/" + fundID + "?" + Utils.TENANT_IDENTIFIER; final String URL = FUNDS_URL + "/" + fundID + "?" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "");
return new Gson().toJson(response); return new Gson().toJson(response);
} }
public static FundsHelper updateFund(final Long fundID, public static FundsHelper updateFund(final Long fundID, final String newName, final String newExternalId,
final String newName, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String newExternalId,
final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
FundsHelper fh = FundsHelper.create(newName).externalId(newExternalId).build(); FundsHelper fh = FundsHelper.create(newName).externalId(newExternalId).build();
String updateJSON = new Gson().toJson(fh); String updateJSON = new Gson().toJson(fh);
@@ -42,7 +42,6 @@ public class LoanApplicationTestBuilder {
public static final String DEFAULT_STRATEGY = "1"; public static final String DEFAULT_STRATEGY = "1";
public static final String RBI_INDIA_STRATEGY = "4"; public static final String RBI_INDIA_STRATEGY = "4";
private String principal = "10,000"; private String principal = "10,000";
private String loanTermFrequency = ""; private String loanTermFrequency = "";
private String loanTermFrequencyType = ""; private String loanTermFrequencyType = "";
@@ -75,7 +74,6 @@ public class LoanApplicationTestBuilder {
private List<HashMap<String, Object>> datatables = null; private List<HashMap<String, Object>> datatables = null;
private List<Map<String, Object>> approvalFormData = null; private List<Map<String, Object>> approvalFormData = null;
public String build(final String clientID, final String groupID, final String loanProductId, final String savingsID) { public String build(final String clientID, final String groupID, final String loanProductId, final String savingsID) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("groupId", groupID); map.put("groupId", groupID);
@@ -111,8 +109,7 @@ public class LoanApplicationTestBuilder {
return build(map, loanProductId, savingsID); return build(map, loanProductId, savingsID);
} }
public String build() public String build() {
{
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
if (this.approvalFormData != null) { if (this.approvalFormData != null) {
@@ -314,8 +311,6 @@ public class LoanApplicationTestBuilder {
return this; return this;
} }
public LoanApplicationTestBuilder withFirstRepaymentDate(final String firstRepaymentDate) { public LoanApplicationTestBuilder withFirstRepaymentDate(final String firstRepaymentDate) {
this.repaymentsStartingFromDate = firstRepaymentDate; this.repaymentsStartingFromDate = firstRepaymentDate;
return this; return this;
@@ -80,25 +80,29 @@ public class LoanDisbursementTestBuilder {
return this.fromDate; return this.fromDate;
} }
/*public HashMap<String, String> build(String dueDate,String totalOriginalDueForPeriod,String totalOutstandingForPeriod, /*
String interestOutstanding, String principalOutstanding, String principalLoanBalanceOutstanding, String principalDue, * public HashMap<String, String> build(String dueDate,String
String principalOriginalDue, String fromDate) { * totalOriginalDueForPeriod,String totalOutstandingForPeriod, String
HashMap<String, String> expectedRepaymentSchedule = new HashMap<String, String>(); * interestOutstanding, String principalOutstanding, String
expectedRepaymentSchedule.put("dueDate", dueDate); * principalLoanBalanceOutstanding, String principalDue, String
expectedRepaymentSchedule.put("totalOriginalDueForPeriod", * principalOriginalDue, String fromDate) { HashMap<String, String>
totalOriginalDueForPeriod); * expectedRepaymentSchedule = new HashMap<String, String>();
expectedRepaymentSchedule.put("totalOutstandingForPeriod", * expectedRepaymentSchedule.put("dueDate", dueDate);
totalOutstandingForPeriod); * expectedRepaymentSchedule.put("totalOriginalDueForPeriod",
expectedRepaymentSchedule.put("interestOutstanding", interestOutstanding); * totalOriginalDueForPeriod);
expectedRepaymentSchedule.put("principalOutstanding", * expectedRepaymentSchedule.put("totalOutstandingForPeriod",
principalOutstanding); * totalOutstandingForPeriod);
expectedRepaymentSchedule.put("principalLoanBalanceOutstanding", * expectedRepaymentSchedule.put("interestOutstanding",
principalLoanBalanceOutstanding); * interestOutstanding);
expectedRepaymentSchedule.put("principalDue", principalDue); * expectedRepaymentSchedule.put("principalOutstanding",
expectedRepaymentSchedule.put("principalOriginalDue", * principalOutstanding);
principalOriginalDue); * expectedRepaymentSchedule.put("principalLoanBalanceOutstanding",
expectedRepaymentSchedule.put("fromDate", fromDate); * principalLoanBalanceOutstanding);
* expectedRepaymentSchedule.put("principalDue", principalDue);
return expectedRepaymentSchedule; * expectedRepaymentSchedule.put("principalOriginalDue",
}*/ * principalOriginalDue); expectedRepaymentSchedule.put("fromDate",
* fromDate);
*
* return expectedRepaymentSchedule; }
*/
} }
@@ -210,8 +210,7 @@ public class LoanProductTestBuilder {
map.put("minimumGap", minimumGap); map.put("minimumGap", minimumGap);
map.put("maximumGap", maximumGap); map.put("maximumGap", maximumGap);
} }
map.put("syncExpectedWithDisbursementDate", map.put("syncExpectedWithDisbursementDate", this.syncExpectedWithDisbursementDate);
this.syncExpectedWithDisbursementDate);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -463,7 +462,8 @@ public class LoanProductTestBuilder {
return this; return this;
} }
public LoanProductTestBuilder withMinimumDaysBetweenDisbursalAndFirstRepayment(final String minimumDaysBetweenDisbursalAndFirstRepayment) { public LoanProductTestBuilder withMinimumDaysBetweenDisbursalAndFirstRepayment(
final String minimumDaysBetweenDisbursalAndFirstRepayment) {
this.minimumDaysBetweenDisbursalAndFirstRepayment = minimumDaysBetweenDisbursalAndFirstRepayment; this.minimumDaysBetweenDisbursalAndFirstRepayment = minimumDaysBetweenDisbursalAndFirstRepayment;
return this; return this;
} }
@@ -493,7 +493,8 @@ public class LoanProductTestBuilder {
return this; return this;
} }
public LoanProductTestBuilder withVariableInstallmentsConfig(Boolean allowVariableInstallments, Integer minimumGap, Integer maximumGap) { public LoanProductTestBuilder withVariableInstallmentsConfig(Boolean allowVariableInstallments, Integer minimumGap,
Integer maximumGap) {
this.allowVariableInstallments = allowVariableInstallments; this.allowVariableInstallments = allowVariableInstallments;
this.minimumGap = minimumGap; this.minimumGap = minimumGap;
this.maximumGap = maximumGap; this.maximumGap = maximumGap;
@@ -501,8 +502,7 @@ public class LoanProductTestBuilder {
} }
public LoanProductTestBuilder withSyncExpectedWithDisbursementDate(Boolean syncExpectedWithDisbursementDate) { public LoanProductTestBuilder withSyncExpectedWithDisbursementDate(Boolean syncExpectedWithDisbursementDate) {
this.syncExpectedWithDisbursementDate = this.syncExpectedWithDisbursementDate = syncExpectedWithDisbursementDate;
syncExpectedWithDisbursementDate ;
return this; return this;
} }
} }
@@ -49,8 +49,7 @@ public class LoanTransactionHelper {
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
private final static Logger LOG = LoggerFactory.getLogger(LoanTransactionHelper.class); private final static Logger LOG = LoggerFactory.getLogger(LoanTransactionHelper.class);
private static final String CREATE_LOAN_PRODUCT_URL = "/fineract-provider/api/v1/loanproducts?" private static final String CREATE_LOAN_PRODUCT_URL = "/fineract-provider/api/v1/loanproducts?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
private static final String APPLY_LOAN_URL = "/fineract-provider/api/v1/loans?" + Utils.TENANT_IDENTIFIER; private static final String APPLY_LOAN_URL = "/fineract-provider/api/v1/loans?" + Utils.TENANT_IDENTIFIER;
private static final String LOAN_ACCOUNT_URL = "/fineract-provider/api/v1/loans"; private static final String LOAN_ACCOUNT_URL = "/fineract-provider/api/v1/loans";
private static final String APPROVE_LOAN_COMMAND = "approve"; private static final String APPROVE_LOAN_COMMAND = "approve";
@@ -76,13 +75,11 @@ public class LoanTransactionHelper {
} }
public Integer getLoanProductId(final String loanProductJSON) { public Integer getLoanProductId(final String loanProductJSON) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, "resourceId");
"resourceId");
} }
public Integer getLoanId(final String loanApplicationJSON) { public Integer getLoanId(final String loanApplicationJSON) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId");
"loanId");
} }
public HashMap<String, Integer> getGlimId(final String loanApplicationJSON) { public HashMap<String, Integer> getGlimId(final String loanApplicationJSON) {
@@ -90,15 +87,13 @@ public class LoanTransactionHelper {
} }
public Object getGlimLoanId(final String glimId) { public Object getGlimLoanId(final String glimId) {
final String GET_LOAN_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" final String GET_LOAN_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_LOAN_URL, "childLoanId"); return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_LOAN_URL, "childLoanId");
} }
public Object getLoanError(final String loanApplicationJSON, final String responseAttribute) { public Object getLoanError(final String loanApplicationJSON, final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute);
responseAttribute);
} }
public Integer getLoanOfficerId(final String loanId) { public Integer getLoanOfficerId(final String loanId) {
@@ -107,8 +102,7 @@ public class LoanTransactionHelper {
} }
public Object createLoanAccount(final String loanApplicationJSON, final String responseAttribute) { public Object createLoanAccount(final String loanApplicationJSON, final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute);
responseAttribute);
} }
public Integer updateLoan(final Integer id, final String loanApplicationJSON) { public Integer updateLoan(final Integer id, final String loanApplicationJSON) {
@@ -116,65 +110,58 @@ public class LoanTransactionHelper {
"/fineract-provider/api/v1/loans/" + id + "?" + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId"); "/fineract-provider/api/v1/loans/" + id + "?" + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId");
} }
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer loanID) { final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&" final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
return (ArrayList) response.get("periods"); return (ArrayList) response.get("periods");
} }
public ArrayList getLoanCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public ArrayList getLoanCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) { final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&" final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges"); return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges");
} }
public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec, public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer loanID) { final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule,futureSchedule&"
+ "?associations=repaymentSchedule,futureSchedule&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
return (ArrayList) response.get("futurePeriods"); return (ArrayList) response.get("futurePeriods");
} }
public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) {
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
return response; return response;
} }
public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID,
final Integer loanID, final String param) { final String param) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, param); return Utils.performServerGet(requestSpec, responseSpec, URL, param);
} }
public String getLoanDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public String getLoanDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) {
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, null); return Utils.performServerGet(requestSpec, responseSpec, URL, null);
} }
public Object getLoanProductDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Object getLoanProductDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanProductId, final String jsonAttributeToGetBack) { final Integer loanProductId, final String jsonAttributeToGetBack) {
final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttributeToGetBack); return Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttributeToGetBack);
} }
public String getLoanProductDetails(final RequestSpecification requestSpec, public String getLoanProductDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer loanProductId) { final Integer loanProductId) {
final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, null); return Utils.performServerGet(requestSpec, responseSpec, URL, null);
} }
public ArrayList getLoanCharges(final Integer loanId) { public ArrayList getLoanCharges(final Integer loanId) {
final String GET_LOAN_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" final String GET_LOAN_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, GET_LOAN_CHARGES_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_LOAN_CHARGES_URL, "");
} }
@@ -192,13 +179,10 @@ public class LoanTransactionHelper {
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches)); getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches));
} }
public List<HashMap<String, Object>> approveLoanForTranches(final String approvalDate, public List<HashMap<String, Object>> approveLoanForTranches(final String approvalDate, final String expectedDisbursementDate,
final String expectedDisbursementDate, final String approvalAmount, final Integer loanID, final String approvalAmount, final Integer loanID, List<HashMap> tranches, final String responseAttribute) {
List<HashMap> tranches, final String responseAttribute) { return (List<HashMap<String, Object>>) performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
return (List<HashMap<String, Object>>) performLoanTransaction( getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches), responseAttribute);
createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches),
responseAttribute);
} }
public Object approveLoan(final String approvalDate, final String approvalAmount, final Integer loanID, public Object approveLoan(final String approvalDate, final String approvalAmount, final Integer loanID,
@@ -216,29 +200,25 @@ public class LoanTransactionHelper {
} }
public HashMap disburseLoan(final String date, final Integer loanID) { public HashMap disburseLoan(final String date, final Integer loanID) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null));
getDisburseLoanAsJSON(date, null));
} }
public HashMap disburseLoanWithRepaymentReschedule(final String date, final Integer loanID, public HashMap disburseLoanWithRepaymentReschedule(final String date, final Integer loanID, String adjustRepaymentDate) {
String adjustRepaymentDate) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanWithRepaymentRescheduleAsJSON(date, null, adjustRepaymentDate)); getDisburseLoanWithRepaymentRescheduleAsJSON(date, null, adjustRepaymentDate));
} }
public HashMap disburseLoan(final String date, final Integer loanID, final String disburseAmt) { public HashMap disburseLoan(final String date, final Integer loanID, final String disburseAmt) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, disburseAmt));
getDisburseLoanAsJSON(date, disburseAmt));
} }
public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError) { public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null),
getDisburseLoanAsJSON(date, null), responseValidationError); responseValidationError);
} }
public HashMap disburseLoanToSavings(final String date, final Integer loanID) { public HashMap disburseLoanToSavings(final String date, final Integer loanID) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), getDisburseLoanAsJSON(date, null));
getDisburseLoanAsJSON(date, null));
} }
public HashMap undoDisbursal(final Integer loanID) { public HashMap undoDisbursal(final Integer loanID) {
@@ -253,8 +233,8 @@ public class LoanTransactionHelper {
final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}"; final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}";
final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID); final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID);
LOG.info("IN UNDO LAST DISBURSE LOAN URL : {} ", url); LOG.info("IN UNDO LAST DISBURSE LOAN URL : {} ", url);
return performUndoLastLoanDisbursementTransaction( return performUndoLastLoanDisbursementTransaction(createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID),
createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID), undoLastDisburseJson); undoLastDisburseJson);
} }
// glimtesting // glimtesting
@@ -294,20 +274,16 @@ public class LoanTransactionHelper {
} }
public HashMap writeOffLoan(final String date, final Integer loanID) { public HashMap writeOffLoan(final String date, final Integer loanID) {
return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), getWriteOffBodyAsJSON(date));
getWriteOffBodyAsJSON(date));
} }
public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) { public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) {
return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived));
getWaiveBodyAsJSON(date, amountToBeWaived));
} }
public Integer waiveInterestAndReturnTransactionId(final String date, final String amountToBeWaived, public Integer waiveInterestAndReturnTransactionId(final String date, final String amountToBeWaived, final Integer loanID) {
final Integer loanID) {
Integer resourceId = Utils.performServerPost(this.requestSpec, this.responseSpec, Integer resourceId = Utils.performServerPost(this.requestSpec, this.responseSpec,
createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived), createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived), "resourceId");
"resourceId");
return resourceId; return resourceId;
} }
@@ -328,16 +304,14 @@ public class LoanTransactionHelper {
public Integer addChargesForLoan(final Integer loanId, final String request) { public Integer addChargesForLoan(final Integer loanId, final String request) {
LOG.info("--------------------------------- ADD CHARGES FOR LOAN --------------------------------"); LOG.info("--------------------------------- ADD CHARGES FOR LOAN --------------------------------");
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, ""); final HashMap response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request, public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request,
final ResponseSpecification responseSpecification) { final ResponseSpecification responseSpecification) {
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, responseSpecification, ADD_CHARGES_URL, request, ""); return Utils.performServerPost(this.requestSpec, responseSpecification, ADD_CHARGES_URL, request, "");
} }
@@ -359,16 +333,16 @@ public class LoanTransactionHelper {
public Integer waiveChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) { public Integer waiveChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------"); LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=waive&"
+ "?command=waive&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public Integer payChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) { public Integer payChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------"); LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=pay&"
+ "?command=pay&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
@@ -386,8 +360,8 @@ public class LoanTransactionHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
private String getDisburseLoanWithRepaymentRescheduleAsJSON(final String actualDisbursementDate, private String getDisburseLoanWithRepaymentRescheduleAsJSON(final String actualDisbursementDate, final String transactionAmount,
final String transactionAmount, final String adjustRepaymentDate) { final String adjustRepaymentDate) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -405,8 +379,8 @@ public class LoanTransactionHelper {
return getApproveLoanAsJSON(approvalDate, null, null, null); return getApproveLoanAsJSON(approvalDate, null, null, null);
} }
private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate, private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate, final String approvalAmount,
final String approvalAmount, List<HashMap> tranches) { List<HashMap> tranches) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -494,8 +468,7 @@ public class LoanTransactionHelper {
return getSpecifiedDueDateChargesForLoanAsJSON(chargeId, "12 January 2013", "100"); return getSpecifiedDueDateChargesForLoanAsJSON(chargeId, "12 January 2013", "100");
} }
public static String getSpecifiedDueDateChargesForLoanAsJSON(final String chargeId, final String dueDate, public static String getSpecifiedDueDateChargesForLoanAsJSON(final String chargeId, final String dueDate, final String amount) {
final String amount) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en_GB"); map.put("locale", "en_GB");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -591,53 +564,47 @@ public class LoanTransactionHelper {
} }
private String createLoanTransactionURL(final String command, final Integer loanID) { private String createLoanTransactionURL(final String command, final Integer loanID) {
return "/fineract-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&" return "/fineract-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
private String createGlimAccountURL(final String command, final Integer glimID) { private String createGlimAccountURL(final String command, final Integer glimID) {
return "/fineract-provider/api/v1/loans/glimAccount/" + glimID + "?command=" + command + "&" return "/fineract-provider/api/v1/loans/glimAccount/" + glimID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) { private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) {
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent,
jsonToBeSent, "changes"); "changes");
return (HashMap) response.get("status"); return (HashMap) response.get("status");
} }
private Float performUndoLastLoanDisbursementTransaction(final String postURLForLoanTransaction, private Float performUndoLastLoanDisbursementTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) {
final String jsonToBeSent) {
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent,
jsonToBeSent, "changes"); "changes");
return (Float) response.get("disbursedAmount"); return (Float) response.get("disbursedAmount");
} }
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent,
final String responseAttribute) { final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, responseAttribute);
responseAttribute);
} }
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent,
ResponseSpecification responseValidationError) { ResponseSpecification responseValidationError) {
return Utils.performServerPost(this.requestSpec, responseValidationError, postURLForLoanTransaction, return Utils.performServerPost(this.requestSpec, responseValidationError, postURLForLoanTransaction, jsonToBeSent,
jsonToBeSent, CommonConstants.RESPONSE_ERROR); CommonConstants.RESPONSE_ERROR);
} }
public Object adjustLoanTransaction(final Integer loanId, final Integer transactionId, final String date, public Object adjustLoanTransaction(final Integer loanId, final Integer transactionId, final String date,
final String transactionAmount, final String responseAttribute) { final String transactionAmount, final String responseAttribute) {
return adjustLoanTransaction(loanId, transactionId, getAdjustTransactionJSON(date, transactionAmount), return adjustLoanTransaction(loanId, transactionId, getAdjustTransactionJSON(date, transactionAmount), responseAttribute);
responseAttribute);
} }
private Object adjustLoanTransaction(final Integer loanId, final Integer tansactionId, final String jsonToBeSent, private Object adjustLoanTransaction(final Integer loanId, final Integer tansactionId, final String jsonToBeSent,
final String responseAttribute) { final String responseAttribute) {
final String URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/" + tansactionId + "?" final String URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/" + tansactionId + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, jsonToBeSent, responseAttribute); return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, jsonToBeSent, responseAttribute);
} }
@@ -652,8 +619,7 @@ public class LoanTransactionHelper {
return json; return json;
} }
public HashMap getPrepayAmount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public HashMap getPrepayAmount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) {
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "/transactions/template?command=prepayLoan&" final String URL = "/fineract-provider/api/v1/loans/" + loanID + "/transactions/template?command=prepayLoan&"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "");
@@ -664,21 +630,17 @@ public class LoanTransactionHelper {
return "/fineract-provider/api/v1/accounttransfers/refundByTransfer?tenantIdentifier=default"; return "/fineract-provider/api/v1/accounttransfers/refundByTransfer?tenantIdentifier=default";
} }
public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) {
final Integer loanID) {
LOG.info("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------"); LOG.info("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------");
final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
loanID); assertEquals(expectedPrincipalOutstanding, repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding"),
assertEquals(expectedPrincipalOutstanding,
repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding"),
"Mismatch in Principal Loan Balance Outstanding "); "Mismatch in Principal Loan Balance Outstanding ");
} }
public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion, public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion, final Float feePortion,
final Float feePortion, final Float penaltyPortion, final Integer loanID) { final Float penaltyPortion, final Integer loanID) {
ArrayList<HashMap> transactions = (ArrayList<HashMap>) getLoanDetail(this.requestSpec, this.responseSpec, ArrayList<HashMap> transactions = (ArrayList<HashMap>) getLoanDetail(this.requestSpec, this.responseSpec, loanID, "transactions");
loanID, "transactions");
boolean isTransactionFound = false; boolean isTransactionFound = false;
for (int i = 0; i < transactions.size(); i++) { for (int i = 0; i < transactions.size(); i++) {
HashMap transactionType = (HashMap) transactions.get(i).get("type"); HashMap transactionType = (HashMap) transactions.get(i).get("type");
@@ -686,19 +648,16 @@ public class LoanTransactionHelper {
if (isAccrualTransaction) { if (isAccrualTransaction) {
ArrayList<Integer> accrualEntryDateAsArray = (ArrayList<Integer>) transactions.get(i).get("date"); ArrayList<Integer> accrualEntryDateAsArray = (ArrayList<Integer>) transactions.get(i).get("date");
LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0), LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
accrualEntryDateAsArray.get(1), accrualEntryDateAsArray.get(2)); accrualEntryDateAsArray.get(2));
if (transactionDate.equals(accrualEntryDate)) { if (transactionDate.equals(accrualEntryDate)) {
isTransactionFound = true; isTransactionFound = true;
assertEquals(interestPortion, assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
"Mismatch in transaction amounts"); "Mismatch in transaction amounts");
assertEquals(feePortion, assertEquals(feePortion, Float.valueOf(String.valueOf(transactions.get(i).get("feeChargesPortion"))),
Float.valueOf(String.valueOf(transactions.get(i).get("feeChargesPortion"))),
"Mismatch in transaction amounts"); "Mismatch in transaction amounts");
assertEquals(penaltyPortion, assertEquals(penaltyPortion, Float.valueOf(String.valueOf(transactions.get(i).get("penaltyChargesPortion"))),
Float.valueOf(String.valueOf(transactions.get(i).get("penaltyChargesPortion"))),
"Mismatch in transaction amounts"); "Mismatch in transaction amounts");
break; break;
} }
@@ -713,10 +672,10 @@ public class LoanTransactionHelper {
getRefundByCashBodyAsJSON(date, amountToBeRefunded)); getRefundByCashBodyAsJSON(date, amountToBeRefunded));
} }
public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId, public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId,
final Integer toAccountId, final Integer fromClientId, final String date, final Float amountToBeRefunded) { final Integer fromClientId, final String date, final Float amountToBeRefunded) {
return performLoanTransaction(createLoanRefundTransferURL(), getRefundByTransferBodyAsJSON(fromAccountId, return performLoanTransaction(createLoanRefundTransferURL(),
toClientId, toAccountId, fromClientId, date, amountToBeRefunded)); getRefundByTransferBodyAsJSON(fromAccountId, toClientId, toAccountId, fromClientId, date, amountToBeRefunded));
} }
private String getRefundByCashBodyAsJSON(final String transactionDate, final Float transactionAmount) { private String getRefundByCashBodyAsJSON(final String transactionDate, final Float transactionAmount) {
@@ -729,9 +688,8 @@ public class LoanTransactionHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId, private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId,
final Integer toAccountId, final Integer fromClientId, final String transactionDate, final Integer fromClientId, final String transactionDate, final Float transactionAmount) {
final Float transactionAmount) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("fromAccountId", fromAccountId.toString()); map.put("fromAccountId", fromAccountId.toString());
map.put("fromAccountType", "1"); map.put("fromAccountType", "1");
@@ -760,34 +718,28 @@ public class LoanTransactionHelper {
return detail; return detail;
} }
public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, final String approvalAmount,
final String approvalAmount, final String expectedDisbursementDate, final String expectedDisbursementDate, final String updatedExpectedDisbursementDate, final String updatedPrincipal,
final String updatedExpectedDisbursementDate, final String updatedPrincipal,
final String jsonAttributeToGetBack) { final String jsonAttributeToGetBack) {
return Utils.performServerPut(this.requestSpec, this.responseSpec, return Utils.performServerPut(this.requestSpec, this.responseSpec, createEditDisbursementURL(loanID, disbursementId),
createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount, getEditDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, updatedExpectedDisbursementDate, updatedPrincipal),
expectedDisbursementDate, updatedExpectedDisbursementDate, updatedPrincipal),
jsonAttributeToGetBack); jsonAttributeToGetBack);
} }
public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, final String expectedDisbursementDate,
final String expectedDisbursementDate, List<HashMap> disbursementData, List<HashMap> disbursementData, final String jsonAttributeToGetBack) {
final String jsonAttributeToGetBack) {
return Utils.performServerPut(this.requestSpec, this.responseSpec, createAddAndDeleteDisbursementURL(loanID), return Utils.performServerPut(this.requestSpec, this.responseSpec, createAddAndDeleteDisbursementURL(loanID),
getAddAndDeleteDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, disbursementData), getAddAndDeleteDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, disbursementData), jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
private String createEditDisbursementURL(Integer loanID, Integer disbursementId) { private String createEditDisbursementURL(Integer loanID, Integer disbursementId) {
return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/" + disbursementId + "?" return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/" + disbursementId + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
private String createAddAndDeleteDisbursementURL(Integer loanID) { private String createAddAndDeleteDisbursementURL(Integer loanID) {
return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/editDisbursements?" return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/editDisbursements?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
public static String getEditDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate, public static String getEditDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate,
@@ -804,8 +756,8 @@ public class LoanTransactionHelper {
return json; return json;
} }
public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate,
final String expectedDisbursementDate, final List<HashMap> disbursementData) { final List<HashMap> disbursementData) {
final HashMap map = new HashMap<>(); final HashMap map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -849,14 +801,12 @@ public class LoanTransactionHelper {
String legalFormType = null; String legalFormType = null;
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec, responseSpec, return Utils.performServerTemplatePost(requestSpec, responseSpec,
LOAN_ACCOUNT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale, LOAN_ACCOUNT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale, dateFormat);
dateFormat);
} }
public String getOutputTemplateLocation(final String importDocumentId) { public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec, return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
"/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
importDocumentId);
} }
} }
@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.util.Assert; import org.springframework.util.Assert;
public class CampaignsHelper { public class CampaignsHelper {
private final static Logger LOG = LoggerFactory.getLogger(CampaignsHelper.class); private final static Logger LOG = LoggerFactory.getLogger(CampaignsHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -56,54 +57,48 @@ public class CampaignsHelper {
public Integer createCampaign(String reportName, Integer triggerType) { public Integer createCampaign(String reportName, Integer triggerType) {
LOG.info("---------------------------------CREATING A CAMPAIGN---------------------------------------------"); LOG.info("---------------------------------CREATING A CAMPAIGN---------------------------------------------");
final String CREATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "?" + Utils.TENANT_IDENTIFIER; final String CREATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL, getCreateCampaignJSON(reportName, triggerType),
getCreateCampaignJSON(reportName, triggerType), "resourceId"); "resourceId");
} }
public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec, public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer generatedCampaignId) { final Integer generatedCampaignId) {
LOG.info("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n");
final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER; final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL, "id");
final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL,
"id");
assertEquals(generatedCampaignId, responseCampaignId, "ERROR IN CREATING THE CAMPAIGN"); assertEquals(generatedCampaignId, responseCampaignId, "ERROR IN CREATING THE CAMPAIGN");
} }
public Integer updateCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Integer updateCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId, String reportName, Integer triggerType) { final Integer generatedCampaignId, String reportName, Integer triggerType) {
LOG.info("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n"); LOG.info("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n");
final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER; return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL, getUpdateCampaignJSON(reportName, triggerType),
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL, "resourceId");
getUpdateCampaignJSON(reportName, triggerType), "resourceId");
} }
public Integer deleteCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Integer deleteCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId) { final Integer generatedCampaignId) {
LOG.info("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n"); LOG.info("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n");
final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_SMS_CAMPAIGNS_URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, DELETE_SMS_CAMPAIGNS_URL, "resourceId");
} }
public Integer performActionsOnCampaign(final RequestSpecification requestSpec, public Integer performActionsOnCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer generatedCampaignId, String command) { final Integer generatedCampaignId, String command) {
LOG.info( LOG.info("------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n");
"------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n"); final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&"
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + Utils.TENANT_IDENTIFIER;
+ "&" + Utils.TENANT_IDENTIFIER;
String actionDate = Utils.getLocalDateOfTenant().toString(DATE_FORMAT); String actionDate = Utils.getLocalDateOfTenant().toString(DATE_FORMAT);
return Utils.performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL, return Utils.performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL, getJSONForCampaignAction(command, actionDate),
getJSONForCampaignAction(command, actionDate), "resourceId"); "resourceId");
} }
public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command, public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command, String actionDate,
String actionDate, String responseJsonAttribute) { String responseJsonAttribute) {
LOG.info( LOG.info("--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n");
"--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n"); final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&"
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + Utils.TENANT_IDENTIFIER;
+ "&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, this.responseSpec, SMS_CAMPAIGNS_ACTION_URL, return Utils.performServerPost(this.requestSpec, this.responseSpec, SMS_CAMPAIGNS_ACTION_URL,
getJSONForCampaignAction(command, actionDate), responseJsonAttribute); getJSONForCampaignAction(command, actionDate), responseJsonAttribute);
} }
@@ -179,15 +174,14 @@ public class CampaignsHelper {
LOG.info("--------------------------------- GET REPORTS OPTIONS -------------------------------"); LOG.info("--------------------------------- GET REPORTS OPTIONS -------------------------------");
Assert.notNull(jsonAttributeToGetBack, "jsonAttributeToGetBack may not be null"); Assert.notNull(jsonAttributeToGetBack, "jsonAttributeToGetBack may not be null");
final String templateUrl = SMS_CAMPAIGNS_URL + "/template?" + Utils.TENANT_IDENTIFIER; final String templateUrl = SMS_CAMPAIGNS_URL + "/template?" + Utils.TENANT_IDENTIFIER;
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when() final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(templateUrl).andReturn()
.get(templateUrl).andReturn().asString(); .asString();
Assert.notNull(json, "json"); Assert.notNull(json, "json");
ArrayList<ReportData> reportsList = new ArrayList<>(); ArrayList<ReportData> reportsList = new ArrayList<>();
String reportsString = new Gson().toJson(from(json).get(jsonAttributeToGetBack)); String reportsString = new Gson().toJson(from(json).get(jsonAttributeToGetBack));
Assert.notNull(reportsString, "reportsString"); Assert.notNull(reportsString, "reportsString");
final Gson gson = new Gson(); final Gson gson = new Gson();
final Type typeOfHashMap = new TypeToken<List<ReportData>>() { final Type typeOfHashMap = new TypeToken<List<ReportData>>() {}.getType();
}.getType();
reportsList = gson.fromJson(reportsString, typeOfHashMap); reportsList = gson.fromJson(reportsString, typeOfHashMap);
return reportsList; return reportsList;
} }
@@ -197,9 +191,7 @@ public class CampaignsHelper {
if (reports != null && !reports.isEmpty()) { if (reports != null && !reports.isEmpty()) {
for (ReportData reportData : reports) { for (ReportData reportData : reports) {
if (reportName.equals(reportData.getReportName())) { if (reportName.equals(reportData.getReportName())) { return reportData.getReportId(); }
return reportData.getReportId();
}
} }
} }
Assert.notNull(null, "null"); Assert.notNull(null, "null");
@@ -27,8 +27,7 @@ public class Currency {
String nameCode; String nameCode;
String displayLabel; String displayLabel;
public Currency(String code, String name, Integer decimalPlaces, String displaySymbol, public Currency(String code, String name, Integer decimalPlaces, String displaySymbol, String nameCode, String displayLabel) {
String nameCode, String displayLabel) {
this.code = code; this.code = code;
this.name = name; this.name = name;
this.decimalPlaces = decimalPlaces; this.decimalPlaces = decimalPlaces;
@@ -38,11 +37,10 @@ public class Currency {
} }
public boolean isValid() { public boolean isValid() {
return (this.code != null && this.code.length() == 3) && return (this.code != null && this.code.length() == 3) && (this.name != null && this.name.length() > 0)
(this.name != null && this.name.length() > 0) && && (this.decimalPlaces != null && this.decimalPlaces >= 0)
(this.decimalPlaces != null && this.decimalPlaces >= 0) && && (this.nameCode != null && this.nameCode.startsWith("currency."))
(this.nameCode != null && this.nameCode.startsWith("currency.")) && && (this.displayLabel != null && this.displayLabel.length() > 0);
(this.displayLabel != null && this.displayLabel.length() > 0);
} }
} }

Some files were not shown because too many files have changed in this diff Show More