[MIFISX-1117] JUnit Test Cases for Fixed and Recurring deposits
This commit is contained in:
+550
@@ -0,0 +1,550 @@
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositAccountStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" })
|
||||
public class FixedDepositTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private FixedDepositProductHelper fixedDepositHelper;
|
||||
private FixedDepositAccountHelper fixedDepositAccountHelper;
|
||||
private AccountHelper accountHelper;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
|
||||
public static final String MINIMUM_OPENING_BALANCE = "1000.0";
|
||||
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||
public static final String CLOSURE_TYPE_WITHDRAW_DEPOSIT = "100";
|
||||
public static final String CLOSURE_TYPE_TRANSFER_TO_SAVINGS = "200";
|
||||
public static final String CLOSURE_TYPE_REINVEST = "300";
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.requestSpec.header("X-Mifos-Platform-TenantId", "default");
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountWithPrematureClosureTypeWithdrawal() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.MONTH, 1);
|
||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountId = this.fixedDepositAccountHelper.calculateInterestForFixedDeposit(fixedDepositAccountId);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
Integer transactionIdForPostInterest = this.fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId);
|
||||
Assert.assertNotNull(transactionIdForPostInterest);
|
||||
|
||||
HashMap fixedDepositPrematureData = this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
|
||||
CLOSED_ON_DATE);
|
||||
|
||||
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
|
||||
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(prematureClosureTransactionId);
|
||||
|
||||
fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsPrematureClosed(fixedDepositAccountStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountUpdation() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateFixedDepositAccount(clientId.toString(),
|
||||
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), VALID_FROM, VALID_TO);
|
||||
Assert.assertTrue(modificationsHashMap.containsKey("submittedOnDate"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountWithPrematureClosureTypeTransferToSavings() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.MONTH, 1);
|
||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientId, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountId = this.fixedDepositAccountHelper.calculateInterestForFixedDeposit(fixedDepositAccountId);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
Integer transactionIdForPostInterest = this.fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId);
|
||||
Assert.assertNotNull(transactionIdForPostInterest);
|
||||
|
||||
HashMap savingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
Float balanceBefore = (Float) savingsSummaryBefore.get("accountBalance");
|
||||
|
||||
HashMap fixedDepositPrematureData = this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
|
||||
CLOSED_ON_DATE);
|
||||
|
||||
Integer prematureClosureTransactionId = (Integer) this.fixedDepositAccountHelper.prematureCloseForFixedDeposit(
|
||||
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_TRANSFER_TO_SAVINGS, savingsId, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(prematureClosureTransactionId);
|
||||
|
||||
fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsPrematureClosed(fixedDepositAccountStatusHashMap);
|
||||
|
||||
HashMap fixedDepositData = this.fixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositAccountId);
|
||||
Float prematurityAmount = (Float) fixedDepositData.get("maturityAmount");
|
||||
|
||||
HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance");
|
||||
Float expectedSavingsBalance = balanceBefore + prematurityAmount;
|
||||
|
||||
Assert.assertEquals("Verifying Savings Account Balance after Premature Closure", expectedSavingsBalance, balanceAfter);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountWithPrematureClosureTypeReinvest() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
FixedDepositAccountHelper fixedDepositAccountHelperValidationError = new FixedDepositAccountHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.MONTH, 1);
|
||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountId = this.fixedDepositAccountHelper.calculateInterestForFixedDeposit(fixedDepositAccountId);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
Integer transactionIdForPostInterest = this.fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId);
|
||||
Assert.assertNotNull(transactionIdForPostInterest);
|
||||
|
||||
HashMap fixedDepositPrematureData = this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
|
||||
CLOSED_ON_DATE);
|
||||
|
||||
ArrayList<HashMap> errorResponse = (ArrayList<HashMap>) fixedDepositAccountHelperValidationError.prematureCloseForFixedDeposit(
|
||||
fixedDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_REINVEST, null, CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("validation.msg.fixeddepositaccount.onAccountClosureId.reinvest.not.allowed",
|
||||
errorResponse.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountUndoApproval() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.undoApproval(fixedDepositAccountId);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountRejectedAndClosed() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String REJECTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.rejectApplication(fixedDepositAccountId, REJECTED_ON_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsRejected(fixedDepositAccountStatusHashMap);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsClosed(fixedDepositAccountStatusHashMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountWithdrawnByClientAndClosed() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String WITHDRAWN_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.withdrawApplication(fixedDepositAccountId, WITHDRAWN_ON_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsWithdrawn(fixedDepositAccountStatusHashMap);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsClosed(fixedDepositAccountStatusHashMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountIsDeleted() {
|
||||
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
|
||||
this.responseSpec);
|
||||
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
|
||||
fixedDepositProductId.toString());
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountId = (Integer) this.fixedDepositAccountHelper.deleteFixedDepositApplication(fixedDepositAccountId, "resourceId");
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
}
|
||||
|
||||
private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
|
||||
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
final String fixedDepositProductJSON = fixedDepositProductHelper //
|
||||
// .withAccountingRuleAsCashBased(accounts)
|
||||
.build(validFrom, validTo);
|
||||
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom,
|
||||
final String validTo, final String submittedOnDate) {
|
||||
System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
|
||||
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
|
||||
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, validFrom, validTo);
|
||||
return this.fixedDepositAccountHelper
|
||||
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String minOpenningBalance) {
|
||||
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
|
||||
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
|
||||
final String savingsProductJSON = savingsProductHelper //
|
||||
.withInterestCompoundingPeriodTypeAsDaily() //
|
||||
.withInterestPostingPeriodTypeAsMonthly() //
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance() //
|
||||
.withMinimumOpenningBalance(minOpenningBalance).build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
}
|
||||
+623
@@ -0,0 +1,623 @@
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.recurringdeposit.RecurringDepositAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.recurringdeposit.RecurringDepositAccountStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.recurringdeposit.RecurringDepositProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
|
||||
public class RecurringDepositTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private RecurringDepositProductHelper recurringDepositProductHelper;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
private AccountHelper accountHelper;
|
||||
private RecurringDepositAccountHelper recurringDepositAccountHelper;
|
||||
|
||||
public static final String MINIMUM_OPENING_BALANCE = "1000.0";
|
||||
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||
public static final String CLOSURE_TYPE_WITHDRAW_DEPOSIT = "100";
|
||||
public static final String CLOSURE_TYPE_TRANSFER_TO_SAVINGS = "200";
|
||||
public static final String CLOSURE_TYPE_REINVEST = "300";
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountWithPrematureClosureTypeWithdrawal() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.MONTH, 1);
|
||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
|
||||
APPROVED_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsApproved(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.activateRecurringDeposit(recurringDepositAccountId,
|
||||
ACTIVATION_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsActive(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountId = this.recurringDepositAccountHelper.calculateInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
Integer transactionIdForPostInterest = this.recurringDepositAccountHelper
|
||||
.postInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(transactionIdForPostInterest);
|
||||
|
||||
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
|
||||
recurringDepositAccountId, CLOSED_ON_DATE);
|
||||
|
||||
Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit(
|
||||
recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_WITHDRAW_DEPOSIT, null, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(prematureClosureTransactionId);
|
||||
|
||||
recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(this.requestSpec,
|
||||
this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountWithPrematureClosureTypeTransferToSavings() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.MONTH, 1);
|
||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientId, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
|
||||
APPROVED_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsApproved(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.activateRecurringDeposit(recurringDepositAccountId,
|
||||
ACTIVATION_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsActive(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountId = this.recurringDepositAccountHelper.calculateInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
Integer transactionIdForPostInterest = this.recurringDepositAccountHelper
|
||||
.postInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(transactionIdForPostInterest);
|
||||
|
||||
HashMap savingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
Float balanceBefore = (Float) savingsSummaryBefore.get("accountBalance");
|
||||
|
||||
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
|
||||
recurringDepositAccountId, CLOSED_ON_DATE);
|
||||
|
||||
Integer prematureClosureTransactionId = (Integer) this.recurringDepositAccountHelper.prematureCloseForRecurringDeposit(
|
||||
recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_TRANSFER_TO_SAVINGS, savingsId,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(prematureClosureTransactionId);
|
||||
|
||||
recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(this.requestSpec,
|
||||
this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsPrematureClosed(recurringDepositAccountStatusHashMap);
|
||||
|
||||
HashMap recurringDepositData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositAccountId);
|
||||
Float prematurityAmount = (Float) recurringDepositData.get("maturityAmount");
|
||||
|
||||
HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance");
|
||||
Float expectedSavingsBalance = balanceBefore + prematurityAmount;
|
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat();
|
||||
decimalFormat.applyPattern(".00");
|
||||
// decimalFormat.format(expectedSavingsBalance);
|
||||
// decimalFormat.format(balanceAfter);
|
||||
|
||||
Assert.assertEquals("Verifying Savings Account Balance after Premature Closure", decimalFormat.format(expectedSavingsBalance), decimalFormat.format(balanceAfter));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountWithPrematureClosureTypeReinvest() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
RecurringDepositAccountHelper recurringDepositAccountHelperValidationError = new RecurringDepositAccountHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.MONTH, 1);
|
||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allRecurringDepositProductsData = this.recurringDepositProductHelper.retrieveAllRecurringDepositProducts(
|
||||
this.requestSpec, this.responseSpec);
|
||||
HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositProductId.toString());
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
|
||||
APPROVED_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsApproved(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.activateRecurringDeposit(recurringDepositAccountId,
|
||||
ACTIVATION_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsActive(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountId = this.recurringDepositAccountHelper.calculateInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
Integer transactionIdForPostInterest = this.recurringDepositAccountHelper
|
||||
.postInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(transactionIdForPostInterest);
|
||||
|
||||
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
|
||||
recurringDepositAccountId, CLOSED_ON_DATE);
|
||||
|
||||
ArrayList<HashMap> errorResponse = (ArrayList<HashMap>) recurringDepositAccountHelperValidationError
|
||||
.prematureCloseForRecurringDeposit(recurringDepositAccountId, CLOSED_ON_DATE, CLOSURE_TYPE_REINVEST, null,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("validation.msg.recurringdepositaccount.onAccountClosureId.reinvest.not.allowed",
|
||||
errorResponse.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountUpdation() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allRecurringDepositProductsData = this.recurringDepositProductHelper.retrieveAllRecurringDepositProducts(
|
||||
this.requestSpec, this.responseSpec);
|
||||
HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositProductId.toString());
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap modificationsHashMap = this.recurringDepositAccountHelper.updateRecurringDepositAccount(clientId.toString(),
|
||||
recurringDepositProductId.toString(), recurringDepositAccountId.toString(), VALID_FROM, VALID_TO);
|
||||
Assert.assertTrue(modificationsHashMap.containsKey("submittedOnDate"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountUndoApproval() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allRecurringDepositProductsData = this.recurringDepositProductHelper.retrieveAllRecurringDepositProducts(
|
||||
this.requestSpec, this.responseSpec);
|
||||
HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositProductId.toString());
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
|
||||
APPROVED_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsApproved(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.undoApproval(recurringDepositAccountId);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountRejectedAndClosed() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String REJECTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allRecurringDepositProductsData = this.recurringDepositProductHelper.retrieveAllRecurringDepositProducts(
|
||||
this.requestSpec, this.responseSpec);
|
||||
HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositProductId.toString());
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.rejectApplication(recurringDepositAccountId,
|
||||
REJECTED_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsRejected(recurringDepositAccountStatusHashMap);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsClosed(recurringDepositAccountStatusHashMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountWithdrawnByClientAndClosed() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String WITHDRAWN_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allRecurringDepositProductsData = this.recurringDepositProductHelper.retrieveAllRecurringDepositProducts(
|
||||
this.requestSpec, this.responseSpec);
|
||||
HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositProductId.toString());
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.withdrawApplication(recurringDepositAccountId,
|
||||
WITHDRAWN_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsWithdrawn(recurringDepositAccountStatusHashMap);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositAccountIsClosed(recurringDepositAccountStatusHashMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountIsDeleted() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
ArrayList<HashMap> allRicurringDepositProductsData = this.recurringDepositProductHelper.retrieveAllRecurringDepositProducts(
|
||||
this.requestSpec, this.responseSpec);
|
||||
HashMap recurringDepositProductData = this.recurringDepositProductHelper.retrieveRecurringDepositProductById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositProductId.toString());
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountId = (Integer) this.recurringDepositAccountHelper.deleteRecurringDepositApplication(
|
||||
recurringDepositAccountId, "resourceId");
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDepositForRecurringDepositAccount() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.MONTH, 1);
|
||||
final String DEPOSIT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
|
||||
APPROVED_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsApproved(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.activateRecurringDeposit(recurringDepositAccountId,
|
||||
ACTIVATION_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsActive(recurringDepositAccountStatusHashMap);
|
||||
|
||||
HashMap recurringDepositSummaryBefore = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
|
||||
Float balanceBefore = (Float) recurringDepositSummaryBefore.get("accountBalance");
|
||||
|
||||
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
|
||||
DEPOSIT_DATE);
|
||||
Assert.assertNotNull(transactionIdForDeposit);
|
||||
|
||||
HashMap recurringDepositSummaryAfter = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
|
||||
Float balanceAfter = (Float) recurringDepositSummaryAfter.get("accountBalance");
|
||||
|
||||
}
|
||||
|
||||
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
|
||||
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
final String recurringDepositProductJSON = recurringDepositProductHelper //
|
||||
// .withAccountingRuleAsCashBased(accounts)
|
||||
.build(validFrom, validTo);
|
||||
return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
|
||||
final String validTo, final String submittedOnDate) {
|
||||
System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------");
|
||||
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) //
|
||||
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, validFrom, validTo);
|
||||
return this.recurringDepositAccountHelper.applyRecurringDepositApplication(recurringDepositApplicationJSON, this.requestSpec,
|
||||
this.responseSpec);
|
||||
}
|
||||
|
||||
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String minOpenningBalance) {
|
||||
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
|
||||
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
|
||||
final String savingsProductJSON = savingsProductHelper //
|
||||
.withInterestCompoundingPeriodTypeAsDaily() //
|
||||
.withInterestPostingPeriodTypeAsMonthly() //
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance() //
|
||||
.withMinimumOpenningBalance(minOpenningBalance).build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
}
|
||||
+401
@@ -0,0 +1,401 @@
|
||||
package org.mifosplatform.integrationtests.common.fixeddeposit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account.AccountType;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsApplicationTestBuilder;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
public class FixedDepositAccountHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public FixedDepositAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/mifosng-provider/api/v1/fixeddepositaccounts";
|
||||
private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve";
|
||||
private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval";
|
||||
private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject";
|
||||
private static final String WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND = "withdrawnByApplicant";
|
||||
private static final String ACTIVATE_FIXED_DEPOSIT_COMMAND = "activate";
|
||||
private static final String CLOSE_FIXED_DEPOSIT_COMMAND = "close";
|
||||
private static final String POST_INTEREST_FIXED_DEPOSIT_COMMAND = "postInterest";
|
||||
private static final String CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND = "calculateInterest";
|
||||
private static final String CALCULATE_PREMATURE_AMOUNT_COMMAND = "calculatePrematureAmount";
|
||||
private static final String PREMATURE_CLOSE_COMMAND = "prematureClose";
|
||||
|
||||
// private static final String CREATED_DATE_PLUS_ONE = "02 April 2014";
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "4";
|
||||
private static final String IN_MULTIPLES_OF = "100";
|
||||
private static final String USD = "USD";
|
||||
private static final String DAYS = "0";
|
||||
private static final String WEEKS = "1";
|
||||
private static final String MONTHS = "2";
|
||||
private static final String YEARS = "3";
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String ANNUALLY = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
private static final String DAYS_360 = "360";
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String WHOLE_TERM = "1";
|
||||
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
|
||||
|
||||
private String interestCompoundingPeriodType = MONTHLY;
|
||||
private String interestPostingPeriodType = MONTHLY;
|
||||
private String interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
private String lockinPeriodFrequency = "6";
|
||||
private String lockingPeriodFrequencyType = MONTHS;
|
||||
private String minDepositTerm = "6";
|
||||
private String minDepositTermTypeId = MONTHS;
|
||||
private String maxDepositTerm = "10";
|
||||
private String maxDepositTermTypeId = YEARS;
|
||||
private String inMultiplesOfDepositTerm = "2";
|
||||
private String inMultiplesOfDepositTermTypeId = MONTHS;
|
||||
private String preClosurePenalInterest = "2";
|
||||
private String preClosurePenalInterestOnTypeId = WHOLE_TERM;
|
||||
private final boolean preClosurePenalApplicable = true;
|
||||
private final boolean isActiveChart = true;
|
||||
private final String currencyCode = USD;
|
||||
private final String interestCalculationDaysInYearType = DAYS_365;
|
||||
private final String depositAmount = "100000";
|
||||
private final String depositPeriod = "14";
|
||||
private final String depositPeriodFrequencyId = MONTHS;
|
||||
private String submittedOnDate = "";
|
||||
|
||||
public String build(final String clientId, final String productId, final String validFrom, final String validTo) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
chartSlabsMap1.put("toPeriod", "6");
|
||||
chartSlabsMap1.put("annualInterestRate", "5");
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
chartSlabsMap2.put("toPeriod", "12");
|
||||
chartSlabsMap2.put("annualInterestRate", "6");
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
chartSlabsMap3.put("toPeriod", "18");
|
||||
chartSlabsMap3.put("annualInterestRate", "7");
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
chartSlabsMap4.put("toPeriod", "24");
|
||||
chartSlabsMap4.put("annualInterestRate", "8");
|
||||
chartSlabsMap4.put("locale", LOCALE);
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
chartsMap.put("locale", LOCALE);
|
||||
chartsMap.put("isActiveChart", this.isActiveChart);
|
||||
chartsMap.put("chartSlabs", chartSlabs);
|
||||
charts.add(chartsMap);
|
||||
|
||||
map.put("charts", charts);
|
||||
map.put("productId", productId);
|
||||
map.put("clientId", clientId);
|
||||
map.put("interestCalculationDaysInYearType", this.interestCalculationDaysInYearType);
|
||||
map.put("locale", LOCALE);
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("monthDayFormat", "dd MMM");
|
||||
map.put("interestCalculationType", this.interestCalculationType);
|
||||
map.put("interestCompoundingPeriodType", this.interestCompoundingPeriodType);
|
||||
map.put("interestPostingPeriodType", this.interestPostingPeriodType);
|
||||
map.put("lockinPeriodFrequency", this.lockinPeriodFrequency);
|
||||
map.put("lockinPeriodFrequencyType", this.lockingPeriodFrequencyType);
|
||||
map.put("preClosurePenalApplicable", "true");
|
||||
map.put("minDepositTermTypeId", this.minDepositTermTypeId);
|
||||
map.put("minDepositTerm", this.minDepositTerm);
|
||||
map.put("maxDepositTermTypeId", this.maxDepositTermTypeId);
|
||||
map.put("maxDepositTerm", this.maxDepositTerm);
|
||||
map.put("preClosurePenalApplicable", this.preClosurePenalApplicable);
|
||||
map.put("inMultiplesOfDepositTerm", this.inMultiplesOfDepositTerm);
|
||||
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
|
||||
map.put("preClosurePenalInterest", this.preClosurePenalInterest);
|
||||
map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId);
|
||||
map.put("depositAmount", this.depositAmount);
|
||||
map.put("depositPeriod", this.depositPeriod);
|
||||
map.put("depositPeriodFrequencyId", this.depositPeriodFrequencyId);
|
||||
map.put("submittedOnDate", this.submittedOnDate);
|
||||
|
||||
String fixedDepositAccountJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountJson);
|
||||
return fixedDepositAccountJson;
|
||||
}
|
||||
|
||||
public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
System.out.println("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, fixedDepositAccountAsJson,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer accountID) {
|
||||
final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------");
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, "");
|
||||
}
|
||||
|
||||
public HashMap getFixedDepositSummary(final Integer accountID) {
|
||||
final String URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
return response;
|
||||
}
|
||||
|
||||
public static Float getInterestRate(ArrayList<ArrayList<HashMap>> interestSlabData, Integer depositPeriod, Float annualInterestRate) {
|
||||
|
||||
for (Integer slabIndex = 0; slabIndex < interestSlabData.get(0).size(); slabIndex++) {
|
||||
Integer fromPeriod = (Integer) interestSlabData.get(0).get(slabIndex).get("fromPeriod");
|
||||
Integer toPeriod = (Integer) interestSlabData.get(0).get(slabIndex).get("toPeriod");
|
||||
if (depositPeriod >= fromPeriod && depositPeriod <= toPeriod) {
|
||||
annualInterestRate = (Float) interestSlabData.get(0).get(slabIndex).get("annualInterestRate");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return annualInterestRate;
|
||||
}
|
||||
|
||||
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom,
|
||||
final String validTo) {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
todaysDate.add(Calendar.DATE, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
|
||||
.withSubmittedOnDate(SUBMITTED_ON_DATE) //
|
||||
.build(clientID, productID, validFrom, validTo);
|
||||
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) {
|
||||
System.out.println("--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------");
|
||||
return performFixedDepositApplicationActions(createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
|
||||
getApproveFixedDepositAccountAsJSON(approvedOnDate));
|
||||
}
|
||||
|
||||
public HashMap undoApproval(final Integer fixedDepositAccountID) {
|
||||
System.out.println("--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
|
||||
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
||||
return performFixedDepositApplicationActions(
|
||||
createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), undoBodyJson);
|
||||
}
|
||||
|
||||
public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) {
|
||||
System.out.println("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------");
|
||||
return performFixedDepositApplicationActions(createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
|
||||
getRejectedFixedDepositAsJSON(rejectedOnDate));
|
||||
}
|
||||
|
||||
public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) {
|
||||
System.out.println("--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
|
||||
return performFixedDepositApplicationActions(
|
||||
createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
|
||||
getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate));
|
||||
}
|
||||
|
||||
public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) {
|
||||
System.out.println("---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------");
|
||||
return performFixedDepositApplicationActions(createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
|
||||
getActivatedFixedDepositAccountAsJSON(activationDate));
|
||||
}
|
||||
|
||||
public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, final String jsonAttributeToGetBack) {
|
||||
System.out.println("---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) {
|
||||
System.out.println("--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
|
||||
return (Integer) performFixedDepositActions(
|
||||
createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
|
||||
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer postInterestForFixedDeposit(final Integer fixedDepositAccountId) {
|
||||
System.out.println("--------------------------------- POST INTEREST FOR FIXED DEPOSIT --------------------------------");
|
||||
return (Integer) performFixedDepositActions(
|
||||
createFixedDepositCalculateInterestURL(POST_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
|
||||
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate) {
|
||||
System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------");
|
||||
return (HashMap) performFixedDepositActions(
|
||||
createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId),
|
||||
getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), "");
|
||||
}
|
||||
|
||||
public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, final String closureType,
|
||||
final Integer toSavingsId, final String jsonAttributeToGetBack) {
|
||||
System.out.println("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------");
|
||||
return performFixedDepositActions(createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId),
|
||||
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("approvedOnDate", approvedOnDate);
|
||||
map.put("note", "Approval NOTE");
|
||||
String fixedDepositAccountApproveJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountApproveJson);
|
||||
return fixedDepositAccountApproveJson;
|
||||
}
|
||||
|
||||
private String getRejectedFixedDepositAsJSON(final String rejectedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectedOnDate", rejectedOnDate);
|
||||
map.put("note", "Rejected NOTE");
|
||||
String fixedDepositAccountJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountJson);
|
||||
return fixedDepositAccountJson;
|
||||
}
|
||||
|
||||
private String getWithdrawnFixedDepositAccountAsJSON(final String withdrawnApplicationOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawnOnDate", withdrawnApplicationOnDate);
|
||||
map.put("note", "Withdraw NOTE");
|
||||
String fixedDepositAccountJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountJson);
|
||||
return fixedDepositAccountJson;
|
||||
}
|
||||
|
||||
private String getActivatedFixedDepositAccountAsJSON(final String activationDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activatedOnDate", activationDate);
|
||||
String fixedDepositAccountActivateJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountActivateJson);
|
||||
return fixedDepositAccountActivateJson;
|
||||
}
|
||||
|
||||
private String getCalculatedInterestForFixedDepositApplicationAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
String fixedDepositAccountCalculatedInterestJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountCalculatedInterestJson);
|
||||
return fixedDepositAccountCalculatedInterestJson;
|
||||
}
|
||||
|
||||
private String getCalculatedPrematureAmountForFixedDepositAccountAsJSON(final String closedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
String fixedDepositAccountPrematureClosureJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountPrematureClosureJson);
|
||||
return fixedDepositAccountPrematureClosureJson;
|
||||
}
|
||||
|
||||
private String getPrematureCloseForFixedDepositAccountAsJSON(final String closedOnDate, final String closureType,
|
||||
final Integer toSavingsId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
map.put("onAccountClosureId", closureType);
|
||||
if (toSavingsId != null) {
|
||||
map.put("toSavingsAccountId", toSavingsId);
|
||||
map.put("transferDescription", "Transferring To Savings Account");
|
||||
}
|
||||
String fixedDepositAccountPrematureCloseJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountPrematureCloseJson);
|
||||
return fixedDepositAccountPrematureCloseJson;
|
||||
}
|
||||
|
||||
private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) {
|
||||
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent,
|
||||
final String jsonAttributeToGetBack) {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, final String jsonToBeSent) {
|
||||
HashMap status = null;
|
||||
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDepositAction, jsonToBeSent,
|
||||
CommonConstants.RESPONSE_CHANGES);
|
||||
if (response != null) {
|
||||
status = (HashMap) response.get("status");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) {
|
||||
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
System.out.println("-------------------- RETRIEVING ALL FIXED DEPOSIT ACCOUNTS ---------------------");
|
||||
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public FixedDepositAccountHelper withSubmittedOnDate(final String fixedDepositApplicationSubmittedDate) {
|
||||
this.submittedOnDate = fixedDepositApplicationSubmittedDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package org.mifosplatform.integrationtests.common.fixeddeposit;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class FixedDepositAccountStatusChecker {
|
||||
|
||||
private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/mifosng-provider/api/v1/fixeddepositaccounts";
|
||||
|
||||
public static void verifyFixedDepositIsApproved(final HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS APPROVED --------------------");
|
||||
assertTrue("Error in Approving Fixed deposit application", getStatus(fixedDepositStatusHashMap, "approved"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
|
||||
assertTrue("FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE", getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyFixedDepositIsActive(final HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("----------------- VERIFYING FIXED DEPOSIT APPLICATION IS ACTIVE -----------------");
|
||||
assertTrue("ERROR IN ACTIVATING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "active"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
|
||||
assertTrue("ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "rejected"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------");
|
||||
assertTrue("ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyFixedDepositAccountIsClosed(final HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
|
||||
assertTrue("ERROR IN CLOSING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "closed"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyFixedDepositAccountIsNotActive(final HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("------------------ VERIFYING FIXED DEPOSIT APPLICATION IS INACTIVE --------------------");
|
||||
Assert.assertFalse(getStatus(fixedDepositStatusHashMap, "active"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String fixedDepositAccountID) {
|
||||
final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status");
|
||||
}
|
||||
|
||||
public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) {
|
||||
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
|
||||
assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "prematureClosed"));
|
||||
System.out.println(fixedDepositStatusHashMap);
|
||||
}
|
||||
|
||||
private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) {
|
||||
return (Boolean) fixedDepositStatusMap.get(fixedDepositStatusString);
|
||||
}
|
||||
}
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
package org.mifosplatform.integrationtests.common.fixeddeposit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account.AccountType;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
public class FixedDepositProductHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public FixedDepositProductHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
private static final String FIXED_DEPOSIT_PRODUCT_URL = "/mifosng-provider/api/v1/fixeddepositproducts";
|
||||
private static final String INTEREST_CHART_URL = "/mifosng-provider/api/v1/interestratecharts";
|
||||
private static final String CREATE_FIXED_DEPOSIT_PRODUCT_URL = FIXED_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "4";
|
||||
private static final String IN_MULTIPLES_OF = "100";
|
||||
private static final String USD = "USD";
|
||||
private static final String DAYS = "0";
|
||||
private static final String WEEKS = "1";
|
||||
private static final String MONTHS = "2";
|
||||
private static final String YEARS = "3";
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String ANNUALLY = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
private static final String DAYS_360 = "360";
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String WHOLE_TERM = "1";
|
||||
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
|
||||
|
||||
private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6);
|
||||
private String shortName = Utils.randomNameGenerator("", 4);
|
||||
private String description = Utils.randomNameGenerator("", 20);
|
||||
private String interestCompoundingPeriodType = MONTHLY;
|
||||
private String interestPostingPeriodType = MONTHLY;
|
||||
private String interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
private String accountingRule = NONE;
|
||||
private String lockinPeriodFrequency = "6";
|
||||
private String lockingPeriodFrequencyType = MONTHS;
|
||||
private String minDepositTerm = "6";
|
||||
private String minDepositTermTypeId = MONTHS;
|
||||
private String maxDepositTerm = "10";
|
||||
private String maxDepositTermTypeId = YEARS;
|
||||
private String inMultiplesOfDepositTerm = "2";
|
||||
private String inMultiplesOfDepositTermTypeId = MONTHS;
|
||||
private String preClosurePenalInterest = "2";
|
||||
private String preClosurePenalInterestOnTypeId = WHOLE_TERM;
|
||||
private final boolean preClosurePenalApplicable = true;
|
||||
private final String currencyCode = USD;
|
||||
private final String interestCalculationDaysInYearType = DAYS_365;
|
||||
private Account[] accountList = null;
|
||||
|
||||
public String build(final String validFrom, final String validTo) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
chartSlabsMap1.put("toPeriod", "6");
|
||||
chartSlabsMap1.put("annualInterestRate", "5");
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
chartSlabsMap2.put("toPeriod", "12");
|
||||
chartSlabsMap2.put("annualInterestRate", "6");
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
chartSlabsMap3.put("toPeriod", "18");
|
||||
chartSlabsMap3.put("annualInterestRate", "7");
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
chartSlabsMap4.put("toPeriod", "24");
|
||||
chartSlabsMap4.put("annualInterestRate", "8");
|
||||
chartSlabsMap4.put("locale", LOCALE);
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
chartsMap.put("locale", LOCALE);
|
||||
chartsMap.put("chartSlabs", chartSlabs);
|
||||
charts.add(chartsMap);
|
||||
|
||||
map.put("charts", charts);
|
||||
map.put("name", this.name);
|
||||
map.put("shortName", this.shortName);
|
||||
map.put("description", this.description);
|
||||
map.put("currencyCode", this.currencyCode);
|
||||
map.put("interestCalculationDaysInYearType", this.interestCalculationDaysInYearType);
|
||||
map.put("locale", LOCALE);
|
||||
map.put("digitsAfterDecimal", DIGITS_AFTER_DECIMAL);
|
||||
map.put("inMultiplesOf", IN_MULTIPLES_OF);
|
||||
map.put("interestCalculationType", this.interestCalculationType);
|
||||
map.put("interestCompoundingPeriodType", this.interestCompoundingPeriodType);
|
||||
map.put("interestPostingPeriodType", this.interestPostingPeriodType);
|
||||
map.put("accountingRule", this.accountingRule);
|
||||
map.put("lockinPeriodFrequency", this.lockinPeriodFrequency);
|
||||
map.put("lockinPeriodFrequencyType", this.lockingPeriodFrequencyType);
|
||||
map.put("preClosurePenalApplicable", "true");
|
||||
map.put("minDepositTermTypeId", this.minDepositTermTypeId);
|
||||
map.put("minDepositTerm", this.minDepositTerm);
|
||||
map.put("maxDepositTermTypeId", this.maxDepositTermTypeId);
|
||||
map.put("maxDepositTerm", this.maxDepositTerm);
|
||||
map.put("preClosurePenalApplicable", this.preClosurePenalApplicable);
|
||||
map.put("inMultiplesOfDepositTerm", this.inMultiplesOfDepositTerm);
|
||||
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
|
||||
map.put("preClosurePenalInterest", this.preClosurePenalInterest);
|
||||
map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId);
|
||||
|
||||
if (this.accountingRule.equals(CASH_BASED)) {
|
||||
map.putAll(getAccountMappingForCashBased());
|
||||
}
|
||||
|
||||
String FixedDepositProductCreateJson = new Gson().toJson(map);
|
||||
System.out.println(FixedDepositProductCreateJson);
|
||||
return FixedDepositProductCreateJson;
|
||||
}
|
||||
|
||||
public FixedDepositProductHelper withAccountingRuleAsNone() {
|
||||
this.accountingRule = NONE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FixedDepositProductHelper withAccountingRuleAsCashBased(final Account[] account_list) {
|
||||
this.accountingRule = CASH_BASED;
|
||||
this.accountList = account_list;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForCashBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
if (accountList != null) {
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("savingsReferenceAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.LIABILITY)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("savingsControlAccountId", ID);
|
||||
map.put("transfersInSuspenseAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("interestOnSavingsAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.INCOME)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("incomeFromFeeAccountId", ID);
|
||||
map.put("incomeFromPenaltyAccountId", ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Integer createFixedDepositProduct(final String fixedDepositProductCreateJson, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
System.out.println("--------------------- CREATING FIXED DEPOSIT PRODUCT ------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_FIXED_DEPOSIT_PRODUCT_URL, fixedDepositProductCreateJson,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
System.out.println("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------");
|
||||
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_PRODUCT_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public static HashMap retrieveFixedDepositProductById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String productId) {
|
||||
System.out.println("------------------------ RETRIEVING FIXED DEPOSIT PRODUCT BY ID ------------------------");
|
||||
final String GET_FD_PRODUCT_BY_ID_URL = FIXED_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_FD_PRODUCT_BY_ID_URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer productId) {
|
||||
System.out.println("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------");
|
||||
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId, "chartSlabs");
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
+415
@@ -0,0 +1,415 @@
|
||||
package org.mifosplatform.integrationtests.common.recurringdeposit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account.AccountType;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsApplicationTestBuilder;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
public class RecurringDepositAccountHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public RecurringDepositAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/mifosng-provider/api/v1/recurringdepositaccounts";
|
||||
private static final String APPLY_RECURRING_DEPOSIT_ACCOUNT_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String APPROVE_RECURRING_DEPOSIT_COMMAND = "approve";
|
||||
private static final String UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND = "undoapproval";
|
||||
private static final String REJECT_RECURRING_DEPOSIT_COMMAND = "reject";
|
||||
private static final String WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND = "withdrawnByApplicant";
|
||||
private static final String ACTIVATE_RECURRING_DEPOSIT_COMMAND = "activate";
|
||||
private static final String CLOSE_RECURRING_DEPOSIT_COMMAND = "close";
|
||||
private static final String POST_INTEREST_RECURRING_DEPOSIT_COMMAND = "postInterest";
|
||||
private static final String CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND = "calculateInterest";
|
||||
private static final String CALCULATE_PREMATURE_AMOUNT_COMMAND = "calculatePrematureAmount";
|
||||
private static final String PREMATURE_CLOSE_COMMAND = "prematureClose";
|
||||
private static final String DEPOSIT_INTO_RECURRING_DEPOSIT_COMMAND = "deposit";
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "4";
|
||||
private static final String IN_MULTIPLES_OF = "100";
|
||||
private static final String USD = "USD";
|
||||
private static final String DAYS = "0";
|
||||
private static final String WEEKS = "1";
|
||||
private static final String MONTHS = "2";
|
||||
private static final String YEARS = "3";
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String ANNUALLY = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
private static final String DAYS_360 = "360";
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String WHOLE_TERM = "1";
|
||||
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
|
||||
|
||||
private String interestCompoundingPeriodType = MONTHLY;
|
||||
private String interestPostingPeriodType = MONTHLY;
|
||||
private String interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
private String lockinPeriodFrequency = "6";
|
||||
private String lockingPeriodFrequencyType = MONTHS;
|
||||
private String minDepositTerm = "6";
|
||||
private String minDepositTermTypeId = MONTHS;
|
||||
private String maxDepositTerm = "10";
|
||||
private String maxDepositTermTypeId = YEARS;
|
||||
private String inMultiplesOfDepositTerm = "2";
|
||||
private String inMultiplesOfDepositTermTypeId = MONTHS;
|
||||
private String preClosurePenalInterest = "2";
|
||||
private String preClosurePenalInterestOnTypeId = WHOLE_TERM;
|
||||
private final boolean preClosurePenalApplicable = true;
|
||||
private final boolean isActiveChart = true;
|
||||
private final String currencyCode = USD;
|
||||
private final String interestCalculationDaysInYearType = DAYS_365;
|
||||
private final String depositAmount = "100000";
|
||||
private final String depositPeriod = "14";
|
||||
private final String depositPeriodFrequencyId = MONTHS;
|
||||
private final String recurringDepositFrequency = "1";
|
||||
private final String recurringDepositFrequencyTypeId = MONTHS;
|
||||
private final String recurringDepositAmount = "2000";
|
||||
private String submittedOnDate = "";
|
||||
|
||||
public String build(final String clientId, final String productId, final String validFrom, final String validTo) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
chartSlabsMap1.put("toPeriod", "6");
|
||||
chartSlabsMap1.put("annualInterestRate", "5");
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
chartSlabsMap2.put("toPeriod", "12");
|
||||
chartSlabsMap2.put("annualInterestRate", "6");
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
chartSlabsMap3.put("toPeriod", "18");
|
||||
chartSlabsMap3.put("annualInterestRate", "7");
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
chartSlabsMap4.put("toPeriod", "24");
|
||||
chartSlabsMap4.put("annualInterestRate", "8");
|
||||
chartSlabsMap4.put("locale", LOCALE);
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
chartsMap.put("locale", LOCALE);
|
||||
chartsMap.put("isActiveChart", this.isActiveChart);
|
||||
chartsMap.put("chartSlabs", chartSlabs);
|
||||
charts.add(chartsMap);
|
||||
|
||||
map.put("charts", charts);
|
||||
map.put("productId", productId);
|
||||
map.put("clientId", clientId);
|
||||
map.put("interestCalculationDaysInYearType", this.interestCalculationDaysInYearType);
|
||||
map.put("locale", LOCALE);
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("monthDayFormat", "dd MMM");
|
||||
map.put("interestCalculationType", this.interestCalculationType);
|
||||
map.put("interestCompoundingPeriodType", this.interestCompoundingPeriodType);
|
||||
map.put("interestPostingPeriodType", this.interestPostingPeriodType);
|
||||
map.put("lockinPeriodFrequency", this.lockinPeriodFrequency);
|
||||
map.put("lockinPeriodFrequencyType", this.lockingPeriodFrequencyType);
|
||||
map.put("preClosurePenalApplicable", "true");
|
||||
map.put("minDepositTermTypeId", this.minDepositTermTypeId);
|
||||
map.put("minDepositTerm", this.minDepositTerm);
|
||||
map.put("maxDepositTermTypeId", this.maxDepositTermTypeId);
|
||||
map.put("maxDepositTerm", this.maxDepositTerm);
|
||||
map.put("preClosurePenalApplicable", this.preClosurePenalApplicable);
|
||||
map.put("inMultiplesOfDepositTerm", this.inMultiplesOfDepositTerm);
|
||||
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
|
||||
map.put("preClosurePenalInterest", this.preClosurePenalInterest);
|
||||
map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId);
|
||||
map.put("depositAmount", this.depositAmount);
|
||||
map.put("depositPeriod", this.depositPeriod);
|
||||
map.put("depositPeriodFrequencyId", this.depositPeriodFrequencyId);
|
||||
map.put("submittedOnDate", this.submittedOnDate);
|
||||
map.put("recurringDepositFrequency", this.recurringDepositFrequency);
|
||||
map.put("recurringDepositFrequencyTypeId", this.recurringDepositFrequencyTypeId);
|
||||
map.put("recurringDepositAmount", this.recurringDepositAmount);
|
||||
|
||||
String recurringDepositAccountJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountJson);
|
||||
return recurringDepositAccountJson;
|
||||
}
|
||||
|
||||
public static Integer applyRecurringDepositApplication(final String recurringDepositAccountAsJson,
|
||||
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
System.out.println("--------------------- APPLYING FOR RECURRING DEPOSIT ACCOUNT ------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, APPLY_RECURRING_DEPOSIT_ACCOUNT_URL, recurringDepositAccountAsJson,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public static HashMap getRecurringDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer accountID) {
|
||||
final String GET_RECURRING_DEPOSIT_BY_ID_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING RECURRING DEPOSIT ACCOUNT BY ID -------------------------");
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_RECURRING_DEPOSIT_BY_ID_URL, "");
|
||||
}
|
||||
|
||||
public HashMap getRecurringDepositSummary(final Integer accountID) {
|
||||
final String URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
return response;
|
||||
}
|
||||
|
||||
public HashMap updateRecurringDepositAccount(final String clientID, final String productID, final String accountID,
|
||||
final String validFrom, final String validTo) {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
todaysDate.add(Calendar.DATE, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) //
|
||||
.withSubmittedOnDate(SUBMITTED_ON_DATE) //
|
||||
.build(clientID, productID, validFrom, validTo);
|
||||
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public HashMap approveRecurringDeposit(final Integer recurringDepositAccountID, final String approvedOnDate) {
|
||||
System.out
|
||||
.println("--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------");
|
||||
return performRecurringDepositApplicationActions(
|
||||
createRecurringDepositOperationURL(APPROVE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
|
||||
getApproveRecurringDepositAccountAsJSON(approvedOnDate));
|
||||
}
|
||||
|
||||
public HashMap undoApproval(final Integer recurringDepositAccountID) {
|
||||
System.out
|
||||
.println("--------------------------------- UNDO APPROVING RECURRING DEPOSIT APPLICATION -------------------------------");
|
||||
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
||||
return performRecurringDepositApplicationActions(
|
||||
createRecurringDepositOperationURL(UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), undoBodyJson);
|
||||
}
|
||||
|
||||
public HashMap rejectApplication(final Integer recurringDepositAccountID, final String rejectedOnDate) {
|
||||
System.out.println("--------------------------------- REJECT RECURRING DEPOSIT APPLICATION -------------------------------");
|
||||
return performRecurringDepositApplicationActions(
|
||||
createRecurringDepositOperationURL(REJECT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
|
||||
getRejectedRecurringDepositAsJSON(rejectedOnDate));
|
||||
}
|
||||
|
||||
public HashMap withdrawApplication(final Integer recurringDepositAccountID, final String withdrawApplicationOnDate) {
|
||||
System.out.println("--------------------------------- WITHDRAW RECURRING DEPOSIT APPLICATION -------------------------------");
|
||||
return performRecurringDepositApplicationActions(
|
||||
createRecurringDepositOperationURL(WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
|
||||
getWithdrawnRecurringDepositAccountAsJSON(withdrawApplicationOnDate));
|
||||
}
|
||||
|
||||
public HashMap activateRecurringDeposit(final Integer recurringDepositAccountID, final String activationDate) {
|
||||
System.out
|
||||
.println("---------------------------------- ACTIVATING RECURRING DEPOSIT APPLICATION ----------------------------------");
|
||||
return performRecurringDepositApplicationActions(
|
||||
createRecurringDepositOperationURL(ACTIVATE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
|
||||
getActivatedRecurringDepositAccountAsJSON(activationDate));
|
||||
}
|
||||
|
||||
public Object deleteRecurringDepositApplication(final Integer recurringDepositAccountID, final String jsonAttributeToGetBack) {
|
||||
System.out.println("---------------------------------- DELETE RECURRING DEPOSIT APPLICATION ----------------------------------");
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/"
|
||||
+ recurringDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public Integer calculateInterestForRecurringDeposit(final Integer recurringDepositAccountId) {
|
||||
System.out.println("--------------------------------- CALCULATING INTEREST FOR RECURRING DEPOSIT --------------------------------");
|
||||
return (Integer) performRecurringDepositActions(
|
||||
createRecurringDepositCalculateInterestURL(CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId),
|
||||
getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer postInterestForRecurringDeposit(final Integer recurringDepositAccountId) {
|
||||
System.out.println("--------------------------------- POST INTEREST FOR RECURRING DEPOSIT --------------------------------");
|
||||
return (Integer) performRecurringDepositActions(
|
||||
createRecurringDepositCalculateInterestURL(POST_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId),
|
||||
getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer depositToRecurringDepositAccount(final Integer recurringDepositAccountId, final String depositedOnDate) {
|
||||
System.out.println("--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------");
|
||||
return (Integer) performRecurringDepositActions(
|
||||
createDepositToRecurringDepositURL(DEPOSIT_INTO_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId),
|
||||
getDepositToRecurringDepositAccountAsJSON(depositedOnDate), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public HashMap calculatePrematureAmountForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate) {
|
||||
System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR RECURRING DEPOSIT ----------------------------");
|
||||
return (HashMap) performRecurringDepositActions(
|
||||
createRecurringDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, recurringDepositAccountId),
|
||||
getCalculatedPrematureAmountForRecurringDepositAccountAsJSON(closedOnDate), "");
|
||||
}
|
||||
|
||||
public Object prematureCloseForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate,
|
||||
final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) {
|
||||
System.out.println("--------------------- PREMATURE CLOSE FOR RECURRING DEPOSIT ----------------------------");
|
||||
return performRecurringDepositActions(
|
||||
createRecurringDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, recurringDepositAccountId),
|
||||
getPrematureCloseForRecurringDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private String getApproveRecurringDepositAccountAsJSON(final String approvedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("approvedOnDate", approvedOnDate);
|
||||
map.put("note", "Approval NOTE");
|
||||
String recurringDepositAccountApproveJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountApproveJson);
|
||||
return recurringDepositAccountApproveJson;
|
||||
}
|
||||
|
||||
private String getRejectedRecurringDepositAsJSON(final String rejectedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectedOnDate", rejectedOnDate);
|
||||
map.put("note", "Rejected NOTE");
|
||||
String recurringDepositAccountJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountJson);
|
||||
return recurringDepositAccountJson;
|
||||
}
|
||||
|
||||
private String getWithdrawnRecurringDepositAccountAsJSON(final String withdrawnApplicationOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawnOnDate", withdrawnApplicationOnDate);
|
||||
map.put("note", "Withdraw NOTE");
|
||||
String recurringDepositAccountJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountJson);
|
||||
return recurringDepositAccountJson;
|
||||
}
|
||||
|
||||
private String getActivatedRecurringDepositAccountAsJSON(final String activationDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activatedOnDate", activationDate);
|
||||
String recurringDepositAccountActivateJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountActivateJson);
|
||||
return recurringDepositAccountActivateJson;
|
||||
}
|
||||
|
||||
private String getCalculatedInterestForRecurringDepositApplicationAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
String recurringDepositAccountCalculatedInterestJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountCalculatedInterestJson);
|
||||
return recurringDepositAccountCalculatedInterestJson;
|
||||
}
|
||||
|
||||
private String getCalculatedPrematureAmountForRecurringDepositAccountAsJSON(final String closedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountPrematureClosureJson);
|
||||
return recurringDepositAccountPrematureClosureJson;
|
||||
}
|
||||
|
||||
private String getDepositToRecurringDepositAccountAsJSON(final String depositedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("transactionAmount", this.recurringDepositAmount);
|
||||
map.put("transactionDate", depositedOnDate);
|
||||
String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountPrematureClosureJson);
|
||||
return recurringDepositAccountPrematureClosureJson;
|
||||
}
|
||||
|
||||
private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate, final String closureType,
|
||||
final Integer toSavingsId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
map.put("onAccountClosureId", closureType);
|
||||
if (toSavingsId != null) {
|
||||
map.put("toSavingsAccountId", toSavingsId);
|
||||
map.put("transferDescription", "Transferring To Savings Account");
|
||||
}
|
||||
String recurringDepositAccountPrematureCloseJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountPrematureCloseJson);
|
||||
return recurringDepositAccountPrematureCloseJson;
|
||||
}
|
||||
|
||||
private String createRecurringDepositOperationURL(final String command, final Integer recurringDepositAccountID) {
|
||||
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private Object performRecurringDepositActions(final String postURLForRecurringDeposit, final String jsonToBeSent,
|
||||
final String jsonAttributeToGetBack) {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForRecurringDeposit, jsonToBeSent,
|
||||
jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private HashMap performRecurringDepositApplicationActions(final String postURLForRecurringDepositAction, final String jsonToBeSent) {
|
||||
HashMap status = null;
|
||||
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForRecurringDepositAction,
|
||||
jsonToBeSent, CommonConstants.RESPONSE_CHANGES);
|
||||
if (response != null) {
|
||||
status = (HashMap) response.get("status");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private String createRecurringDepositCalculateInterestURL(final String command, final Integer recurringDepositAccountID) {
|
||||
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private String createDepositToRecurringDepositURL(final String command, final Integer recurringDepositAccountID) {
|
||||
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
public RecurringDepositAccountHelper withSubmittedOnDate(final String recurringDepositApplicationSubmittedDate) {
|
||||
this.submittedOnDate = recurringDepositApplicationSubmittedDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package org.mifosplatform.integrationtests.common.recurringdeposit;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class RecurringDepositAccountStatusChecker {
|
||||
|
||||
private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/mifosng-provider/api/v1/recurringdepositaccounts";
|
||||
|
||||
public static void verifyRecurringDepositIsApproved(final HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS APPROVED --------------------");
|
||||
assertTrue("Error in Approving Recurring deposit application", getStatus(recurringDepositStatusHashMap, "approved"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyRecurringDepositIsPending(final HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS PENDING --------------------");
|
||||
assertTrue("RECURRING DEPOSIT ACCOUNT IS NOT IN PENDING STATE",
|
||||
getStatus(recurringDepositStatusHashMap, "submittedAndPendingApproval"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyRecurringDepositIsActive(final HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("----------------- VERIFYING RECURRING DEPOSIT APPLICATION IS ACTIVE -----------------");
|
||||
assertTrue("ERROR IN ACTIVATING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "active"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyRecurringDepositIsRejected(final HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("-------------- VERIFYING RECURRING DEPOSIT APPLICATION IS REJECTED ----------------");
|
||||
assertTrue("ERROR IN REJECTING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "rejected"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyRecurringDepositIsWithdrawn(final HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("---------------- VERIFYING RECURRING DEPOSIT APPLICATION IS WITHDRAWN ----------------");
|
||||
assertTrue("ERROR IN WITHDRAW THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "withdrawnByApplicant"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyRecurringDepositAccountIsClosed(final HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------");
|
||||
assertTrue("ERROR IN CLOSING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "closed"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static void verifyRecurringDepositAccountIsNotActive(final HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("------------------ VERIFYING RECURRING DEPOSIT APPLICATION IS INACTIVE --------------------");
|
||||
Assert.assertFalse(getStatus(recurringDepositStatusHashMap, "active"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
public static HashMap getStatusOfRecurringDepositAccount(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String recurringDepositAccountID) {
|
||||
final String GET_STATUS_OF_RECURRING_DEPOSIT_ACCOUNT_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_RECURRING_DEPOSIT_ACCOUNT_URL, "status");
|
||||
}
|
||||
|
||||
public static void verifyRecurringDepositAccountIsPrematureClosed(HashMap recurringDepositStatusHashMap) {
|
||||
System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------");
|
||||
assertTrue("ERROR IN PREMATURELY CLOSING THE RECURRING DEPOSIT ACCOUNT",
|
||||
getStatus(recurringDepositStatusHashMap, "prematureClosed"));
|
||||
System.out.println(recurringDepositStatusHashMap);
|
||||
}
|
||||
|
||||
private static boolean getStatus(final HashMap recurringDepositStatusMap, final String recurringDepositStatusString) {
|
||||
return (Boolean) recurringDepositStatusMap.get(recurringDepositStatusString);
|
||||
}
|
||||
}
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
package org.mifosplatform.integrationtests.common.recurringdeposit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account.AccountType;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
public class RecurringDepositProductHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public RecurringDepositProductHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
private static final String RECURRING_DEPOSIT_PRODUCT_URL = "/mifosng-provider/api/v1/recurringdepositproducts";
|
||||
private static final String CREATE_RECURRING_DEPOSIT_PRODUCT_URL = RECURRING_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "4";
|
||||
private static final String IN_MULTIPLES_OF = "100";
|
||||
private static final String USD = "USD";
|
||||
private static final String DAYS = "0";
|
||||
private static final String WEEKS = "1";
|
||||
private static final String MONTHS = "2";
|
||||
private static final String YEARS = "3";
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String ANNUALLY = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
private static final String DAYS_360 = "360";
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String WHOLE_TERM = "1";
|
||||
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
|
||||
private static final String VOLUNTARY = "1";
|
||||
private static final String MANDATORY = "2";
|
||||
|
||||
private String name = Utils.randomNameGenerator("RECURRING_DEPOSIT_PRODUCT_", 6);
|
||||
private String shortName = Utils.randomNameGenerator("", 4);
|
||||
private String description = Utils.randomNameGenerator("", 20);
|
||||
private String interestCompoundingPeriodType = MONTHLY;
|
||||
private String interestPostingPeriodType = MONTHLY;
|
||||
private String interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
private String accountingRule = NONE;
|
||||
private String lockinPeriodFrequency = "6";
|
||||
private String lockingPeriodFrequencyType = MONTHS;
|
||||
private String minDepositTerm = "6";
|
||||
private String minDepositTermTypeId = MONTHS;
|
||||
private String maxDepositTerm = "10";
|
||||
private String maxDepositTermTypeId = YEARS;
|
||||
private String inMultiplesOfDepositTerm = "2";
|
||||
private String inMultiplesOfDepositTermTypeId = MONTHS;
|
||||
private String preClosurePenalInterest = "2";
|
||||
private String preClosurePenalInterestOnTypeId = WHOLE_TERM;
|
||||
private final boolean preClosurePenalApplicable = true;
|
||||
private final String currencyCode = USD;
|
||||
private final String interestCalculationDaysInYearType = DAYS_365;
|
||||
private final String recurringDepositTypeId = VOLUNTARY;
|
||||
private final String recurringDepositFrequencyTypeId = MONTHS;
|
||||
private final String recurringDepositFrequency = "1";
|
||||
private Account[] accountList = null;
|
||||
|
||||
public String build(final String validFrom, final String validTo) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
chartSlabsMap1.put("toPeriod", "6");
|
||||
chartSlabsMap1.put("annualInterestRate", "5");
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
chartSlabsMap2.put("toPeriod", "12");
|
||||
chartSlabsMap2.put("annualInterestRate", "6");
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
chartSlabsMap3.put("toPeriod", "18");
|
||||
chartSlabsMap3.put("annualInterestRate", "7");
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
chartSlabsMap4.put("toPeriod", "24");
|
||||
chartSlabsMap4.put("annualInterestRate", "8");
|
||||
chartSlabsMap4.put("locale", LOCALE);
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
chartsMap.put("locale", LOCALE);
|
||||
chartsMap.put("chartSlabs", chartSlabs);
|
||||
charts.add(chartsMap);
|
||||
|
||||
map.put("charts", charts);
|
||||
map.put("name", this.name);
|
||||
map.put("shortName", this.shortName);
|
||||
map.put("description", this.description);
|
||||
map.put("currencyCode", this.currencyCode);
|
||||
map.put("interestCalculationDaysInYearType", this.interestCalculationDaysInYearType);
|
||||
map.put("locale", LOCALE);
|
||||
map.put("digitsAfterDecimal", DIGITS_AFTER_DECIMAL);
|
||||
map.put("inMultiplesOf", IN_MULTIPLES_OF);
|
||||
map.put("interestCalculationType", this.interestCalculationType);
|
||||
map.put("interestCompoundingPeriodType", this.interestCompoundingPeriodType);
|
||||
map.put("interestPostingPeriodType", this.interestPostingPeriodType);
|
||||
map.put("accountingRule", this.accountingRule);
|
||||
map.put("lockinPeriodFrequency", this.lockinPeriodFrequency);
|
||||
map.put("lockinPeriodFrequencyType", this.lockingPeriodFrequencyType);
|
||||
map.put("preClosurePenalApplicable", "true");
|
||||
map.put("minDepositTermTypeId", this.minDepositTermTypeId);
|
||||
map.put("minDepositTerm", this.minDepositTerm);
|
||||
map.put("maxDepositTermTypeId", this.maxDepositTermTypeId);
|
||||
map.put("maxDepositTerm", this.maxDepositTerm);
|
||||
map.put("preClosurePenalApplicable", this.preClosurePenalApplicable);
|
||||
map.put("inMultiplesOfDepositTerm", this.inMultiplesOfDepositTerm);
|
||||
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
|
||||
map.put("preClosurePenalInterest", this.preClosurePenalInterest);
|
||||
map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId);
|
||||
map.put("recurringDepositTypeId", this.recurringDepositTypeId);
|
||||
map.put("recurringDepositFrequencyTypeId", this.recurringDepositFrequencyTypeId);
|
||||
map.put("recurringDepositFrequency", this.recurringDepositFrequency);
|
||||
|
||||
if (this.accountingRule.equals(CASH_BASED)) {
|
||||
map.putAll(getAccountMappingForCashBased());
|
||||
}
|
||||
|
||||
String RecurringDepositProductCreateJson = new Gson().toJson(map);
|
||||
System.out.println(RecurringDepositProductCreateJson);
|
||||
return RecurringDepositProductCreateJson;
|
||||
}
|
||||
|
||||
public RecurringDepositProductHelper withAccountingRuleAsNone() {
|
||||
this.accountingRule = NONE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecurringDepositProductHelper withAccountingRuleAsCashBased(final Account[] account_list) {
|
||||
this.accountingRule = CASH_BASED;
|
||||
this.accountList = account_list;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForCashBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
if (accountList != null) {
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("savingsReferenceAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.LIABILITY)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("savingsControlAccountId", ID);
|
||||
map.put("transfersInSuspenseAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("interestOnSavingsAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.INCOME)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("incomeFromFeeAccountId", ID);
|
||||
map.put("incomeFromPenaltyAccountId", ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Integer createRecurringDepositProduct(final String recurrungDepositProductCreateJson,
|
||||
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
System.out.println("------------------ CREATING RECURRING DEPOSIT PRODUCT--------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_RECURRING_DEPOSIT_PRODUCT_URL, recurrungDepositProductCreateJson,
|
||||
"resourceId");
|
||||
}
|
||||
|
||||
public static ArrayList retrieveAllRecurringDepositProducts(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
System.out.println("----------------- RETRIEVING ALL RECURRING DEPOSIT PRODUCTS---------------------------");
|
||||
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, RECURRING_DEPOSIT_PRODUCT_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public static HashMap retrieveRecurringDepositProductById(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String productId) {
|
||||
System.out.println("-------------------- RETRIEVING RECURRING DEPOSIT PRODUCT BY ID --------------------------");
|
||||
final String GET_RD_PRODUCT_BY_ID_URL = RECURRING_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_RD_PRODUCT_BY_ID_URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user