[MIFOSX-1117] Fixed test case failure issue

This commit is contained in:
Vishwa1311
2014-04-30 15:14:43 +05:30
parent d033ea22ca
commit 8191ef0211
7 changed files with 158 additions and 138 deletions
@@ -11,6 +11,9 @@ import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.Months;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -38,11 +41,22 @@ public class FixedDepositTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private FixedDepositProductHelper fixedDepositHelper;
private FixedDepositProductHelper fixedDepositProductHelper;
private FixedDepositAccountHelper fixedDepositAccountHelper;
private AccountHelper accountHelper;
private SavingsAccountHelper savingsAccountHelper;
private static final String WHOLE_TERM = "1";
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
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";
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";
@@ -60,7 +74,7 @@ public class FixedDepositTest {
@Test
public void testFixedDepositAccountWithPrematureClosureTypeWithdrawal() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = 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);
@@ -94,13 +108,8 @@ public class FixedDepositTest {
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);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -134,7 +143,7 @@ public class FixedDepositTest {
@Test
public void testFixedDepositAccountUpdation() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
@@ -148,8 +157,8 @@ public class FixedDepositTest {
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());
String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assert.assertNotNull(clientId);
@@ -157,24 +166,26 @@ public class FixedDepositTest {
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO);
Assert.assertNotNull(fixedDepositProductId);
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositHelper.retrieveAllFixedDepositProducts(this.requestSpec,
ArrayList<HashMap> allFixedDepositProductsData = this.fixedDepositProductHelper.retrieveAllFixedDepositProducts(this.requestSpec,
this.responseSpec);
HashMap fixedDepositProductData = this.fixedDepositHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec,
fixedDepositProductId.toString());
HashMap fixedDepositProductData = this.fixedDepositProductHelper.retrieveFixedDepositProductById(this.requestSpec,
this.responseSpec, fixedDepositProductId.toString());
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
VALID_TO, SUBMITTED_ON_DATE);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
todaysDate.add(Calendar.DATE, -1);
SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateFixedDepositAccount(clientId.toString(),
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), VALID_FROM, VALID_TO);
fixedDepositProductId.toString(), fixedDepositAccountId.toString(), VALID_FROM, VALID_TO, WHOLE_TERM, SUBMITTED_ON_DATE);
Assert.assertTrue(modificationsHashMap.containsKey("submittedOnDate"));
}
@Test
public void testFixedDepositAccountWithPrematureClosureTypeTransferToSavings() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = 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);
@@ -218,13 +229,8 @@ public class FixedDepositTest {
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);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -266,13 +272,13 @@ public class FixedDepositTest {
Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance");
Float expectedSavingsBalance = balanceBefore + prematurityAmount;
Assert.assertEquals("Verifying Savings Account Balance after Premature Closure", expectedSavingsBalance, balanceAfter);
Assert.assertEquals("Verifying Savings Account Balance after Premature Closure", balanceAfter, expectedSavingsBalance);
}
@Test
public void testFixedDepositAccountWithPrematureClosureTypeReinvest() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = 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);
@@ -304,13 +310,8 @@ public class FixedDepositTest {
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);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -342,7 +343,7 @@ public class FixedDepositTest {
@Test
public void testFixedDepositAccountUndoApproval() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
@@ -366,13 +367,8 @@ public class FixedDepositTest {
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);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -388,7 +384,7 @@ public class FixedDepositTest {
@Test
public void testFixedDepositAccountRejectedAndClosed() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
@@ -413,13 +409,8 @@ public class FixedDepositTest {
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);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -433,7 +424,7 @@ public class FixedDepositTest {
@Test
public void testFixedDepositAccountWithdrawnByClientAndClosed() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
@@ -458,13 +449,8 @@ public class FixedDepositTest {
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);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -478,7 +464,7 @@ public class FixedDepositTest {
@Test
public void testFixedDepositAccountIsDeleted() {
this.fixedDepositHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
@@ -501,13 +487,8 @@ public class FixedDepositTest {
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);
VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(fixedDepositAccountId);
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
@@ -528,10 +509,10 @@ public class FixedDepositTest {
}
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom,
final String validTo, final String submittedOnDate) {
final String validTo, final String submittedOnDate, final String penalInterestType) {
System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, validFrom, validTo);
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, validFrom, validTo, penalInterestType);
return this.fixedDepositAccountHelper
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec);
}
@@ -9,6 +9,8 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import org.joda.time.DateTime;
import org.joda.time.Months;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -40,6 +42,9 @@ public class RecurringDepositTest {
private AccountHelper accountHelper;
private RecurringDepositAccountHelper recurringDepositAccountHelper;
private static final String WHOLE_TERM = "1";
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
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";
@@ -51,6 +56,7 @@ public class RecurringDepositTest {
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();
}
@@ -90,7 +96,7 @@ public class RecurringDepositTest {
Assert.assertNotNull(recurringDepositProductId);
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -177,7 +183,7 @@ public class RecurringDepositTest {
Assert.assertNotNull(recurringDepositProductId);
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -225,10 +231,9 @@ public class RecurringDepositTest {
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));
Assert.assertEquals("Verifying Savings Account Balance after Premature Closure", decimalFormat.format(expectedSavingsBalance),
decimalFormat.format(balanceAfter));
}
@@ -272,7 +277,7 @@ public class RecurringDepositTest {
this.responseSpec, recurringDepositProductId.toString());
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -322,8 +327,8 @@ public class RecurringDepositTest {
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());
String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assert.assertNotNull(clientId);
@@ -331,17 +336,15 @@ public class RecurringDepositTest {
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);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
todaysDate.add(Calendar.DATE, -1);
SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
HashMap modificationsHashMap = this.recurringDepositAccountHelper.updateRecurringDepositAccount(clientId.toString(),
recurringDepositProductId.toString(), recurringDepositAccountId.toString(), VALID_FROM, VALID_TO);
recurringDepositProductId.toString(), recurringDepositAccountId.toString(), VALID_FROM, VALID_TO, WHOLE_TERM, SUBMITTED_ON_DATE);
Assert.assertTrue(modificationsHashMap.containsKey("submittedOnDate"));
}
@@ -372,13 +375,8 @@ public class RecurringDepositTest {
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);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -420,13 +418,8 @@ public class RecurringDepositTest {
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);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -466,13 +459,8 @@ public class RecurringDepositTest {
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);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -510,13 +498,8 @@ public class RecurringDepositTest {
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);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -564,7 +547,7 @@ public class RecurringDepositTest {
Assert.assertNotNull(recurringDepositProductId);
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE);
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM);
Assert.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
@@ -601,10 +584,10 @@ public class RecurringDepositTest {
}
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
final String validTo, final String submittedOnDate) {
final String validTo, final String submittedOnDate, final String penalInterestType) {
System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------");
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, validFrom, validTo);
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, validFrom, validTo, penalInterestType);
return this.recurringDepositAccountHelper.applyRecurringDepositApplication(recurringDepositApplicationJSON, this.requestSpec,
this.responseSpec);
}
@@ -45,8 +45,6 @@ public class FixedDepositAccountHelper {
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";
@@ -63,8 +61,6 @@ public class FixedDepositAccountHelper {
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;
@@ -78,17 +74,17 @@ public class FixedDepositAccountHelper {
private String inMultiplesOfDepositTerm = "2";
private String inMultiplesOfDepositTermTypeId = MONTHS;
private String preClosurePenalInterest = "2";
private String preClosurePenalInterestOnTypeId = WHOLE_TERM;
private String interestCalculationDaysInYearType = DAYS_365;
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) {
public String build(final String clientId, final String productId, final String validFrom, final String validTo,
final String penalInterestType) {
final HashMap<String, Object> map = new HashMap<String, Object>();
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
@@ -159,7 +155,7 @@ public class FixedDepositAccountHelper {
map.put("inMultiplesOfDepositTerm", this.inMultiplesOfDepositTerm);
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
map.put("preClosurePenalInterest", this.preClosurePenalInterest);
map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId);
map.put("preClosurePenalInterestOnTypeId", penalInterestType);
map.put("depositAmount", this.depositAmount);
map.put("depositPeriod", this.depositPeriod);
map.put("depositPeriodFrequencyId", this.depositPeriodFrequencyId);
@@ -183,7 +179,7 @@ public class FixedDepositAccountHelper {
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");
@@ -205,16 +201,27 @@ public class FixedDepositAccountHelper {
}
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom,
final String validTo) {
final String validTo, final String penalInterestType, final String submittedOnDate) {
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);
.withSubmittedOnDate(submittedOnDate) //
.build(clientID, productID, validFrom, validTo, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
}
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID, final String submittedOnDate,
final String validFrom, final String validTo, final String numberOfDaysPerYear, final String penalInterestType,
final String interestCalculationType, final String interestCompoundingPeriodType, final String interestPostingPeriodType) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) //
.withNumberOfDaysPerYear(numberOfDaysPerYear) //
.withInterestCalculationPeriodType(interestCalculationType) //
.withInterestCompoundingPeriodType(interestCompoundingPeriodType) //
.withInterestPostingPeriodType(interestPostingPeriodType) //
.build(clientID, productID, validFrom, validTo, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
@@ -385,7 +392,7 @@ public class FixedDepositAccountHelper {
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 + "?"
@@ -398,4 +405,24 @@ public class FixedDepositAccountHelper {
return this;
}
public FixedDepositAccountHelper withNumberOfDaysPerYear(final String numberOfDaysPerYearTypeId) {
this.interestCalculationDaysInYearType = numberOfDaysPerYearTypeId;
return this;
}
public FixedDepositAccountHelper withInterestCalculationPeriodType(final String interestCalculationTypeId) {
this.interestCalculationType = interestCalculationTypeId;
return this;
}
public FixedDepositAccountHelper withInterestCompoundingPeriodType(final String interestCompoundingPeriodTypeId) {
this.interestCompoundingPeriodType = interestCompoundingPeriodTypeId;
return this;
}
public FixedDepositAccountHelper withInterestPostingPeriodType(final String interestPostingPeriodTypeId) {
this.interestPostingPeriodType = interestPostingPeriodTypeId;
return this;
}
}
@@ -59,10 +59,11 @@ public class FixedDepositAccountStatusChecker {
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;
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"));
@@ -12,6 +12,7 @@ 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;
@@ -67,6 +68,7 @@ public class FixedDepositProductHelper {
private String maxDepositTerm = "10";
private String maxDepositTermTypeId = YEARS;
private String inMultiplesOfDepositTerm = "2";
private final String depositAmount = "100000";
private String inMultiplesOfDepositTermTypeId = MONTHS;
private String preClosurePenalInterest = "2";
private String preClosurePenalInterestOnTypeId = WHOLE_TERM;
@@ -144,6 +146,7 @@ public class FixedDepositProductHelper {
map.put("minDepositTerm", this.minDepositTerm);
map.put("maxDepositTermTypeId", this.maxDepositTermTypeId);
map.put("maxDepositTerm", this.maxDepositTerm);
map.put("depositAmount", this.depositAmount);
map.put("preClosurePenalApplicable", this.preClosurePenalApplicable);
map.put("inMultiplesOfDepositTerm", this.inMultiplesOfDepositTerm);
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
@@ -158,7 +161,7 @@ public class FixedDepositProductHelper {
System.out.println(FixedDepositProductCreateJson);
return FixedDepositProductCreateJson;
}
public FixedDepositProductHelper withAccountingRuleAsNone() {
this.accountingRule = NONE;
return this;
@@ -222,7 +225,8 @@ public class FixedDepositProductHelper {
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");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId,
"chartSlabs");
return response;
}
@@ -62,8 +62,6 @@ public class RecurringDepositAccountHelper {
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;
@@ -77,12 +75,11 @@ public class RecurringDepositAccountHelper {
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 depositAmount = "2000";
private final String depositPeriod = "14";
private final String depositPeriodFrequencyId = MONTHS;
private final String recurringDepositFrequency = "1";
@@ -90,7 +87,8 @@ public class RecurringDepositAccountHelper {
private final String recurringDepositAmount = "2000";
private String submittedOnDate = "";
public String build(final String clientId, final String productId, final String validFrom, final String validTo) {
public String build(final String clientId, final String productId, final String validFrom, final String validTo,
final String penalInterestType) {
final HashMap<String, Object> map = new HashMap<String, Object>();
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
@@ -161,7 +159,7 @@ public class RecurringDepositAccountHelper {
map.put("inMultiplesOfDepositTerm", this.inMultiplesOfDepositTerm);
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
map.put("preClosurePenalInterest", this.preClosurePenalInterest);
map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId);
map.put("preClosurePenalInterestOnTypeId", penalInterestType);
map.put("depositAmount", this.depositAmount);
map.put("depositPeriod", this.depositPeriod);
map.put("depositPeriodFrequencyId", this.depositPeriodFrequencyId);
@@ -188,15 +186,29 @@ public class RecurringDepositAccountHelper {
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 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 updateRecurringDepositAccount(final String clientID, final String productID, final String accountID,
final String validFrom, final String validTo) {
final String validFrom, final String validTo, final String penalInterestType, final String submittedOnDate) {
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
Calendar todaysDate = Calendar.getInstance();
@@ -204,8 +216,8 @@ public class RecurringDepositAccountHelper {
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);
.withSubmittedOnDate(submittedOnDate) //
.build(clientID, productID, validFrom, validTo, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
@@ -269,7 +281,7 @@ public class RecurringDepositAccountHelper {
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(
@@ -351,7 +363,7 @@ public class RecurringDepositAccountHelper {
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);
@@ -402,9 +414,10 @@ public class RecurringDepositAccountHelper {
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;
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
}
public RecurringDepositAccountHelper withSubmittedOnDate(final String recurringDepositApplicationSubmittedDate) {
@@ -30,6 +30,7 @@ public class RecurringDepositProductHelper {
}
private static final String RECURRING_DEPOSIT_PRODUCT_URL = "/mifosng-provider/api/v1/recurringdepositproducts";
private static final String INTEREST_CHART_URL = "/mifosng-provider/api/v1/interestratecharts";
private static final String CREATE_RECURRING_DEPOSIT_PRODUCT_URL = RECURRING_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER;
private static final String LOCALE = "en_GB";
@@ -78,6 +79,7 @@ public class RecurringDepositProductHelper {
private final String recurringDepositTypeId = VOLUNTARY;
private final String recurringDepositFrequencyTypeId = MONTHS;
private final String recurringDepositFrequency = "1";
private final String depositAmount = "100000";
private Account[] accountList = null;
public String build(final String validFrom, final String validTo) {
@@ -156,6 +158,7 @@ public class RecurringDepositProductHelper {
map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId);
map.put("recurringDepositTypeId", this.recurringDepositTypeId);
map.put("recurringDepositFrequencyTypeId", this.recurringDepositFrequencyTypeId);
map.put("depositAmount", this.depositAmount);
map.put("recurringDepositFrequency", this.recurringDepositFrequency);
if (this.accountingRule.equals(CASH_BASED)) {
@@ -228,4 +231,12 @@ public class RecurringDepositProductHelper {
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;
}
}