fix for failing test case testSavingsInterestPostingAtPeriodEnd
This commit is contained in:
+34
-41
@@ -32,9 +32,9 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
|||||||
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
|
||||||
public class FlexibleSavingsInterestPostingIntegrationTest {
|
public class FlexibleSavingsInterestPostingIntegrationTest {
|
||||||
|
|
||||||
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||||
|
|
||||||
private ResponseSpecification responseSpec;
|
private ResponseSpecification responseSpec;
|
||||||
private RequestSpecification requestSpec;
|
private RequestSpecification requestSpec;
|
||||||
private SavingsProductHelper savingsProductHelper;
|
private SavingsProductHelper savingsProductHelper;
|
||||||
private SavingsAccountHelper savingsAccountHelper;
|
private SavingsAccountHelper savingsAccountHelper;
|
||||||
@@ -47,13 +47,13 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
|
|||||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||||
this.savingsProductHelper = new SavingsProductHelper();
|
this.savingsProductHelper = new SavingsProductHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSavingsInterestPostingAtPeriodEnd() {
|
public void testSavingsInterestPostingAtPeriodEnd() {
|
||||||
//client activation, savings activation and 1st transaction date
|
// client activation, savings activation and 1st transaction date
|
||||||
final String startDate = "01 December 2013";
|
final String startDate = "01 December 2013";
|
||||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, startDate);
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, startDate);
|
||||||
Assert.assertNotNull(clientID);
|
Assert.assertNotNull(clientID);
|
||||||
|
|
||||||
// Configuring global config flags
|
// Configuring global config flags
|
||||||
@@ -61,33 +61,32 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
|
|||||||
|
|
||||||
final Integer savingsId = createSavingsAccount(clientID, startDate);
|
final Integer savingsId = createSavingsAccount(clientID, startDate);
|
||||||
|
|
||||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000",
|
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate,
|
||||||
startDate, CommonConstants.RESPONSE_RESOURCE_ID);
|
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Perform Post interest transaction and verify the posted transaction date
|
* Perform Post interest transaction and verify the posted transaction
|
||||||
|
* date
|
||||||
*/
|
*/
|
||||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||||
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
|
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
|
||||||
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>)
|
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
|
||||||
accountDetails.get("transactions");
|
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
|
||||||
HashMap<String, Object> interestPostingTransaction = transactions.get(0);
|
for (Entry<String, Object> entry : interestPostingTransaction.entrySet())
|
||||||
for(Entry<String, Object> entry : interestPostingTransaction.entrySet())
|
System.out.println(entry.getKey() + "-" + entry.getValue().toString());
|
||||||
System.out.println(entry.getKey() + "-" + entry.getValue().toString());
|
// 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily
|
||||||
//1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily balance
|
// balance
|
||||||
//33.7016 obtained from formula in excel provided by Subramanya
|
// 33.7016 obtained from formula in excel provided by Subramanya
|
||||||
assertEquals("Equality check for interest posted amount",
|
assertEquals("Equality check for interest posted amount", "33.7016", interestPostingTransaction.get("amount").toString());
|
||||||
"33.7016", interestPostingTransaction.get("amount").toString());
|
assertEquals("Date check for Interest Posting transaction", "[2014, 3, 31]", interestPostingTransaction.get("date").toString());
|
||||||
assertEquals("Date check for Interest Posting transaction",
|
|
||||||
"[2014, 3, 31]", interestPostingTransaction.get("date").toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer createSavingsAccount(final Integer clientID, final String startDate) {
|
private Integer createSavingsAccount(final Integer clientID, final String startDate) {
|
||||||
final Integer savingsProductID = createSavingsProduct();
|
final Integer savingsProductID = createSavingsProduct();
|
||||||
Assert.assertNotNull(savingsProductID);
|
Assert.assertNotNull(savingsProductID);
|
||||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID,
|
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID, savingsProductID,
|
||||||
savingsProductID, ACCOUNT_TYPE_INDIVIDUAL, startDate);
|
ACCOUNT_TYPE_INDIVIDUAL, startDate);
|
||||||
Assert.assertNotNull(savingsId);
|
Assert.assertNotNull(savingsId);
|
||||||
HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavingsOnDate(savingsId, startDate);
|
HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavingsOnDate(savingsId, startDate);
|
||||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||||
@@ -96,10 +95,8 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
|
|||||||
return savingsId;
|
return savingsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureInterestPosting(final Boolean periodEndEnable,
|
private void configureInterestPosting(final Boolean periodEndEnable, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
final ArrayList<HashMap> globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
|
||||||
final ArrayList<HashMap> globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
|
|
||||||
this.responseSpec);
|
|
||||||
Assert.assertNotNull(globalConfig);
|
Assert.assertNotNull(globalConfig);
|
||||||
|
|
||||||
// Updating flag for interest posting at period end
|
// Updating flag for interest posting at period end
|
||||||
@@ -107,42 +104,38 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
|
|||||||
Assert.assertNotNull(periodEndConfigId);
|
Assert.assertNotNull(periodEndConfigId);
|
||||||
|
|
||||||
HashMap periodEndConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
|
HashMap periodEndConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
|
||||||
periodEndConfigId.toString());
|
periodEndConfigId.toString());
|
||||||
Assert.assertNotNull(periodEndConfigData);
|
Assert.assertNotNull(periodEndConfigData);
|
||||||
|
|
||||||
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
|
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
|
||||||
|
|
||||||
if (enabled != periodEndEnable)
|
if (enabled != periodEndEnable)
|
||||||
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||||
periodEndConfigId.toString(), periodEndEnable);
|
periodEndConfigId.toString(), periodEndEnable);
|
||||||
|
|
||||||
|
// Updating value for financial year beginning month
|
||||||
//Updating value for financial year beginning month
|
|
||||||
Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
|
Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
|
||||||
Assert.assertNotNull(financialYearBeginningConfigId);
|
Assert.assertNotNull(financialYearBeginningConfigId);
|
||||||
|
|
||||||
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
|
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec,
|
||||||
financialYearBeginningConfigId.toString());
|
this.responseSpec, financialYearBeginningConfigId.toString());
|
||||||
Assert.assertNotNull(financialYearBeginningConfigData);
|
Assert.assertNotNull(financialYearBeginningConfigData);
|
||||||
|
|
||||||
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||||
financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString());
|
financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString());
|
||||||
Assert.assertNotNull(financialYearBeginningConfigId);
|
Assert.assertNotNull(financialYearBeginningConfigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer createSavingsProduct() {
|
private Integer createSavingsProduct() {
|
||||||
final String savingsProductJSON = this.savingsProductHelper
|
final String savingsProductJSON = this.savingsProductHelper.withInterestCompoundingPeriodTypeAsDaily()
|
||||||
.withInterestCompoundingPeriodTypeAsDaily()
|
.withInterestPostingPeriodTypeAsAnnual().withInterestCalculationPeriodTypeAsDailyBalance().build();
|
||||||
.withInterestPostingPeriodTypeAsAnnual()
|
|
||||||
.withInterestCalculationPeriodTypeAsDailyBalance()
|
|
||||||
.build();
|
|
||||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reset configuration fields
|
// Reset configuration fields
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
configureInterestPosting(false, 1);
|
configureInterestPosting(false, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user