remove all trailing spaces in Java files (FINERACT-821)

find . -type f -name "*.java" -exec sed -i 's/ *$//' '{}' ';'
This commit is contained in:
Michael Vorburger
2020-01-19 19:58:21 +01:00
committed by Michael Vorburger ⛑️
parent b0196049f1
commit dd7503f296
862 changed files with 4984 additions and 4984 deletions
@@ -86,7 +86,7 @@ public class AccountNumberPreferencesTest {
private Integer groupID; private Integer groupID;
private Integer centerId; private Integer centerId;
private String groupAccountNo; private String groupAccountNo;
@Before @Before
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -191,17 +191,17 @@ public class AccountNumberPreferencesTest {
this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference( this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Savings (ID: " + this.savingsAccountNumberPreferenceId); System.out.println("Successfully created account number preferences for Savings (ID: " + this.savingsAccountNumberPreferenceId);
this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference( this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Groups (ID: " + this.groupsAccountNumberPreferenceId); System.out.println("Successfully created account number preferences for Groups (ID: " + this.groupsAccountNumberPreferenceId);
this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference( this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Center (ID: " + this.centerAccountNumberPreferenceId); System.out.println("Successfully created account number preferences for Center (ID: " + this.centerAccountNumberPreferenceId);
this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId, this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId,
this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId, this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId,
this.centerAccountNumberPreferenceId, this.responseSpec, this.requestSpec); this.centerAccountNumberPreferenceId, this.responseSpec, this.requestSpec);
this.createAccountNumberPreferenceInvalidData("1000", "1001"); this.createAccountNumberPreferenceInvalidData("1000", "1001");
@@ -278,7 +278,7 @@ public class AccountNumberPreferencesTest {
this.createAndValidateClientWithoutAccountPreference(); this.createAndValidateClientWithoutAccountPreference();
} }
} }
private void createAndValidateGroup(Boolean isAccountPreferenceSetUp) { private void createAndValidateGroup(Boolean isAccountPreferenceSetUp) {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec); this.groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
@@ -286,25 +286,25 @@ public class AccountNumberPreferencesTest {
this.groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString()); this.groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString());
GroupHelper.verifyGroupActivatedOnServer(this.requestSpec, this.responseSpec, groupID, true); GroupHelper.verifyGroupActivatedOnServer(this.requestSpec, this.responseSpec, groupID, true);
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + this.groupID + "?" + Utils.TENANT_IDENTIFIER; final String GROUP_URL = "/fineract-provider/api/v1/groups/" + this.groupID + "?" + Utils.TENANT_IDENTIFIER;
this.groupAccountNo = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "accountNo"); this.groupAccountNo = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "accountNo");
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String groupsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String groupsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.groupsAccountNumberPreferenceId, "prefixType.value"); this.groupsAccountNumberPreferenceId, "prefixType.value");
if (groupsPrefixName.equals(this.officeName)) { if (groupsPrefixName.equals(this.officeName)) {
final String groupOfficeName = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "officeName"); final String groupOfficeName = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "officeName");
this.validateAccountNumberLengthAndStartsWithPrefix(this.groupAccountNo, groupOfficeName); this.validateAccountNumberLengthAndStartsWithPrefix(this.groupAccountNo, groupOfficeName);
} }
} else { } else {
validateAccountNumberLengthAndStartsWithPrefix(this.groupAccountNo, null); validateAccountNumberLengthAndStartsWithPrefix(this.groupAccountNo, null);
} }
} }
private void createAndValidateCenter(Boolean isAccountPreferenceSetUp) { private void createAndValidateCenter(Boolean isAccountPreferenceSetUp) {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
Integer officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007"); Integer officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007");
@@ -314,21 +314,21 @@ public class AccountNumberPreferencesTest {
CenterDomain center = CenterHelper.retrieveByID(centerId, requestSpec, responseSpec); CenterDomain center = CenterHelper.retrieveByID(centerId, requestSpec, responseSpec);
Assert.assertNotNull(center); Assert.assertNotNull(center);
Assert.assertTrue(center.getName().equals(name)); Assert.assertTrue(center.getName().equals(name));
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.centerAccountNumberPreferenceId, "prefixType.value"); this.centerAccountNumberPreferenceId, "prefixType.value");
final String CENTER_URL = "/fineract-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER; final String CENTER_URL = "/fineract-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER;
if (centerPrefixName.equals(this.officeName)) { if (centerPrefixName.equals(this.officeName)) {
final String centerOfficeName = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "officeName"); final String centerOfficeName = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "officeName");
this.validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), centerOfficeName); this.validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), centerOfficeName);
} }
} else { } else {
validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), null); validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), null);
} }
} }
private void createAndValidateClientWithoutAccountPreference() { private void createAndValidateClientWithoutAccountPreference() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
@@ -49,9 +49,9 @@ import com.jayway.restassured.specification.ResponseSpecification;
* {@link org.apache.fineract.batch.command.CommandStrategyProvider}. This tests * {@link org.apache.fineract.batch.command.CommandStrategyProvider}. This tests
* the response provided by commandStrategy by injecting it with a * the response provided by commandStrategy by injecting it with a
* {@code BatchRequest}. * {@code BatchRequest}.
* *
* @author RishabhShukla * @author RishabhShukla
* *
* @see org.apache.fineract.integrationtests.common.BatchHelper * @see org.apache.fineract.integrationtests.common.BatchHelper
* @see org.apache.fineract.batch.domain.BatchRequest * @see org.apache.fineract.batch.domain.BatchRequest
*/ */
@@ -81,7 +81,7 @@ public class BatchApiTest {
* Tests for the unimplemented command Strategies by returning 501 status * Tests for the unimplemented command Strategies by returning 501 status
* code. For a unknownRequest a statusCode 501 is returned back with * code. For a unknownRequest a statusCode 501 is returned back with
* response. * response.
* *
* @see org.apache.fineract.batch.command.internal.UnknownCommandStrategy * @see org.apache.fineract.batch.command.internal.UnknownCommandStrategy
*/ */
@Test @Test
@@ -104,7 +104,7 @@ public class BatchApiTest {
* Tests for the successful response for a createClient request from * Tests for the successful response for a createClient request from
* createClientCommand. A successful response with statusCode '200' is * createClientCommand. A successful response with statusCode '200' is
* returned back. * returned back.
* *
* @see org.apache.fineract.batch.command.internal.CreateClientCommandStrategy * @see org.apache.fineract.batch.command.internal.CreateClientCommandStrategy
*/ */
@Test @Test
@@ -125,7 +125,7 @@ public class BatchApiTest {
* fails. If Query Parameter 'enclosingTransaction' is set to 'true' and if * fails. If Query Parameter 'enclosingTransaction' is set to 'true' and if
* one of the request in BatchRequest fails then all transactions are rolled * one of the request in BatchRequest fails then all transactions are rolled
* back. * back.
* *
* @see org.apache.fineract.batch.command.internal.CreateClientCommandStrategy * @see org.apache.fineract.batch.command.internal.CreateClientCommandStrategy
* @see org.apache.fineract.batch.api.BatchApiResource * @see org.apache.fineract.batch.api.BatchApiResource
* @see org.apache.fineract.batch.service.BatchApiService * @see org.apache.fineract.batch.service.BatchApiService
@@ -167,7 +167,7 @@ public class BatchApiTest {
* Tests that a client information was successfully updated through * Tests that a client information was successfully updated through
* updateClientCommand. A 'changes' parameter is returned in the response * updateClientCommand. A 'changes' parameter is returned in the response
* after successful update of client information. * after successful update of client information.
* *
* @see org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy * @see org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy
*/ */
@Test @Test
@@ -202,7 +202,7 @@ public class BatchApiTest {
* 200(OK) status. It creates a new client and apply a loan to that client. * 200(OK) status. It creates a new client and apply a loan to that client.
* This also verifies the successful resolution of dependencies among two * This also verifies the successful resolution of dependencies among two
* requests. * requests.
* *
* @see org.apache.fineract.batch.command.internal.ApplyLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.ApplyLoanCommandStrategy
*/ */
@Test @Test
@@ -251,7 +251,7 @@ public class BatchApiTest {
* Tests that a new savings accounts was applied to an existing client and a * Tests that a new savings accounts was applied to an existing client and a
* 200(OK) status was returned. It first creates a new client and a savings * 200(OK) status was returned. It first creates a new client and a savings
* product, then uses the cliendId and ProductId to apply a savings account. * product, then uses the cliendId and ProductId to apply a savings account.
* *
* @see org.apache.fineract.batch.command.internal.ApplySavingsCommandStrategy * @see org.apache.fineract.batch.command.internal.ApplySavingsCommandStrategy
*/ */
@Test @Test
@@ -294,7 +294,7 @@ public class BatchApiTest {
* Collected properly 200(OK) status was returned for successful responses. * Collected properly 200(OK) status was returned for successful responses.
* It first creates a new client and apply a loan, then creates a new charge * It first creates a new client and apply a loan, then creates a new charge
* for the create loan and then fetches all the applied charges * for the create loan and then fetches all the applied charges
* *
* @see org.apache.fineract.batch.command.internal.CollectChargesCommandStrategy * @see org.apache.fineract.batch.command.internal.CollectChargesCommandStrategy
* @see org.apache.fineract.batch.command.internal.CreateChargeCommandStrategy * @see org.apache.fineract.batch.command.internal.CreateChargeCommandStrategy
*/ */
@@ -409,7 +409,7 @@ public class BatchApiTest {
* Test for the successful activation of a pending client using * Test for the successful activation of a pending client using
* 'ActivateClientCommandStrategy'. A '200' status code is expected on * 'ActivateClientCommandStrategy'. A '200' status code is expected on
* successful activation. * successful activation.
* *
* @see org.apache.fineract.batch.command.internal.ActivateClientCommandStrategy * @see org.apache.fineract.batch.command.internal.ActivateClientCommandStrategy
*/ */
@Test @Test
@@ -439,7 +439,7 @@ public class BatchApiTest {
* Test for the successful approval and disbursal of a loan using * Test for the successful approval and disbursal of a loan using
* 'ApproveLoanCommandStrategy' and 'DisburseLoanCommandStrategy'. A '200' * 'ApproveLoanCommandStrategy' and 'DisburseLoanCommandStrategy'. A '200'
* status code is expected on successful activation. * status code is expected on successful activation.
* *
* @see org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy
* @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy
*/ */
@@ -43,7 +43,7 @@ import com.jayway.restassured.specification.ResponseSpecification;
* Test class for testing the integration of Batch API with custom batch * Test class for testing the integration of Batch API with custom batch
* requests and various user defined workflow. Like in the case of mifos * requests and various user defined workflow. Like in the case of mifos
* community-app * community-app
* *
* @author Rishabh Shukla * @author Rishabh Shukla
*/ */
public class BatchRequestsIntegrationTest { public class BatchRequestsIntegrationTest {
@@ -70,12 +70,12 @@ public class BatchRequestsIntegrationTest {
@Test @Test
/** /**
* Tests that a loan is successfully applied to client members of a group. * Tests that a loan is successfully applied to client members of a group.
* Firstly, it'll create a few new clients and then will add those clients * Firstly, it'll create a few new clients and then will add those clients
* to the group. Then a few loans will be created and one of those loans * to the group. Then a few loans will be created and one of those loans
* will be chosen at random and similarily a few of the created clients will * will be chosen at random and similarily a few of the created clients will
* be chosen on random. Now, the selected loan will be applied to these * be chosen on random. Now, the selected loan will be applied to these
* clients through Batch - API ApplyLoanCommandStrategy. * clients through Batch - API ApplyLoanCommandStrategy.
*/ */
public void shouldReturnOkStatusForLoansAppliedToSelectedClients() { public void shouldReturnOkStatusForLoansAppliedToSelectedClients() {
@@ -239,7 +239,7 @@ public class CenterIntegrationTest {
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID); CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec,
this.responseSpec, groupID.toString(), this.responseSpec, groupID.toString(),
staffId.longValue()); staffId.longValue());
@@ -248,7 +248,7 @@ public class CenterIntegrationTest {
Assert.assertNotNull(centerWithStaffAssigned); Assert.assertNotNull(centerWithStaffAssigned);
Assert.assertTrue(centerWithStaffAssigned.getId().intValue() == groupID); Assert.assertTrue(centerWithStaffAssigned.getId().intValue() == groupID);
Assert.assertTrue(centerWithStaffAssigned.getStaffId().intValue() == staffId); Assert.assertTrue(centerWithStaffAssigned.getStaffId().intValue() == staffId);
final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec, final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec,
this.responseSpec, groupID.toString(), this.responseSpec, groupID.toString(),
staffId.longValue()); staffId.longValue());
@@ -257,7 +257,7 @@ public class CenterIntegrationTest {
Assert.assertNotNull(centerWithStaffUnssigned); Assert.assertNotNull(centerWithStaffUnssigned);
Assert.assertTrue(centerWithStaffUnssigned.getId().intValue() == groupID); Assert.assertTrue(centerWithStaffUnssigned.getId().intValue() == groupID);
Assert.assertTrue(centerWithStaffUnssigned.getStaffId() == null); Assert.assertTrue(centerWithStaffUnssigned.getStaffId() == null);
} }
} }
@@ -108,11 +108,11 @@ public class ClientSavingsIntegrationTest {
this.savingsAccountHelper.postInterestForSavings(savingsId); this.savingsAccountHelper.postInterestForSavings(savingsId);
summary = this.savingsAccountHelper.getSavingsSummary(savingsId); summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
Assert.assertFalse(summaryBefore.equals(summary)); Assert.assertFalse(summaryBefore.equals(summary));
final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId); final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId);
// verifySavingsInterest(savingsInterest); // verifySavingsInterest(savingsInterest);
} }
@Test @Test
public void testSavingsAccountWithMinBalanceForInterestCalculation() { public void testSavingsAccountWithMinBalanceForInterestCalculation() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -703,7 +703,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
* *
* @param activationDate * @param activationDate
* this value is every time first day of previous month * this value is every time first day of previous month
*/ */
@@ -735,7 +735,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Perform Deposit transaction on last day of month and verify account * Perform Deposit transaction on last day of month and verify account
* balance. * balance.
* *
* @param transactionDate * @param transactionDate
* this value is every time last day of previous month * this value is every time last day of previous month
*/ */
@@ -785,7 +785,7 @@ public class ClientSavingsIntegrationTest {
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountPostInterestOnLastDayWithOverdraft() { public void testSavingsAccountPostInterestOnLastDayWithOverdraft() {
@@ -845,7 +845,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
* *
* @param activationDate * @param activationDate
* this value is every time first day of previous month * this value is every time first day of previous month
*/ */
@@ -876,7 +876,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Perform Deposit transaction on last day of month and verify account * Perform Deposit transaction on last day of month and verify account
* balance. * balance.
* *
* @param transactionDate * @param transactionDate
* this value is every time last day of previous month * this value is every time last day of previous month
*/ */
@@ -1120,7 +1120,7 @@ public class ClientSavingsIntegrationTest {
.println("-----Post Interest As on Successfully Worked----------"); .println("-----Post Interest As on Successfully Worked----------");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountPostInterestOnLastDayWithdrawalWithOverdraft() { public void testSavingsAccountPostInterestOnLastDayWithdrawalWithOverdraft() {
@@ -1180,7 +1180,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
* *
* @param activationDate * @param activationDate
* this value is every time first day of previous month * this value is every time first day of previous month
*/ */
@@ -1219,11 +1219,11 @@ public class ClientSavingsIntegrationTest {
balance -= new Float(WITHDRAW_AMOUNT); balance -= new Float(WITHDRAW_AMOUNT);
assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount")); assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount"));
assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance")); assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
/*** /***
* Perform Deposit transaction on last day of month and verify account * Perform Deposit transaction on last day of month and verify account
* balance. * balance.
* *
* @param transactionDate * @param transactionDate
* this value is every time last day of previous month * this value is every time last day of previous month
*/ */
@@ -1462,7 +1462,7 @@ public class ClientSavingsIntegrationTest {
System.out System.out
.println("-----Post Interest As on Successfully Worked----------"); .println("-----Post Interest As on Successfully Worked----------");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountPostInterestWithOverdraft() { public void testSavingsAccountPostInterestWithOverdraft() {
@@ -1523,7 +1523,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
* *
* @param activationDate * @param activationDate
* this value is every time first day of previous month * this value is every time first day of previous month
*/ */
@@ -1555,7 +1555,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Perform Deposit transaction on last day of month and verify account * Perform Deposit transaction on last day of month and verify account
* balance. * balance.
* *
* @param transactionDate * @param transactionDate
* this value is every time last day of previous month * this value is every time last day of previous month
*/ */
@@ -1619,7 +1619,7 @@ public class ClientSavingsIntegrationTest {
final String INTEREST_POSTING_DATE = dateFormat.format(interestPostingDate.getTime()); final String INTEREST_POSTING_DATE = dateFormat.format(interestPostingDate.getTime());
final String TODYS_POSTING_DATE = dateFormat.format(todysDate.getTime()); final String TODYS_POSTING_DATE = dateFormat.format(todysDate.getTime());
String withdrawBalance = "true"; String withdrawBalance = "true";
if (TODYS_POSTING_DATE.equalsIgnoreCase(INTEREST_POSTING_DATE)) { if (TODYS_POSTING_DATE.equalsIgnoreCase(INTEREST_POSTING_DATE)) {
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, responseSpec); final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, responseSpec);
@@ -1687,11 +1687,11 @@ public class ClientSavingsIntegrationTest {
final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH); final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH);
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth); todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime()); final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime());
Calendar postedDate = Calendar.getInstance(); Calendar postedDate = Calendar.getInstance();
postedDate.set(Calendar.DAY_OF_MONTH, 1); postedDate.set(Calendar.DAY_OF_MONTH, 1);
final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime()); final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime());
Calendar postedLastDate = Calendar.getInstance(); Calendar postedLastDate = Calendar.getInstance();
int countOfDate=postedDate.getActualMaximum(Calendar.DAY_OF_MONTH); int countOfDate=postedDate.getActualMaximum(Calendar.DAY_OF_MONTH);
System.out.println("count Of Date---> "+countOfDate); System.out.println("count Of Date---> "+countOfDate);
@@ -1700,7 +1700,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
* *
* @param activationDate * @param activationDate
* this value is every time first day of previous month * this value is every time first day of previous month
*/ */
@@ -1732,7 +1732,7 @@ public class ClientSavingsIntegrationTest {
/*** /***
* Perform Deposit transaction on last day of month and verify account * Perform Deposit transaction on last day of month and verify account
* balance. * balance.
* *
* @param transactionDate * @param transactionDate
* this value is every time last day of previous month * this value is every time last day of previous month
*/ */
@@ -1750,8 +1750,8 @@ public class ClientSavingsIntegrationTest {
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
summary = (HashMap) accountDetails.get("summary"); summary = (HashMap) accountDetails.get("summary");
Float actualInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString()); Float actualInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
/*** /***
* Calculate expected interest to be posted, interest should be posted * Calculate expected interest to be posted, interest should be posted
* for one day only because deposit transaction happened on last day of * for one day only because deposit transaction happened on last day of
@@ -1773,14 +1773,14 @@ public class ClientSavingsIntegrationTest {
decimalFormat.applyPattern("#.###"); decimalFormat.applyPattern("#.###");
interestPosted = new Float(decimalFormat.format(interestPosted)); interestPosted = new Float(decimalFormat.format(interestPosted));
actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted)); actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted));
assertEquals("Verifying interest posted", interestPosted, actualInterestPosted); assertEquals("Verifying interest posted", interestPosted, actualInterestPosted);
System.out.println("------Post Interest As On Successful Worked--------"); System.out.println("------Post Interest As On Successful Worked--------");
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, POSTED_LAST_TRANSACTION_DATE); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, POSTED_LAST_TRANSACTION_DATE);
HashMap accountLastDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); HashMap accountLastDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
summary = (HashMap) accountLastDetails.get("summary"); summary = (HashMap) accountLastDetails.get("summary");
Float actualLastInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString()); Float actualLastInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
final Float nominalLastAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString()); final Float nominalLastAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
final HashMap interestLastCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType"); final HashMap interestLastCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
final Integer daysLastInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString()); final Integer daysLastInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
@@ -1788,18 +1788,18 @@ public class ClientSavingsIntegrationTest {
double perLastDay = (double) 1 / (daysInYear); double perLastDay = (double) 1 / (daysInYear);
double interestLastPerDay = interestLastRateInFraction * perLastDay; double interestLastPerDay = interestLastRateInFraction * perLastDay;
Float interestLastPosted = (float) (interestLastPerDay * balance * 1); Float interestLastPosted = (float) (interestLastPerDay * balance * 1);
DecimalFormat decimalLastFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US)); DecimalFormat decimalLastFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
decimalLastFormat.applyPattern("#.###"); decimalLastFormat.applyPattern("#.###");
interestLastPosted = new Float(decimalLastFormat.format(interestLastPosted)); interestLastPosted = new Float(decimalLastFormat.format(interestLastPosted));
actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted)); actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted));
assertEquals("Verifying interest posted", interestLastPosted, actualInterestPosted); assertEquals("Verifying interest posted", interestLastPosted, actualInterestPosted);
System.out.println("------Post Interest As On Successful Worked--------"); System.out.println("------Post Interest As On Successful Worked--------");
} }
@Test @Test
public void testSavingsAccount_WITH_WITHHOLD_TAX() { public void testSavingsAccount_WITH_WITHHOLD_TAX() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -1897,7 +1897,7 @@ public class ClientSavingsIntegrationTest {
Assert.assertEquals(expected, actual, 1); Assert.assertEquals(expected, actual, 1);
} }
@Test @Test
public void testSavingsAccount_DormancyTracking() { public void testSavingsAccount_DormancyTracking() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -1913,7 +1913,7 @@ public class ClientSavingsIntegrationTest {
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId), true); minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft, String.valueOf(taxGroupId), true);
Assert.assertNotNull(savingsProductID); Assert.assertNotNull(savingsProductID);
final Integer savingsChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, final Integer savingsChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getSavingsNoActivityFeeJSON()); ChargesHelper.getSavingsNoActivityFeeJSON());
Assert.assertNotNull(savingsChargeId); Assert.assertNotNull(savingsChargeId);
@@ -1961,14 +1961,14 @@ public class ClientSavingsIntegrationTest {
TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID); TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
transactionDate = transactionDate.minusDays(30); transactionDate = transactionDate.minusDays(30);
} }
SchedulerJobHelper jobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); SchedulerJobHelper jobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec);
try { try {
jobHelper.executeJob("Update Savings Dormant Accounts"); jobHelper.executeJob("Update Savings Dormant Accounts");
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
//VERIFY WITHIN PROVIDED RANGE DOESN'T INACTIVATE //VERIFY WITHIN PROVIDED RANGE DOESN'T INACTIVATE
savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(0)); savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(0));
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
@@ -2010,7 +2010,7 @@ public class ClientSavingsIntegrationTest {
chargeAmt = 100f; chargeAmt = 100f;
balance -= chargeAmt; balance -= chargeAmt;
assertEquals("Verifying account Balance", balance, summary.get("accountBalance")); assertEquals("Verifying account Balance", balance, summary.get("accountBalance"));
TRANSACTION_DATE = formatter.print(new LocalDate()); TRANSACTION_DATE = formatter.print(new LocalDate());
depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsList.get(2), DEPOSIT_AMOUNT, depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsList.get(2), DEPOSIT_AMOUNT,
TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID); TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -2018,7 +2018,7 @@ public class ClientSavingsIntegrationTest {
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
savingsStatusHashMap = SavingsStatusChecker.getSubStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(2)); savingsStatusHashMap = SavingsStatusChecker.getSubStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(2));
SavingsStatusChecker.verifySavingsSubStatusNone(savingsStatusHashMap); SavingsStatusChecker.verifySavingsSubStatusNone(savingsStatusHashMap);
//VERIFY ESCHEAT DUE TO OLD TRANSACTION //VERIFY ESCHEAT DUE TO OLD TRANSACTION
savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(3)); savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(3));
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap); SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
@@ -2026,7 +2026,7 @@ public class ClientSavingsIntegrationTest {
SavingsStatusChecker.verifySavingsSubStatusEscheat(savingsStatusHashMap); SavingsStatusChecker.verifySavingsSubStatusEscheat(savingsStatusHashMap);
summary = this.savingsAccountHelper.getSavingsSummary(savingsList.get(3)); summary = this.savingsAccountHelper.getSavingsSummary(savingsList.get(3));
assertEquals("Verifying account Balance", 2900f, summary.get("accountBalance")); assertEquals("Verifying account Balance", 2900f, summary.get("accountBalance"));
//VERIFY ESCHEAT DUE NO TRANSACTION FROM ACTIVATION //VERIFY ESCHEAT DUE NO TRANSACTION FROM ACTIVATION
savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(4)); savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(4));
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap); SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
@@ -2034,17 +2034,17 @@ public class ClientSavingsIntegrationTest {
SavingsStatusChecker.verifySavingsSubStatusEscheat(savingsStatusHashMap); SavingsStatusChecker.verifySavingsSubStatusEscheat(savingsStatusHashMap);
summary = this.savingsAccountHelper.getSavingsSummary(savingsList.get(4)); summary = this.savingsAccountHelper.getSavingsSummary(savingsList.get(4));
assertEquals("Verifying account Balance", 900f, summary.get("accountBalance")); assertEquals("Verifying account Balance", 900f, summary.get("accountBalance"));
//VERIFY NON ACTIVE ACCOUNTS ARE NOT AFFECTED //VERIFY NON ACTIVE ACCOUNTS ARE NOT AFFECTED
savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(5)); savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(5));
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
savingsStatusHashMap = SavingsStatusChecker.getSubStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(5)); savingsStatusHashMap = SavingsStatusChecker.getSubStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(5));
SavingsStatusChecker.verifySavingsSubStatusNone(savingsStatusHashMap); SavingsStatusChecker.verifySavingsSubStatusNone(savingsStatusHashMap);
} }
private HashMap activateSavingsAccount(final Integer savingsId, final String activationDate) { private HashMap activateSavingsAccount(final Integer savingsId, final String activationDate) {
final HashMap status = this.savingsAccountHelper.activateSavingsAccount(savingsId, activationDate); final HashMap status = this.savingsAccountHelper.activateSavingsAccount(savingsId, activationDate);
return status; return status;
@@ -2057,7 +2057,7 @@ public class ClientSavingsIntegrationTest {
return createSavingsProduct(requestSpec, responseSpec, minOpenningBalance, minBalanceForInterestCalculation, minRequiredBalance, return createSavingsProduct(requestSpec, responseSpec, minOpenningBalance, minBalanceForInterestCalculation, minRequiredBalance,
enforceMinRequiredBalance, allowOverdraft, taxGroupId, false); enforceMinRequiredBalance, allowOverdraft, taxGroupId, false);
} }
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance, final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance,
String enforceMinRequiredBalance, final boolean allowOverdraft, final String taxGroupId, boolean withDormancy) { String enforceMinRequiredBalance, final boolean allowOverdraft, final String taxGroupId, boolean withDormancy) {
@@ -2085,7 +2085,7 @@ public class ClientSavingsIntegrationTest {
.withMinimumOpenningBalance(minOpenningBalance).withWithHoldTax(taxGroupId).build(); .withMinimumOpenningBalance(minOpenningBalance).withWithHoldTax(taxGroupId).build();
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
} }
private Integer createTaxGroup(final String percentage){ private Integer createTaxGroup(final String percentage){
final Integer liabilityAccountId = null; final Integer liabilityAccountId = null;
final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId); final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId);
@@ -2098,11 +2098,11 @@ public class ClientSavingsIntegrationTest {
* System.out.println( * System.out.println(
* "--------------------VERIFYING THE BALANCE, INTEREST --------------------------" * "--------------------VERIFYING THE BALANCE, INTEREST --------------------------"
* ); * );
* *
* assertEquals("Verifying Interest Calculation", new Float("238.3399"), * assertEquals("Verifying Interest Calculation", new Float("238.3399"),
* savingsInterest); } * savingsInterest); }
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountBlockStatus() { public void testSavingsAccountBlockStatus() {
@@ -2162,7 +2162,7 @@ public class ClientSavingsIntegrationTest {
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_ERROR); SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.savings.account.debit.transaction.not.allowed", assertEquals("error.msg.savings.account.debit.transaction.not.allowed",
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT, depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID); SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId); depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
@@ -2183,7 +2183,7 @@ public class ClientSavingsIntegrationTest {
CommonConstants.RESPONSE_ERROR); CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.savings.account.credit.transaction.not.allowed", assertEquals("error.msg.savings.account.credit.transaction.not.allowed",
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT, withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT,
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID); SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId); withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
@@ -78,10 +78,10 @@ public class ClientTest {
ClientStatusChecker.verifyClientWithdrawn(clientStatusHashMap); ClientStatusChecker.verifyClientWithdrawn(clientStatusHashMap);
} }
@Test @Test
public void testClientAsPersonStatus() { public void testClientAsPersonStatus() {
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
final Integer clientId = ClientHelper.createClientAsPerson(this.requestSpec, this.responseSpec); final Integer clientId = ClientHelper.createClientAsPerson(this.requestSpec, this.responseSpec);
Assert.assertNotNull(clientId); Assert.assertNotNull(clientId);
@@ -111,10 +111,10 @@ public class ClientTest {
ClientStatusChecker.verifyClientWithdrawn(clientStatusHashMap); ClientStatusChecker.verifyClientWithdrawn(clientStatusHashMap);
} }
@Test @Test
public void testClientAsEntityStatus() { public void testClientAsEntityStatus() {
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
final Integer clientId = ClientHelper.createClientAsEntity(this.requestSpec, this.responseSpec); final Integer clientId = ClientHelper.createClientAsEntity(this.requestSpec, this.responseSpec);
Assert.assertNotNull(clientId); Assert.assertNotNull(clientId);
@@ -244,7 +244,7 @@ public class FixedDepositTest {
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsPrematureClosed(fixedDepositAccountStatusHashMap); FixedDepositAccountStatusChecker.verifyFixedDepositAccountIsPrematureClosed(fixedDepositAccountStatusHashMap);
/*** /***
* Verify journal entry transactions for preclosure transaction * Verify journal entry transactions for preclosure transaction
*/ */
@@ -257,8 +257,8 @@ public class FixedDepositTest {
JournalEntry.TransactionType.DEBIT)); JournalEntry.TransactionType.DEBIT));
} }
@Test @Test
public void testFixedDepositAccountWithPrematureClosureTypeWithdrawal_WITH_HOLD_TAX() { public void testFixedDepositAccountWithPrematureClosureTypeWithdrawal_WITH_HOLD_TAX() {
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
@@ -391,11 +391,11 @@ public class FixedDepositTest {
HashMap accountDetails = this.fixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, HashMap accountDetails = this.fixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Float maturityAmount = Float.valueOf(accountDetails.get("maturityAmount").toString()); Float maturityAmount = Float.valueOf(accountDetails.get("maturityAmount").toString());
HashMap summary = (HashMap) accountDetails.get("summary"); HashMap summary = (HashMap) accountDetails.get("summary");
Assert.assertNotNull(summary.get("totalWithholdTax")); Assert.assertNotNull(summary.get("totalWithholdTax"));
Float withHoldTax = (Float) summary.get("totalWithholdTax"); Float withHoldTax = (Float) summary.get("totalWithholdTax");
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount,
JournalEntry.TransactionType.CREDIT)); JournalEntry.TransactionType.CREDIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, CLOSED_ON_DATE, new JournalEntry(maturityAmount,
@@ -404,8 +404,8 @@ public class FixedDepositTest {
JournalEntry.TransactionType.CREDIT)); JournalEntry.TransactionType.CREDIT));
} }
@Test @Test
public void testFixedDepositAccountClosureTypeWithdrawal_WITH_HOLD_TAX() throws InterruptedException { public void testFixedDepositAccountClosureTypeWithdrawal_WITH_HOLD_TAX() throws InterruptedException {
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
@@ -514,20 +514,20 @@ public class FixedDepositTest {
/*** /***
* FD account verify whether account is matured * FD account verify whether account is matured
*/ */
SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec, responseSpec); SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec, responseSpec);
String JobName = "Update Deposit Accounts Maturity details"; String JobName = "Update Deposit Accounts Maturity details";
schedulerJobHelper.executeJob(JobName); schedulerJobHelper.executeJob(JobName);
HashMap accountDetails = this.fixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, HashMap accountDetails = this.fixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
HashMap summary = (HashMap) accountDetails.get("summary"); HashMap summary = (HashMap) accountDetails.get("summary");
Assert.assertNotNull(summary.get("totalWithholdTax")); Assert.assertNotNull(summary.get("totalWithholdTax"));
Float withHoldTax = (Float) summary.get("totalWithholdTax"); Float withHoldTax = (Float) summary.get("totalWithholdTax");
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax,
JournalEntry.TransactionType.CREDIT)); JournalEntry.TransactionType.CREDIT));
fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
this.responseSpec, fixedDepositAccountId.toString()); this.responseSpec, fixedDepositAccountId.toString());
@@ -535,7 +535,7 @@ public class FixedDepositTest {
} }
@Test @Test
public void testFixedDepositAccountWithPeriodInterestRateChart() { public void testFixedDepositAccountWithPeriodInterestRateChart() {
final String chartToUse = "period"; final String chartToUse = "period";
@@ -544,7 +544,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithPeriodInterestRateChart_AMOUNT_VARIATION() { public void testFixedDepositAccountWithPeriodInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "period"; final String chartToUse = "period";
@@ -553,7 +553,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithPeriodInterestRateChart_PERIOD_VARIATION() { public void testFixedDepositAccountWithPeriodInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "period"; final String chartToUse = "period";
@@ -562,7 +562,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(7.0); final Float interestRate = new Float(7.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithAmountInterestRateChart() { public void testFixedDepositAccountWithAmountInterestRateChart() {
final String chartToUse = "amount"; final String chartToUse = "amount";
@@ -571,7 +571,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(7.0); final Float interestRate = new Float(7.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithAmountInterestRateChart_AMOUNT_VARIATION() { public void testFixedDepositAccountWithAmountInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "amount"; final String chartToUse = "amount";
@@ -580,7 +580,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(5.0); final Float interestRate = new Float(5.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithAmountInterestRateChart_PERIOD_VARIATION() { public void testFixedDepositAccountWithAmountInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "amount"; final String chartToUse = "amount";
@@ -598,7 +598,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(7.0); final Float interestRate = new Float(7.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithPeriodAndAmountInterestRateChart_AMOUNT_VARIATION() { public void testFixedDepositAccountWithPeriodAndAmountInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "period_amount"; final String chartToUse = "period_amount";
@@ -607,7 +607,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithPeriodAndAmountInterestRateChart_PERIOD_VARIATION() { public void testFixedDepositAccountWithPeriodAndAmountInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "period_amount"; final String chartToUse = "period_amount";
@@ -616,7 +616,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(9.0); final Float interestRate = new Float(9.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart() { public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart() {
final String chartToUse = "amount_period"; final String chartToUse = "amount_period";
@@ -625,7 +625,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(8.0); final Float interestRate = new Float(8.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart_AMOUNT_VARIATION() { public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "amount_period"; final String chartToUse = "amount_period";
@@ -634,7 +634,7 @@ public class FixedDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart_PERIOD_VARIATION() { public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "amount_period"; final String chartToUse = "amount_period";
@@ -2422,7 +2422,7 @@ public class FixedDepositTest {
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec); return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
} }
private Integer createFixedDepositProductWithWithHoldTax(final String validFrom, final String validTo, final String taxGroupId, private Integer createFixedDepositProductWithWithHoldTax(final String validFrom, final String validTo, final String taxGroupId,
final String accountingRule, Account... accounts) { final String accountingRule, Account... accounts) {
System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
@@ -2437,7 +2437,7 @@ public class FixedDepositTest {
.build(validFrom, validTo); .build(validFrom, validTo);
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec); return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
} }
private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule, private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule,
final String chartToBePicked, Account... accounts) { final String chartToBePicked, Account... accounts) {
System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
@@ -2561,7 +2561,7 @@ public class FixedDepositTest {
Assert.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id")); Assert.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
Assert.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id")); Assert.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id"));
} }
private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax){ private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax){
final Integer liabilityAccountId = liabilityAccountForTax.getAccountID(); final Integer liabilityAccountId = liabilityAccountForTax.getAccountID();
final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId); final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId);
@@ -36,11 +36,11 @@ import com.jayway.restassured.specification.ResponseSpecification;
public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest { public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private GlobalConfigurationHelper globalConfigurationHelper; private GlobalConfigurationHelper globalConfigurationHelper;
@Before @Before
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -54,20 +54,20 @@ public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec);
GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec);
} }
@SuppressWarnings( {"static-access", "rawtypes", "unchecked"}) @SuppressWarnings( {"static-access", "rawtypes", "unchecked"})
@Test @Test
public void testInterestChargedFromDateSameAsDisbursalDate(){ public void testInterestChargedFromDateSameAsDisbursalDate(){
this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); .getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
Assert.assertNotNull(globalConfig); Assert.assertNotNull(globalConfig);
String configName = "interest-charged-from-date-same-as-disbursal-date"; String configName = "interest-charged-from-date-same-as-disbursal-date";
boolean newBooleanValue = true; boolean newBooleanValue = true;
for (Integer configIndex = 0; configIndex < (globalConfig.size()); configIndex++) { for (Integer configIndex = 0; configIndex < (globalConfig.size()); configIndex++) {
if (globalConfig.get(configIndex).get("name") if (globalConfig.get(configIndex).get("name")
.equals(configName)) { .equals(configName)) {
@@ -80,7 +80,7 @@ public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
break; break;
} }
} }
} }
} }
@@ -144,7 +144,7 @@ public class GlobalConfigurationTest {
Assert.assertEquals("Verifying Is Cache Enabled Global Config after Updation", cacheTypeId, changes.get("cacheType")); Assert.assertEquals("Verifying Is Cache Enabled Global Config after Updation", cacheTypeId, changes.get("cacheType"));
} }
} }
@Test @Test
public void testGlobalConfigForcePasswordResetDays() { public void testGlobalConfigForcePasswordResetDays() {
@@ -500,10 +500,10 @@ public class GroupSavingsIntegrationTest {
BigDecimal totalWaiveAmount = BigDecimal.valueOf(Double.valueOf((Float) savingsChargeForWaive.get("amount"))); BigDecimal totalWaiveAmount = BigDecimal.valueOf(Double.valueOf((Float) savingsChargeForWaive.get("amount")));
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount); totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived")); assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsWeeklyFeeJSON()); final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsWeeklyFeeJSON());
Assert.assertNotNull(weeklyFeeId); Assert.assertNotNull(weeklyFeeId);
this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId, true); this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId, true);
charges = this.savingsAccountHelper.getSavingsCharges(savingsId); charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
Assert.assertEquals(3, charges.size()); Assert.assertEquals(3, charges.size());
@@ -530,9 +530,9 @@ public class GroupSavingsIntegrationTest {
.plusWeeks((Integer) paidCharge.get("feeInterval")); .plusWeeks((Integer) paidCharge.get("feeInterval"));
assertEquals(expectedNextDueDate, nextDueDate); assertEquals(expectedNextDueDate, nextDueDate);
cal = Calendar.getInstance(); cal = Calendar.getInstance();
this.savingsAccountHelper.closeSavingsAccountAndGetBackRequiredField(savingsId, "true", null, sdf.format(cal.getTime())); this.savingsAccountHelper.closeSavingsAccountAndGetBackRequiredField(savingsId, "true", null, sdf.format(cal.getTime()));
} }
public static Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@@ -96,7 +96,7 @@ public class HookIntegrationTest {
} }
} }
@Test @Test
public void createUpdateAndDeleteHook(){ public void createUpdateAndDeleteHook(){
final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?"; final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?";
@@ -74,7 +74,7 @@ public class LoanDisbursalDateValidationTest {
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID); + loanProductID);
// APPLY FOR LOAN // APPLY FOR LOAN
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ loanID); + loanID);
@@ -93,10 +93,10 @@ public class LoanDisbursalDateValidationTest {
// DISBURSE A LOAN // DISBURSE A LOAN
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID, this.responseForbiddenError); List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID, this.responseForbiddenError);
Assert.assertEquals("error.msg.actual.disbursement.date.does.not.match.with.expected.disbursal.date", Assert.assertEquals("error.msg.actual.disbursement.date.does.not.match.with.expected.disbursal.date",
disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) {
@@ -112,6 +112,6 @@ public class LoanDisbursalDateValidationTest {
return this.loanTransactionHelper.getLoanId(loanApplication); return this.loanTransactionHelper.getLoanId(loanApplication);
} }
} }
@@ -239,63 +239,63 @@ public class LoanDisbursementDetailsIntegrationTest {
* periods){ LoanDisbursementTestBuilder expectedRepaymentSchedule0 = new * periods){ LoanDisbursementTestBuilder expectedRepaymentSchedule0 = new
* LoanDisbursementTestBuilder( "[2015, 6, 1]", 0.0f, 0.0f, null, null, * LoanDisbursementTestBuilder( "[2015, 6, 1]", 0.0f, 0.0f, null, null,
* 5000.0f, null, null, null); * 5000.0f, null, null, null);
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule1 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule1 = new
* LoanDisbursementTestBuilder( "[2015, 7, 1]", 800.0f, 800.0f, 50.0f, * LoanDisbursementTestBuilder( "[2015, 7, 1]", 800.0f, 800.0f, 50.0f,
* 750.0f, 4250.0f, 750.0f, 750.0f, "[2015, 6, 1]"); * 750.0f, 4250.0f, 750.0f, 750.0f, "[2015, 6, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule2 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule2 = new
* LoanDisbursementTestBuilder( "[2015, 8, 1]", 800.0f, 800.0f, 42.5f, * LoanDisbursementTestBuilder( "[2015, 8, 1]", 800.0f, 800.0f, 42.5f,
* 757.5f, 3492.5f, 757.5f, 757.5f, "[2015, 7, 1]"); * 757.5f, 3492.5f, 757.5f, 757.5f, "[2015, 7, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule3 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule3 = new
* LoanDisbursementTestBuilder( "[2015, 9, 1]", 0.0f, 0.0f, null, null, * LoanDisbursementTestBuilder( "[2015, 9, 1]", 0.0f, 0.0f, null, null,
* 5000.0f, null, null, null); * 5000.0f, null, null, null);
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule4 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule4 = new
* LoanDisbursementTestBuilder( "[2015, 9, 1]", 800.0f, 800.0f, 34.92f, * LoanDisbursementTestBuilder( "[2015, 9, 1]", 800.0f, 800.0f, 34.92f,
* 765.08f, 7727.42f, 765.08f, 765.08f, "[2015, 8, 1]"); * 765.08f, 7727.42f, 765.08f, 765.08f, "[2015, 8, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule5 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule5 = new
* LoanDisbursementTestBuilder( "[2015, 10, 1]", 800.0f, 800.0f, 77.27f, * LoanDisbursementTestBuilder( "[2015, 10, 1]", 800.0f, 800.0f, 77.27f,
* 722.73f, 7004.69f, 722.73f, 722.73f, "[2015, 9, 1]"); * 722.73f, 7004.69f, 722.73f, 722.73f, "[2015, 9, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule6 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule6 = new
* LoanDisbursementTestBuilder( "[2015, 11, 1]", 800.0f, 800.0f, 70.05f, * LoanDisbursementTestBuilder( "[2015, 11, 1]", 800.0f, 800.0f, 70.05f,
* 729.95f, 6274.74f, 729.95f, 729.95f, "[2015, 10, 1]"); * 729.95f, 6274.74f, 729.95f, 729.95f, "[2015, 10, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule7 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule7 = new
* LoanDisbursementTestBuilder( "[2015, 12, 1]", 800.0f, 800.0f, 62.75f, * LoanDisbursementTestBuilder( "[2015, 12, 1]", 800.0f, 800.0f, 62.75f,
* 737.25f, 5537.49f, 737.25f, 737.25f, "[2015, 11, 1]"); * 737.25f, 5537.49f, 737.25f, 737.25f, "[2015, 11, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule8 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule8 = new
* LoanDisbursementTestBuilder( "[2016, 1, 1]", 800.0f, 800.0f, 55.37f, * LoanDisbursementTestBuilder( "[2016, 1, 1]", 800.0f, 800.0f, 55.37f,
* 744.63f, 4792.86f, 744.63f, 744.63f, "[2015, 12, 1]"); * 744.63f, 4792.86f, 744.63f, 744.63f, "[2015, 12, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule9 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule9 = new
* LoanDisbursementTestBuilder( "[2016, 2, 1]", 800.0f, 800.0f, 47.93f, * LoanDisbursementTestBuilder( "[2016, 2, 1]", 800.0f, 800.0f, 47.93f,
* 752.07f, 4040.79f, 752.07f, 752.07f, "[2016, 1, 1]"); * 752.07f, 4040.79f, 752.07f, 752.07f, "[2016, 1, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule10 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule10 = new
* LoanDisbursementTestBuilder( "[2016, 3, 1]", 800.0f, 800.0f, 40.41f, * LoanDisbursementTestBuilder( "[2016, 3, 1]", 800.0f, 800.0f, 40.41f,
* 759.59f, 3281.2f, 759.59f, 759.59f, "[2016, 2, 1]"); * 759.59f, 3281.2f, 759.59f, 759.59f, "[2016, 2, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule11 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule11 = new
* LoanDisbursementTestBuilder( "[2016, 4, 1]", 800.0f, 800.0f, 32.81f, * LoanDisbursementTestBuilder( "[2016, 4, 1]", 800.0f, 800.0f, 32.81f,
* 767.19f, 2514.01f, 767.19f, 767.19f, "[2016, 3, 1]"); * 767.19f, 2514.01f, 767.19f, 767.19f, "[2016, 3, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule12 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule12 = new
* LoanDisbursementTestBuilder( "[2016, 5, 1]", 800.0f, 800.0f, 25.14f, * LoanDisbursementTestBuilder( "[2016, 5, 1]", 800.0f, 800.0f, 25.14f,
* 774.86f, 1739.15f, 774.86f, 774.86f, "[2016, 4, 1]"); * 774.86f, 1739.15f, 774.86f, 774.86f, "[2016, 4, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule13 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule13 = new
* LoanDisbursementTestBuilder( "[2016, 6, 1]", 800.0f, 800.0f, 17.39f, * LoanDisbursementTestBuilder( "[2016, 6, 1]", 800.0f, 800.0f, 17.39f,
* 782.61f, 956.54f, 782.61f, 782.61f, "[2016, 5, 1]"); * 782.61f, 956.54f, 782.61f, 782.61f, "[2016, 5, 1]");
* *
* LoanDisbursementTestBuilder expectedRepaymentSchedule14 = new * LoanDisbursementTestBuilder expectedRepaymentSchedule14 = new
* LoanDisbursementTestBuilder( "[2016, 7, 1]", 966.11f, 966.11f, 9.57f, * LoanDisbursementTestBuilder( "[2016, 7, 1]", 966.11f, 966.11f, 9.57f,
* 956.54f, 0.0f, 956.54f, 956.54f, "[2016, 6, 1]"); * 956.54f, 0.0f, 956.54f, 956.54f, "[2016, 6, 1]");
* *
* ArrayList<LoanDisbursementTestBuilder> list = new * ArrayList<LoanDisbursementTestBuilder> list = new
* ArrayList<LoanDisbursementTestBuilder>(); * ArrayList<LoanDisbursementTestBuilder>();
* list.add(expectedRepaymentSchedule0); * list.add(expectedRepaymentSchedule0);
@@ -313,14 +313,14 @@ public class LoanDisbursementDetailsIntegrationTest {
* list.add(expectedRepaymentSchedule12); * list.add(expectedRepaymentSchedule12);
* list.add(expectedRepaymentSchedule13); * list.add(expectedRepaymentSchedule13);
* list.add(expectedRepaymentSchedule14); * list.add(expectedRepaymentSchedule14);
* *
* for (int i = 0; i < list.size(); i++) { * for (int i = 0; i < list.size(); i++) {
* this.assertRepaymentScheduleValuesWithoutEMI(periods.get(i), list.get(i), * this.assertRepaymentScheduleValuesWithoutEMI(periods.get(i), list.get(i),
* i); } } * i); } }
* *
* private void assertRepaymentScheduleValuesWithoutEMI(HashMap period, * private void assertRepaymentScheduleValuesWithoutEMI(HashMap period,
* LoanDisbursementTestBuilder expectedRepaymentSchedule, int position) { * LoanDisbursementTestBuilder expectedRepaymentSchedule, int position) {
* *
* assertEquals(period.get("dueDate").toString(), * assertEquals(period.get("dueDate").toString(),
* expectedRepaymentSchedule.getDueDate()); * expectedRepaymentSchedule.getDueDate());
* assertEquals(period.get("principalLoanBalanceOutstanding"), * assertEquals(period.get("principalLoanBalanceOutstanding"),
@@ -329,9 +329,9 @@ public class LoanDisbursementDetailsIntegrationTest {
* expectedRepaymentSchedule.getTotalOriginalDueForPeriod()); * expectedRepaymentSchedule.getTotalOriginalDueForPeriod());
* assertEquals(period.get("totalOutstandingForPeriod"), * assertEquals(period.get("totalOutstandingForPeriod"),
* expectedRepaymentSchedule.getTotalOutstandingForPeriod()); * expectedRepaymentSchedule.getTotalOutstandingForPeriod());
* *
* if (position != 0 && position != 3) { * if (position != 0 && position != 3) {
* *
* assertEquals(period.get("interestOutstanding"), * assertEquals(period.get("interestOutstanding"),
* expectedRepaymentSchedule.getInterestOutstanding()); * expectedRepaymentSchedule.getInterestOutstanding());
* assertEquals(period.get("principalOutstanding"), * assertEquals(period.get("principalOutstanding"),
@@ -51,7 +51,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
private LoanApplicationApprovalTest loanApplicationApprovalTest; private LoanApplicationApprovalTest loanApplicationApprovalTest;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
@Before @Before
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -62,60 +62,60 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
this.loanApplicationApprovalTest = new LoanApplicationApprovalTest(); this.loanApplicationApprovalTest = new LoanApplicationApprovalTest();
this.generalResponseSpec = new ResponseSpecBuilder().build(); this.generalResponseSpec = new ResponseSpecBuilder().build();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testLoanRepaymentRescheduleAtDisbursement(){ public void testLoanRepaymentRescheduleAtDisbursement(){
final String approvalAmount = "10000"; final String approvalAmount = "10000";
final String approveDate = "01 March 2015"; final String approveDate = "01 March 2015";
final String expectedDisbursementDate = "01 March 2015"; final String expectedDisbursementDate = "01 March 2015";
final String disbursementDate = "01 March 2015"; final String disbursementDate = "01 March 2015";
final String adjustRepaymentDate = "16 March 2015"; final String adjustRepaymentDate = "16 March 2015";
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID); + clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION // CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION
final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY, final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY,
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0",
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null); LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null);
// CREATE TRANCHES // CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>(); List<HashMap> createTranches = new ArrayList<>();
createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 March 2015", "5000")); createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 March 2015", "5000"));
createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 May 2015", "5000")); createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 May 2015", "5000"));
// APPROVE TRANCHES // APPROVE TRANCHES
List<HashMap> approveTranches = new ArrayList<>(); List<HashMap> approveTranches = new ArrayList<>();
approveTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 March 2015", "5000")); approveTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 March 2015", "5000"));
approveTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 May 2015", "5000")); approveTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("01 May 2015", "5000"));
// APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION // APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION
final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate,
LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, new ArrayList<HashMap>(0), createTranches); LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, new ArrayList<HashMap>(0), createTranches);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches); loanID, approveTranches);
// VALIDATE THE LOAN IS APPROVED // VALIDATE THE LOAN IS APPROVED
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
// DISBURSE A FIRST TRANCHE // DISBURSE A FIRST TRANCHE
this.loanTransactionHelper.disburseLoanWithRepaymentReschedule(disbursementDate, loanID, adjustRepaymentDate); this.loanTransactionHelper.disburseLoanWithRepaymentReschedule(disbursementDate, loanID, adjustRepaymentDate);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, loanID); ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, loanID);
HashMap firstInstallement = loanRepaymnetSchedule.get(1); HashMap firstInstallement = loanRepaymnetSchedule.get(1);
Map<String, Object> expectedvalues = new HashMap<>(3); Map<String, Object> expectedvalues = new HashMap<>(3);
@@ -127,14 +127,14 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
expectedvalues.put("feeChargesDue", "0"); expectedvalues.put("feeChargesDue", "0");
expectedvalues.put("penaltyChargesDue", "0"); expectedvalues.put("penaltyChargesDue", "0");
expectedvalues.put("totalDueForPeriod", "884.03"); expectedvalues.put("totalDueForPeriod", "884.03");
// VALIDATE REPAYMENT SCHEDULE // VALIDATE REPAYMENT SCHEDULE
verifyLoanRepaymentSchedule(firstInstallement, expectedvalues); verifyLoanRepaymentSchedule(firstInstallement, expectedvalues);
} }
private void verifyLoanRepaymentSchedule(final HashMap firstInstallement, final Map<String, Object> expectedvalues) { private void verifyLoanRepaymentSchedule(final HashMap firstInstallement, final Map<String, Object> expectedvalues) {
assertEquals(expectedvalues.get("dueDate"), firstInstallement.get("dueDate")); assertEquals(expectedvalues.get("dueDate"), firstInstallement.get("dueDate"));
assertEquals(String.valueOf(expectedvalues.get("principalDue")), String.valueOf(firstInstallement.get("principalDue"))); assertEquals(String.valueOf(expectedvalues.get("principalDue")), String.valueOf(firstInstallement.get("principalDue")));
assertEquals(String.valueOf(expectedvalues.get("interestDue")), String.valueOf(firstInstallement.get("interestDue"))); assertEquals(String.valueOf(expectedvalues.get("interestDue")), String.valueOf(firstInstallement.get("interestDue")));
@@ -143,7 +143,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
assertEquals(String.valueOf(expectedvalues.get("totalDueForPeriod")), String.valueOf(firstInstallement.get("totalDueForPeriod"))); assertEquals(String.valueOf(expectedvalues.get("totalDueForPeriod")), String.valueOf(firstInstallement.get("totalDueForPeriod")));
} }
private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy, private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy,
final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod, final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod,
final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval, final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval,
@@ -160,7 +160,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
accounts, null, false, recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, accounts, null, false, recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType,
recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType); recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType);
} }
private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy, private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy,
final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod, final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod,
final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval, final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval,
@@ -197,7 +197,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
final String loanProductJSON = builder.build(chargeId); final String loanProductJSON = builder.build(chargeId);
return this.loanTransactionHelper.getLoanProductId(loanProductJSON); return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
} }
private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID, private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID,
final String disbursementDate, final String repaymentStrategy, final List<HashMap> charges, List<HashMap> tranches) { final String disbursementDate, final String repaymentStrategy, final List<HashMap> charges, List<HashMap> tranches) {
final String graceOnInterestPayment = null; final String graceOnInterestPayment = null;
@@ -205,7 +205,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, repaymentStrategy, charges, return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, repaymentStrategy, charges,
graceOnInterestPayment, graceOnPrincipalPayment, tranches); graceOnInterestPayment, graceOnPrincipalPayment, tranches);
} }
private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID, private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID,
final String disbursementDate, final String repaymentStrategy, final List<HashMap> charges, final String graceOnInterestPayment, final String disbursementDate, final String repaymentStrategy, final List<HashMap> charges, final String graceOnInterestPayment,
final String graceOnPrincipalPayment, List<HashMap> tranches) { final String graceOnPrincipalPayment, List<HashMap> tranches) {
@@ -231,7 +231,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
.build(clientID.toString(), loanProductID.toString(), null); .build(clientID.toString(), loanProductID.toString(), null);
return this.loanTransactionHelper.getLoanId(loanApplicationJSON); return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
} }
private List getDateAsArray(Calendar date, int addPeriod) { private List getDateAsArray(Calendar date, int addPeriod) {
return getDateAsArray(date, addPeriod, Calendar.DAY_OF_MONTH); return getDateAsArray(date, addPeriod, Calendar.DAY_OF_MONTH);
} }
@@ -39,8 +39,8 @@ import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.specification.RequestSpecification; import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification; import com.jayway.restassured.specification.ResponseSpecification;
/** /**
* Test the creation, approval and rejection of a loan reschedule request * Test the creation, approval and rejection of a loan reschedule request
**/ **/
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public class LoanRescheduleRequestTest { public class LoanRescheduleRequestTest {
@@ -57,7 +57,7 @@ public class LoanRescheduleRequestTest {
private String numberOfRepayments = "12"; private String numberOfRepayments = "12";
private String interestRatePerPeriod = "18"; private String interestRatePerPeriod = "18";
private String dateString = "4 September 2014"; private String dateString = "4 September 2014";
@Before @Before
public void initialize() { public void initialize() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -68,52 +68,52 @@ public class LoanRescheduleRequestTest {
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
this.generalResponseSpec = new ResponseSpecBuilder().build(); this.generalResponseSpec = new ResponseSpecBuilder().build();
// create all required entities // create all required entities
this.createRequiredEntities(); this.createRequiredEntities();
} }
/** /**
* Creates the client, loan product, and loan entities * Creates the client, loan product, and loan entities
**/ **/
private void createRequiredEntities() { private void createRequiredEntities() {
this.createClientEntity(); this.createClientEntity();
this.createLoanProductEntity(); this.createLoanProductEntity();
this.createLoanEntity(); this.createLoanEntity();
} }
/** /**
* create a new client * create a new client
**/ **/
private void createClientEntity() { private void createClientEntity() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId);
} }
/** /**
* create a new loan product * create a new loan product
**/ **/
private void createLoanProductEntity() { private void createLoanProductEntity() {
System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() final String loanProductJSON = new LoanProductTestBuilder()
.withPrincipal(loanPrincipalAmount) .withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments) .withNumberOfRepayments(numberOfRepayments)
.withinterestRatePerPeriod(interestRatePerPeriod) .withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear() .withInterestRateFrequencyTypeAsYear()
.build(null); .build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
System.out.println("Successfully created loan product (ID: " + this.loanProductId + ")"); System.out.println("Successfully created loan product (ID: " + this.loanProductId + ")");
} }
/** /**
* submit a new loan application, approve and disburse the loan * submit a new loan application, approve and disburse the loan
**/ **/
private void createLoanEntity() { private void createLoanEntity() {
System.out.println("---------------------------------NEW LOAN APPLICATION------------------------------------------"); System.out.println("---------------------------------NEW LOAN APPLICATION------------------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
.withPrincipal(loanPrincipalAmount) .withPrincipal(loanPrincipalAmount)
.withLoanTermFrequency(numberOfRepayments) .withLoanTermFrequency(numberOfRepayments)
@@ -130,90 +130,90 @@ public class LoanRescheduleRequestTest {
.withPrincipalGrace("2") .withPrincipalGrace("2")
.withInterestGrace("2") .withInterestGrace("2")
.build(this.clientId.toString(), this.loanProductId.toString(), null); .build(this.clientId.toString(), this.loanProductId.toString(), null);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
System.out.println("Sucessfully created loan (ID: " + this.loanId + ")"); System.out.println("Sucessfully created loan (ID: " + this.loanId + ")");
this.approveLoanApplication(); this.approveLoanApplication();
this.disburseLoan(); this.disburseLoan();
} }
/** /**
* approve the loan application * approve the loan application
**/ **/
private void approveLoanApplication() { private void approveLoanApplication() {
if(this.loanId != null) { if(this.loanId != null) {
this.loanTransactionHelper.approveLoan(this.dateString, this.loanId); this.loanTransactionHelper.approveLoan(this.dateString, this.loanId);
System.out.println("Successfully approved loan (ID: " + this.loanId + ")"); System.out.println("Successfully approved loan (ID: " + this.loanId + ")");
} }
} }
/** /**
* disburse the newly created loan * disburse the newly created loan
**/ **/
private void disburseLoan() { private void disburseLoan() {
if(this.loanId != null) { if(this.loanId != null) {
this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId); this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId);
System.out.println("Successfully disbursed loan (ID: " + this.loanId + ")"); System.out.println("Successfully disbursed loan (ID: " + this.loanId + ")");
} }
} }
/** /**
* create new loan reschedule request * create new loan reschedule request
**/ **/
private void createLoanRescheduleRequest() { private void createLoanRescheduleRequest() {
System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------"); System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------");
final String requestJSON = new LoanRescheduleRequestTestBuilder().build(this.loanId.toString()); final String requestJSON = new LoanRescheduleRequestTestBuilder().build(this.loanId.toString());
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON); this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId); this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
System.out.println("Successfully created loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); System.out.println("Successfully created loan reschedule request (ID: " + this.loanRescheduleRequestId + ")");
} }
@Test @Test
public void testCreateLoanRescheduleRequest() { public void testCreateLoanRescheduleRequest() {
this.createLoanRescheduleRequest(); this.createLoanRescheduleRequest();
} }
@Test @Test
public void testRejectLoanRescheduleRequest() { public void testRejectLoanRescheduleRequest() {
this.createLoanRescheduleRequest(); this.createLoanRescheduleRequest();
System.out.println("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------"); System.out.println("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------");
final String requestJSON = new LoanRescheduleRequestTestBuilder().getRejectLoanRescheduleRequestJSON(); final String requestJSON = new LoanRescheduleRequestTestBuilder().getRejectLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean)response.get("rejected")); assertTrue((Boolean)response.get("rejected"));
System.out.println("Successfully rejected loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); System.out.println("Successfully rejected loan reschedule request (ID: " + this.loanRescheduleRequestId + ")");
} }
@Test @Test
public void testApproveLoanRescheduleRequest() { public void testApproveLoanRescheduleRequest() {
this.createLoanRescheduleRequest(); this.createLoanRescheduleRequest();
System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------"); System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------");
final String requestJSON = new LoanRescheduleRequestTestBuilder().getApproveLoanRescheduleRequestJSON(); final String requestJSON = new LoanRescheduleRequestTestBuilder().getApproveLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean)response.get("approved")); assertTrue((Boolean)response.get("approved"));
final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId, "numberOfRepayments"); final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId, "numberOfRepayments");
final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId); final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId);
final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment"); final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment");
assertEquals("NUMBER OF REPAYMENTS SHOULD BE 16, NOT 12", "12", numberOfRepayments.toString()); assertEquals("NUMBER OF REPAYMENTS SHOULD BE 16, NOT 12", "12", numberOfRepayments.toString());
assertEquals("TOTAL EXPECTED REPAYMENT MUST BE EQUAL TO 118000.0", "118000.0", totalExpectedRepayment.toString()); assertEquals("TOTAL EXPECTED REPAYMENT MUST BE EQUAL TO 118000.0", "118000.0", totalExpectedRepayment.toString());
System.out.println("Successfully approved loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); System.out.println("Successfully approved loan reschedule request (ID: " + this.loanRescheduleRequestId + ")");
} }
} }
@@ -99,7 +99,7 @@ public class LoanReschedulingWithinCenterTest {
Integer clientId = createClient(officeId); Integer clientId = createClient(officeId);
associateClientsToGroup(groupId, clientId); associateClientsToGroup(groupId, clientId);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy"); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); dateFormat.setTimeZone(Utils.getTimeZoneOfTenant());
Calendar today = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar today = Calendar.getInstance(Utils.getTimeZoneOfTenant());
@@ -114,7 +114,7 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan,
null, null); null, null);
// APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION // APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION
@@ -153,7 +153,7 @@ public class LoanReschedulingWithinCenterTest {
Float interestDue = (Float) ((HashMap) loanRepaymnetSchedule.get(2)).get("interestDue"); Float interestDue = (Float) ((HashMap) loanRepaymnetSchedule.get(2)).get("interestDue");
assertEquals("90.82", String.valueOf(interestDue)); assertEquals("90.82", String.valueOf(interestDue));
} }
private void associateClientsToGroup(Integer groupId, Integer clientId) { private void associateClientsToGroup(Integer groupId, Integer clientId) {
// Associate client to the group // Associate client to the group
GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString()); GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString());
@@ -225,13 +225,13 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan,
null, null); null, null);
Calendar seondTrancheDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar seondTrancheDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
seondTrancheDate.add(Calendar.MONTH, 1); seondTrancheDate.add(Calendar.MONTH, 1);
String secondDisbursement = dateFormat.format(seondTrancheDate.getTime()) ; String secondDisbursement = dateFormat.format(seondTrancheDate.getTime()) ;
// CREATE TRANCHES // CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>(); List<HashMap> createTranches = new ArrayList<>();
createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail(disbursementDate, "5000")); createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail(disbursementDate, "5000"));
@@ -295,8 +295,8 @@ public class LoanReschedulingWithinCenterTest {
return createLoanProductWithInterestRecalculation(repaymentStrategy, interestRecalculationCompoundingMethod, return createLoanProductWithInterestRecalculation(repaymentStrategy, interestRecalculationCompoundingMethod,
rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval, rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval,
recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval, recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval,
recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, isMultiTrancheLoan, recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, isMultiTrancheLoan,
recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, recalculationRestFrequencyOnDayType, recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, recalculationRestFrequencyOnDayType,
recalculationRestFrequencyDayOfWeekType); recalculationRestFrequencyDayOfWeekType);
} }
@@ -306,7 +306,7 @@ public class LoanReschedulingWithinCenterTest {
final String recalculationRestFrequencyDate, final String recalculationCompoundingFrequencyType, final String recalculationRestFrequencyDate, final String recalculationCompoundingFrequencyType,
final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate, final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate,
final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId, final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId,
boolean isArrearsBasedOnOriginalSchedule, final boolean isMultiTrancheLoan, boolean isArrearsBasedOnOriginalSchedule, final boolean isMultiTrancheLoan,
final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyOnDayType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) { final Integer recalculationRestFrequencyDayOfWeekType) {
@@ -65,11 +65,11 @@ public class PasswordPreferencesIntegrationTest {
System.out.println("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------"); System.out.println("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------");
} }
@Test @Test
public void updateWithInvalidPolicyId() { public void updateWithInvalidPolicyId() {
String invalidValidationPolicyId = "2000"; String invalidValidationPolicyId = "2000";
final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec, invalidValidationPolicyId, final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec, invalidValidationPolicyId,
CommonConstants.RESPONSE_ERROR); CommonConstants.RESPONSE_ERROR);
assertEquals("Password Validation Policy with identifier 2000 does not exist", "error.msg.password.validation.policy.id.invalid", assertEquals("Password Validation Policy with identifier 2000 does not exist", "error.msg.password.validation.policy.id.invalid",
error.get(0).get("userMessageGlobalisationCode")); error.get(0).get("userMessageGlobalisationCode"));
@@ -478,7 +478,7 @@ public class RecurringDepositTest {
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec); this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
/*** /***
* Create GL Accounts for product account mapping * Create GL Accounts for product account mapping
@@ -611,7 +611,7 @@ public class RecurringDepositTest {
Integer transactionIdForPostInterest = this.recurringDepositAccountHelper Integer transactionIdForPostInterest = this.recurringDepositAccountHelper
.postInterestForRecurringDeposit(recurringDepositAccountId); .postInterestForRecurringDeposit(recurringDepositAccountId);
Assert.assertNotNull(transactionIdForPostInterest); Assert.assertNotNull(transactionIdForPostInterest);
HashMap accountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId); HashMap accountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted"); Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted");
@@ -694,7 +694,7 @@ public class RecurringDepositTest {
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec); this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
/*** /***
* Create GL Accounts for product account mapping * Create GL Accounts for product account mapping
@@ -810,7 +810,7 @@ public class RecurringDepositTest {
*/ */
todaysDate = Calendar.getInstance(); todaysDate = Calendar.getInstance();
todaysDate.add(Calendar.MONTH, -20); todaysDate.add(Calendar.MONTH, -20);
for (int i = 0; i < 14; i++) { for (int i = 0; i < 14; i++) {
Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
depositAmount, dateFormat.format(todaysDate.getTime())); depositAmount, dateFormat.format(todaysDate.getTime()));
@@ -826,20 +826,20 @@ public class RecurringDepositTest {
/*** /***
* FD account verify whether account is matured * FD account verify whether account is matured
*/ */
SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec, responseSpec); SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec, responseSpec);
String JobName = "Update Deposit Accounts Maturity details"; String JobName = "Update Deposit Accounts Maturity details";
schedulerJobHelper.executeJob(JobName); schedulerJobHelper.executeJob(JobName);
HashMap accountDetails = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, HashMap accountDetails = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
HashMap summary = (HashMap) accountDetails.get("summary"); HashMap summary = (HashMap) accountDetails.get("summary");
Assert.assertNotNull(summary.get("totalWithholdTax")); Assert.assertNotNull(summary.get("totalWithholdTax"));
Float withHoldTax = (Float) summary.get("totalWithholdTax"); Float withHoldTax = (Float) summary.get("totalWithholdTax");
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccountForTax, CLOSED_ON_DATE, new JournalEntry(withHoldTax,
JournalEntry.TransactionType.CREDIT)); JournalEntry.TransactionType.CREDIT));
recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(this.requestSpec, recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(this.requestSpec,
this.responseSpec, recurringDepositAccountId.toString()); this.responseSpec, recurringDepositAccountId.toString());
@@ -849,7 +849,7 @@ public class RecurringDepositTest {
} }
/*** /***
* Test case for Recurring Deposit Account premature closure with * Test case for Recurring Deposit Account premature closure with
* transaction type ReInvest and Cash Based accounting enabled * transaction type ReInvest and Cash Based accounting enabled
@@ -2882,7 +2882,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithPeriodInterestRateChart_AMOUNT_VARIATION() { public void testRecurringDepositAccountWithPeriodInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "period"; final String chartToUse = "period";
@@ -2891,7 +2891,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithPeriodInterestRateChart_PERIOD_VARIATION() { public void testRecurringDepositAccountWithPeriodInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "period"; final String chartToUse = "period";
@@ -2900,7 +2900,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(7.0); final Float interestRate = new Float(7.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithAmountInterestRateChart() { public void testRecurringDepositAccountWithAmountInterestRateChart() {
final String chartToUse = "amount"; final String chartToUse = "amount";
@@ -2909,7 +2909,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(8.0); final Float interestRate = new Float(8.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithAmountInterestRateChart_AMOUNT_VARIATION() { public void testRecurringDepositAccountWithAmountInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "amount"; final String chartToUse = "amount";
@@ -2918,7 +2918,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(7.0); final Float interestRate = new Float(7.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithAmountInterestRateChart_PERIOD_VARIATION() { public void testRecurringDepositAccountWithAmountInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "amount"; final String chartToUse = "amount";
@@ -2927,7 +2927,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(5.0); final Float interestRate = new Float(5.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart() { public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart() {
final String chartToUse = "period_amount"; final String chartToUse = "period_amount";
@@ -2936,7 +2936,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(7.0); final Float interestRate = new Float(7.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart_AMOUNT_VARIATION() { public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "period_amount"; final String chartToUse = "period_amount";
@@ -2945,7 +2945,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart_PERIOD_VARIATION() { public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "period_amount"; final String chartToUse = "period_amount";
@@ -2954,7 +2954,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(8.0); final Float interestRate = new Float(8.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart() { public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart() {
final String chartToUse = "amount_period"; final String chartToUse = "amount_period";
@@ -2963,7 +2963,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(8.0); final Float interestRate = new Float(8.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart_AMOUNT_VARIATION() { public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart_AMOUNT_VARIATION() {
final String chartToUse = "amount_period"; final String chartToUse = "amount_period";
@@ -2972,7 +2972,7 @@ public class RecurringDepositTest {
final Float interestRate = new Float(6.0); final Float interestRate = new Float(6.0);
testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate);
} }
@Test @Test
public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart_PERIOD_VARIATION() { public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart_PERIOD_VARIATION() {
final String chartToUse = "amount_period"; final String chartToUse = "amount_period";
@@ -3049,7 +3049,7 @@ public class RecurringDepositTest {
final String recurringDepositProductJSON = recurringDepositProductHelper.withPeriodRangeChart().build(validFrom, validTo); final String recurringDepositProductJSON = recurringDepositProductHelper.withPeriodRangeChart().build(validFrom, validTo);
return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec); return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec);
} }
private Integer createRecurringDepositProductWithWithHoldTax(final String validFrom, final String validTo,final String taxGroupId, final String accountingRule, private Integer createRecurringDepositProductWithWithHoldTax(final String validFrom, final String validTo,final String taxGroupId, final String accountingRule,
Account... accounts) { Account... accounts) {
System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
@@ -3186,7 +3186,7 @@ public class RecurringDepositTest {
Assert.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id")); Assert.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
Assert.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id")); Assert.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id"));
} }
private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax){ private Integer createTaxGroup(final String percentage, final Account liabilityAccountForTax){
final Integer liabilityAccountId = liabilityAccountForTax.getAccountID(); final Integer liabilityAccountId = liabilityAccountForTax.getAccountID();
final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId); final Integer taxComponentId = TaxComponentHelper.createTaxComponent(this.requestSpec, this.responseSpec, percentage, liabilityAccountId);
@@ -159,15 +159,15 @@ public class SkipRepaymentOnMonthFirstTest {
assertEquals("Checking for Repayment Date for 1st Month", new ArrayList<>(Arrays.asList(2011, 10, 15)), assertEquals("Checking for Repayment Date for 1st Month", new ArrayList<>(Arrays.asList(2011, 10, 15)),
loanSchedule.get(1).get("dueDate")); loanSchedule.get(1).get("dueDate"));
System.out.println("Repayment Date for 1st Month--" + loanSchedule.get(1).get("dueDate")); System.out.println("Repayment Date for 1st Month--" + loanSchedule.get(1).get("dueDate"));
assertEquals("Checking for Repayment Date for 2nd Month", new ArrayList<>(Arrays.asList(2011, 11, 15)), assertEquals("Checking for Repayment Date for 2nd Month", new ArrayList<>(Arrays.asList(2011, 11, 15)),
loanSchedule.get(2).get("dueDate")); loanSchedule.get(2).get("dueDate"));
System.out.println("Repayment Date for 2nd Month--" + loanSchedule.get(2).get("dueDate")); System.out.println("Repayment Date for 2nd Month--" + loanSchedule.get(2).get("dueDate"));
assertEquals("Checking for Repayment Date for 3rd Month", new ArrayList<>(Arrays.asList(2011, 12, 15)), assertEquals("Checking for Repayment Date for 3rd Month", new ArrayList<>(Arrays.asList(2011, 12, 15)),
loanSchedule.get(3).get("dueDate")); loanSchedule.get(3).get("dueDate"));
System.out.println("Repayment Date for 3rd Month--" + loanSchedule.get(3).get("dueDate")); System.out.println("Repayment Date for 3rd Month--" + loanSchedule.get(3).get("dueDate"));
assertEquals("Checking for Repayment Date for 4th Month", new ArrayList<>(Arrays.asList(2012, 1, 15)), assertEquals("Checking for Repayment Date for 4th Month", new ArrayList<>(Arrays.asList(2012, 1, 15)),
loanSchedule.get(4).get("dueDate")); loanSchedule.get(4).get("dueDate"));
System.out.println("Repayment Date for 4th Month--" + loanSchedule.get(4).get("dueDate")); System.out.println("Repayment Date for 4th Month--" + loanSchedule.get(4).get("dueDate"));
@@ -41,7 +41,7 @@ import com.jayway.restassured.specification.ResponseSpecification;
/** /**
* Test for creating, updating, deleting codes and code values * Test for creating, updating, deleting codes and code values
* *
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class SystemCodeTest { public class SystemCodeTest {
@@ -35,9 +35,9 @@ import com.jayway.restassured.specification.ResponseSpecification;
* Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It * Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It
* takes care of creation of {@code BatchRequest} list and posting this list to * takes care of creation of {@code BatchRequest} list and posting this list to
* the server. * the server.
* *
* @author Rishabh Shukla * @author Rishabh Shukla
* *
* @see org.apache.fineract.integrationtests.BatchApiTest * @see org.apache.fineract.integrationtests.BatchApiTest
*/ */
public class BatchHelper { public class BatchHelper {
@@ -51,7 +51,7 @@ public class BatchHelper {
/** /**
* Returns a JSON String for a list of {@code BatchRequest}s * Returns a JSON String for a list of {@code BatchRequest}s
* *
* @param batchRequests * @param batchRequests
* @return JSON String of BatchRequest * @return JSON String of BatchRequest
*/ */
@@ -71,7 +71,7 @@ public class BatchHelper {
/** /**
* Returns the converted string response into JSON. * Returns the converted string response into JSON.
* *
* @param json * @param json
* @return List<BatchResponse> * @return List<BatchResponse>
*/ */
@@ -83,7 +83,7 @@ public class BatchHelper {
* Returns a list of BatchResponse with query parameter enclosing * Returns a list of BatchResponse with query parameter enclosing
* transaction set to false by posting the jsonified BatchRequest to the * transaction set to false by posting the jsonified BatchRequest to the
* server. * server.
* *
* @param requestSpec * @param requestSpec
* @param responseSpec * @param responseSpec
* @param jsonifiedBatchRequests * @param jsonifiedBatchRequests
@@ -99,7 +99,7 @@ public class BatchHelper {
* Returns a list of BatchResponse with query parameter enclosing * Returns a list of BatchResponse with query parameter enclosing
* transaction set to true by posting the jsonified BatchRequest to the * transaction set to true by posting the jsonified BatchRequest to the
* server. * server.
* *
* @param requestSpec * @param requestSpec
* @param responseSpec * @param responseSpec
* @param jsonifiedBatchRequests * @param jsonifiedBatchRequests
@@ -114,7 +114,7 @@ public class BatchHelper {
/** /**
* Returns a BatchResponse based on the given BatchRequest, by posting the * Returns a BatchResponse based on the given BatchRequest, by posting the
* request to the server. * request to the server.
* *
* @param BatchRequest * @param BatchRequest
* @return List<BatchResponse> * @return List<BatchResponse>
*/ */
@@ -139,7 +139,7 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.CreateClientCommandStrategy} * {@link org.apache.fineract.batch.command.internal.CreateClientCommandStrategy}
* Request as one of the request in Batch. * Request as one of the request in Batch.
* *
* @param reqId * @param reqId
* @param externalId * @param externalId
* @return BatchRequest * @return BatchRequest
@@ -202,7 +202,7 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy} * {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy}
* Request with given requestId and reference. * Request with given requestId and reference.
* *
* @param reqId * @param reqId
* @param clientId * @param clientId
* @return BatchRequest * @return BatchRequest
@@ -224,7 +224,7 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.ApplyLoanCommandStrategy} * {@link org.apache.fineract.batch.command.internal.ApplyLoanCommandStrategy}
* Request with given requestId and reference. * Request with given requestId and reference.
* *
* @param requestId * @param requestId
* @param reference * @param reference
* @param productId * @param productId
@@ -255,7 +255,7 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.ApplySavingsCommandStrategy} * {@link org.apache.fineract.batch.command.internal.ApplySavingsCommandStrategy}
* Request with given requestId and reference. * Request with given requestId and reference.
* *
* @param requestId * @param requestId
* @param reference * @param reference
* @param productId * @param productId
@@ -281,7 +281,7 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.CreateChargeCommandStrategy} * {@link org.apache.fineract.batch.command.internal.CreateChargeCommandStrategy}
* Request with given requestId and reference * Request with given requestId and reference
* *
* @param requestId * @param requestId
* @param reference * @param reference
* @return BatchRequest * @return BatchRequest
@@ -305,7 +305,7 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.CollectChargesCommandStrategy} * {@link org.apache.fineract.batch.command.internal.CollectChargesCommandStrategy}
* Request with given requestId and reference. * Request with given requestId and reference.
* *
* @param requestId * @param requestId
* @param reference * @param reference
* @return BatchRequest * @return BatchRequest
@@ -327,8 +327,8 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.ActivateClientCommandStrategy} * {@link org.apache.fineract.batch.command.internal.ActivateClientCommandStrategy}
* Request with given requestId and reference. * Request with given requestId and reference.
* *
* *
* @param requestId * @param requestId
* @param reference * @param reference
* @return BatchRequest * @return BatchRequest
@@ -345,13 +345,13 @@ public class BatchHelper {
return br; return br;
} }
/** /**
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy} * {@link org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy}
* Request with given requestId and reference. * Request with given requestId and reference.
* *
* *
* @param requestId * @param requestId
* @param reference * @param reference
* @return BatchRequest * @return BatchRequest
@@ -363,7 +363,7 @@ public class BatchHelper {
br.setRelativeUrl("loans/$.loanId?command=approve"); br.setRelativeUrl("loans/$.loanId?command=approve");
br.setReference(reference); br.setReference(reference);
br.setMethod("POST"); br.setMethod("POST");
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"approvedOnDate\": \"12 September 2013\"," br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"approvedOnDate\": \"12 September 2013\","
+ "\"note\": \"Loan approval note\"}"); + "\"note\": \"Loan approval note\"}");
return br; return br;
@@ -373,8 +373,8 @@ public class BatchHelper {
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy} * {@link org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy}
* Request with given requestId and reference. * Request with given requestId and reference.
* *
* *
* @param requestId * @param requestId
* @param reference * @param reference
* @return BatchRequest * @return BatchRequest
@@ -413,11 +413,11 @@ public class BatchHelper {
return br; return br;
} }
/** /**
* Checks that the client with given externalId is not created on the * Checks that the client with given externalId is not created on the
* server. * server.
* *
* @param requestSpec * @param requestSpec
* @param responseSpec * @param responseSpec
* @param externalId * @param externalId
@@ -88,7 +88,7 @@ public class CalendarHelper {
final Integer responseCalendarId = from(responseCalendarDetailsinJSON).get("id"); final Integer responseCalendarId = from(responseCalendarDetailsinJSON).get("id");
assertEquals("ERROR IN CREATING THE CALENDAR", generatedCalendarId, responseCalendarId); assertEquals("ERROR IN CREATING THE CALENDAR", generatedCalendarId, responseCalendarId);
} }
public static Integer createMeetingForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createMeetingForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) { final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) {
@@ -195,7 +195,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
public String getHierarchy() { public String getHierarchy() {
return this.hierarchy; return this.hierarchy;
} }
public String getAccountNo(){ public String getAccountNo(){
return this.accountNo; return this.accountNo;
} }
@@ -97,7 +97,7 @@ public class CenterHelper {
hm.put("dateFormat", "dd MMM yyyy"); hm.put("dateFormat", "dd MMM yyyy");
hm.put("activationDate", activationDate); hm.put("activationDate", activationDate);
} }
System.out.println("------------------------CREATING CENTER-------------------------"); System.out.println("------------------------CREATING CENTER-------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, new Gson().toJson(hm), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, new Gson().toJson(hm), "resourceId");
} }
@@ -183,7 +183,7 @@ public class CenterHelper {
} }
public static String getTestCenterWithStaffAsJSON(final boolean active, final String activationDate, final Integer staffId) { public static String getTestCenterWithStaffAsJSON(final boolean active, final String activationDate, final Integer staffId) {
Integer id = null; Integer id = null;
Integer statusid = null; Integer statusid = null;
String statuscode = null; String statuscode = null;
@@ -201,7 +201,7 @@ public class CenterHelper {
} }
public static String getTestCenterAsJSON(final boolean active, final String activationDate) { public static String getTestCenterAsJSON(final boolean active, final String activationDate) {
Integer id = null; Integer id = null;
Integer statusid = null; Integer statusid = null;
String statuscode = null; String statuscode = null;
@@ -217,7 +217,7 @@ public class CenterHelper {
return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate,submittedDate,name, return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate,submittedDate,name,
externalId, staffId, officeID, officeName, hierarchy, groupMembers); externalId, staffId, officeID, officeName, hierarchy, groupMembers);
} }
public static String assignStaffAsJSON(final Long staffId) { public static String assignStaffAsJSON(final Long staffId) {
@@ -34,13 +34,13 @@ import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification; import com.jayway.restassured.specification.ResponseSpecification;
/** /**
* *
* IntegrationTest for ClientCharges. * IntegrationTest for ClientCharges.
* *
*/ */
/** /**
* @author lenovo * @author lenovo
* *
*/ */
public class ClientChargesTest { public class ClientChargesTest {
@@ -71,7 +71,7 @@ public class ClientChargesTest {
* create a charge for loan and try to associate to client created in * create a charge for loan and try to associate to client created in
* the above lines.it will be an invalid scenario the reason is client * the above lines.it will be an invalid scenario the reason is client
* is not allowed to have only client charge. * is not allowed to have only client charge.
* *
*/ */
final Integer loanChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, final Integer loanChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON()); ChargesHelper.getLoanSpecifiedDueDateJSON());
@@ -159,7 +159,7 @@ public class ClientChargesTest {
/** /**
* It checks whether the client charge transaction is reversed or not. * It checks whether the client charge transaction is reversed or not.
* *
* @param clientId * @param clientId
* @param transactionId * @param transactionId
*/ */
@@ -172,7 +172,7 @@ public class ClientChargesTest {
/** /**
* Check whether the outStandingAmount is equal to expected Amount or not * Check whether the outStandingAmount is equal to expected Amount or not
* after paying or after waiving off the client charge. * after paying or after waiving off the client charge.
* *
* @param outStandingAmount * @param outStandingAmount
* @param expectedAmount * @param expectedAmount
*/ */
@@ -85,9 +85,9 @@ public class ClientHelper {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(activationDate, officeId), return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(activationDate, officeId),
"clientId"); "clientId");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return createClientPending(requestSpec, responseSpec, "04 March 2014"); return createClientPending(requestSpec, responseSpec, "04 March 2014");
} }
@@ -128,12 +128,12 @@ public class ClientHelper {
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) { final String activationDate, final String officeId) {
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId), return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId),
"clientId"); "clientId");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011"); return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
} }
@@ -145,10 +145,10 @@ public class ClientHelper {
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) { final String activationDate, final String officeId) {
Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id"); Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id"); Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId),
"clientId"); "clientId");
@@ -191,7 +191,7 @@ public class ClientHelper {
System.out.println("map : " + map); System.out.println("map : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String getTestClientAsJSONPending(final String submittedOnDate, final String officeId) { public static String getTestClientAsJSONPending(final String submittedOnDate, final String officeId) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("officeId", officeId); map.put("officeId", officeId);
@@ -248,11 +248,11 @@ public class ClientHelper {
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", dateOfJoining); map.put("activationDate", dateOfJoining);
map.put("legalFormId", 1); map.put("legalFormId", 1);
System.out.println("map : " + map); System.out.println("map : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String getTestEntityClientAsJSON(final String dateOfJoining, final String officeId, final Integer soleProprietorCodeValueId) { public static String getTestEntityClientAsJSON(final String dateOfJoining, final String officeId, final Integer soleProprietorCodeValueId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("officeId", officeId); map.put("officeId", officeId);
@@ -263,11 +263,11 @@ public class ClientHelper {
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", dateOfJoining); map.put("activationDate", dateOfJoining);
map.put("legalFormId", 2); map.put("legalFormId", 2);
final HashMap<String, Object> clientNonPersonMap = new HashMap<>(); final HashMap<String, Object> clientNonPersonMap = new HashMap<>();
clientNonPersonMap.put("constitutionId", soleProprietorCodeValueId); clientNonPersonMap.put("constitutionId", soleProprietorCodeValueId);
map.put("clientNonPersonDetails", clientNonPersonMap); map.put("clientNonPersonDetails", clientNonPersonMap);
System.out.println("map : " + map); System.out.println("map : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -408,8 +408,8 @@ public class ClientHelper {
System.out.println(clientJson); System.out.println(clientJson);
return clientJson; return clientJson;
} }
private String getWithdrawClientAsJSON() { private String getWithdrawClientAsJSON() {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
@@ -539,7 +539,7 @@ public class ClientHelper {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent,
jsonAttributeToGetBack); jsonAttributeToGetBack);
} }
private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) { private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS); Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS);
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId)); HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
@@ -362,7 +362,7 @@ public class GlobalConfigurationHelper {
return Utils.performServerPut(requestSpec, responseSpec, IS_CACHE_GLOBAL_CONFIG_UPDATE_URL, return Utils.performServerPut(requestSpec, responseSpec, IS_CACHE_GLOBAL_CONFIG_UPDATE_URL,
updateIsCacheEnabledGlobalConfigUpdateAsJSON(cacheType), "changes"); updateIsCacheEnabledGlobalConfigUpdateAsJSON(cacheType), "changes");
} }
public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec, public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) {
final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
@@ -377,7 +377,7 @@ public class GlobalConfigurationHelper {
System.out.println("map : " + map); System.out.println("map : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String updatePasswordResetDaysGlobalConfigAsJSON(final String value, final String enabled) { public static String updatePasswordResetDaysGlobalConfigAsJSON(final String value, final String enabled) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
if(value != null){ if(value != null){
@@ -64,7 +64,7 @@ public class HolidayHelper {
System.out.println(HolidayCreateJson); System.out.println(HolidayCreateJson);
return HolidayCreateJson; return HolidayCreateJson;
} }
public static String getActivateHolidayDataAsJSON() { public static String getActivateHolidayDataAsJSON() {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
String activateHoliday = new Gson().toJson(map); String activateHoliday = new Gson().toJson(map);
@@ -75,12 +75,12 @@ public class HolidayHelper {
public static Integer createHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer createHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOLIDAY_URL, getCreateHolidayDataAsJSON(), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOLIDAY_URL, getCreateHolidayDataAsJSON(), "resourceId");
} }
public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String holidayID) { public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String holidayID) {
final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER; final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId");
} }
public static HashMap getHolidayById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getHolidayById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String holidayID) { final String holidayID) {
final String GET_HOLIDAY_BY_ID_URL = HOLIDAYS_URL + "/" + holidayID + "?" + Utils.TENANT_IDENTIFIER; final String GET_HOLIDAY_BY_ID_URL = HOLIDAYS_URL + "/" + holidayID + "?" + Utils.TENANT_IDENTIFIER;
@@ -29,23 +29,23 @@ import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification; import com.jayway.restassured.specification.ResponseSpecification;
public class HookHelper { public class HookHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
private static final String CREATE_HOOK_URL = "/fineract-provider/api/v1/hooks?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_HOOK_URL = "/fineract-provider/api/v1/hooks?" + Utils.TENANT_IDENTIFIER;
public HookHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public HookHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public Integer createHook(final String payloadURL) { public Integer createHook(final String payloadURL) {
System.out.println("---------------------------------CREATING A HOOK---------------------------------------------"); System.out.println("---------------------------------CREATING A HOOK---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL),
"resourceId"); "resourceId");
} }
public String getTestHookAsJson(final String payloadURL) { public String getTestHookAsJson(final String payloadURL) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("name", "Web"); map.put("name", "Web");
@@ -64,7 +64,7 @@ public class HookHelper {
System.out.println("map : " + map); System.out.println("map : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public Integer updateHook(final String payloadURL, final Long hookId) { public Integer updateHook(final String payloadURL, final Long hookId) {
System.out.println("---------------------------------UPDATING HOOK---------------------------------------------"); System.out.println("---------------------------------UPDATING HOOK---------------------------------------------");
final String UPDATE_HOOK_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_HOOK_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
@@ -76,14 +76,14 @@ public class HookHelper {
final String DELETE_HOOK_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String DELETE_HOOK_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(this.requestSpec, this.responseSpec, DELETE_HOOK_URL, "resourceId"); return Utils.performServerDelete(this.requestSpec, this.responseSpec, DELETE_HOOK_URL, "resourceId");
} }
public void verifyHookCreatedOnServer(final Long hookId) { public void verifyHookCreatedOnServer(final Long hookId) {
System.out.println("------------------------------CHECK CREATE HOOK DETAILS------------------------------------\n"); System.out.println("------------------------------CHECK CREATE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
final Integer responseHookId = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "id"); final Integer responseHookId = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "id");
assertEquals(hookId.toString(), responseHookId.toString()); assertEquals(hookId.toString(), responseHookId.toString());
} }
public void verifyUpdateHook(final String updateURL, final Long hookId) { public void verifyUpdateHook(final String updateURL, final Long hookId) {
System.out.println("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n"); System.out.println("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
@@ -91,7 +91,7 @@ public class HookHelper {
HashMap<String, String> hash = (HashMap<String, String>) map.get(1); HashMap<String, String> hash = (HashMap<String, String>) map.get(1);
assertEquals(updateURL, hash.get("fieldValue")); assertEquals(updateURL, hash.get("fieldValue"));
} }
public void verifyDeleteHook(final Long hookId) { public void verifyDeleteHook(final Long hookId) {
System.out.println("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n"); System.out.println("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
@@ -26,40 +26,40 @@ import com.jayway.restassured.specification.ResponseSpecification;
public class LoanRescheduleRequestHelper { public class LoanRescheduleRequestHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
private static final String LOAN_RESCHEDULE_REQUEST_URL = "/fineract-provider/api/v1/rescheduleloans"; private static final String LOAN_RESCHEDULE_REQUEST_URL = "/fineract-provider/api/v1/rescheduleloans";
public LoanRescheduleRequestHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public LoanRescheduleRequestHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public Integer createLoanRescheduleRequest(final String requestJSON) { public Integer createLoanRescheduleRequest(final String requestJSON) {
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "?" + Utils.TENANT_IDENTIFIER; final String URL = LOAN_RESCHEDULE_REQUEST_URL + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId"); return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId");
} }
public Integer rejectLoanRescheduleRequest(final Integer requestId, final String requestJSON) { public Integer rejectLoanRescheduleRequest(final Integer requestId, final String requestJSON) {
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER + "&command=reject"; final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER + "&command=reject";
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId"); return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId");
} }
public Integer approveLoanRescheduleRequest(final Integer requestId, final String requestJSON) { public Integer approveLoanRescheduleRequest(final Integer requestId, final String requestJSON) {
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER + "&command=approve"; final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER + "&command=approve";
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId"); return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId");
} }
public Object getLoanRescheduleRequest(final Integer requestId, final String param) { public Object getLoanRescheduleRequest(final Integer requestId, final String param) {
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER; final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, param); return Utils.performServerGet(requestSpec, responseSpec, URL, param);
} }
public void verifyCreationOfLoanRescheduleRequest(final Integer requestId) { public void verifyCreationOfLoanRescheduleRequest(final Integer requestId) {
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER; final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER;
final Integer id = Utils.performServerGet(requestSpec, responseSpec, URL, "id"); final Integer id = Utils.performServerGet(requestSpec, responseSpec, URL, "id");
assertEquals("ERROR IN CREATING LOAN RESCHEDULE REQUEST", requestId, id); assertEquals("ERROR IN CREATING LOAN RESCHEDULE REQUEST", requestId, id);
} }
@@ -28,7 +28,7 @@ public class PasswordPreferencesHelper {
private static final String PASSWORD_PREFERENCES_URL = "/fineract-provider/api/v1/passwordpreferences"; private static final String PASSWORD_PREFERENCES_URL = "/fineract-provider/api/v1/passwordpreferences";
public static Object updatePasswordPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object updatePasswordPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
String validationPolicyId) { String validationPolicyId) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE PASSWORD PREFERENCE---------------------------------------------"); System.out.println("---------------------------------UPDATE PASSWORD PREFERENCE---------------------------------------------");
@@ -64,7 +64,7 @@ public class PaymentTypeHelper {
final Integer paymentTypeId) { final Integer paymentTypeId) {
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + paymentTypeId + "?" + Utils.TENANT_IDENTIFIER; final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + paymentTypeId + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------GET PAYMENT TYPE---------------------------------------------"); System.out.println("---------------------------------GET PAYMENT TYPE---------------------------------------------");
Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, ""); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "");
final String jsonData = new Gson().toJson(get); final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() {}.getType()); return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() {}.getType());
@@ -104,7 +104,7 @@ public class ProvisioningIntegrationTest {
Map newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId) ; Map newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId) ;
validateProvisioningCriteria(requestCriteria, newCriteria) ; validateProvisioningCriteria(requestCriteria, newCriteria) ;
ArrayList definitions = (ArrayList)newCriteria.get("definitions") ; ArrayList definitions = (ArrayList)newCriteria.get("definitions") ;
for(int i = 0 ; i < definitions.size(); i++) { for(int i = 0 ; i < definitions.size(); i++) {
Map criteriadefinition = (Map) definitions.get(i) ; Map criteriadefinition = (Map) definitions.get(i) ;
@@ -115,9 +115,9 @@ public class ProvisioningIntegrationTest {
Integer criteriaId1 = transactionHelper.updateProvisioningCriteria(criteriaId, updateCriteriaString) ; Integer criteriaId1 = transactionHelper.updateProvisioningCriteria(criteriaId, updateCriteriaString) ;
Map updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1) ; Map updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1) ;
validateProvisioningCriteria(newCriteria, updatedCriteria) ; validateProvisioningCriteria(newCriteria, updatedCriteria) ;
transactionHelper.deleteProvisioningCriteria(criteriaId1) ; transactionHelper.deleteProvisioningCriteria(criteriaId1) ;
categories = transactionHelper.retrieveAllProvisioningCategories(); categories = transactionHelper.retrieveAllProvisioningCategories();
liability = accountHelper.createLiabilityAccount() ; liability = accountHelper.createLiabilityAccount() ;
expense = accountHelper.createExpenseAccount() ; expense = accountHelper.createExpenseAccount() ;
@@ -129,7 +129,7 @@ public class ProvisioningIntegrationTest {
String provisioningEntryJson = ProvisioningHelper.createProvisioningEntryJson(); String provisioningEntryJson = ProvisioningHelper.createProvisioningEntryJson();
Integer provisioningEntryId = transactionHelper.createProvisioningEntries(provisioningEntryJson); Integer provisioningEntryId = transactionHelper.createProvisioningEntries(provisioningEntryJson);
Assert.assertNotNull(provisioningEntryId); Assert.assertNotNull(provisioningEntryId);
transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, "") ; transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, "") ;
transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, "") ; transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, "") ;
Map entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId) ; Map entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId) ;
@@ -139,24 +139,24 @@ public class ProvisioningIntegrationTest {
} }
private void validateProvisioningCriteria(Map requestCriteria, Map newCriteria) { private void validateProvisioningCriteria(Map requestCriteria, Map newCriteria) {
//criteria name validation //criteria name validation
String requestCriteriaName = (String)requestCriteria.get("criteriaName") ; String requestCriteriaName = (String)requestCriteria.get("criteriaName") ;
String criteriaName = (String)newCriteria.get("criteriaName") ; String criteriaName = (String)newCriteria.get("criteriaName") ;
Assert.assertEquals(criteriaName, requestCriteriaName) ; Assert.assertEquals(criteriaName, requestCriteriaName) ;
//loan products validation //loan products validation
ArrayList requestProducts = (ArrayList)requestCriteria.get("loanProducts") ; ArrayList requestProducts = (ArrayList)requestCriteria.get("loanProducts") ;
ArrayList products = (ArrayList)newCriteria.get("loanProducts") ; ArrayList products = (ArrayList)newCriteria.get("loanProducts") ;
Assert.assertEquals(products.size(), requestProducts.size()) ; Assert.assertEquals(products.size(), requestProducts.size()) ;
ArrayList requestedDefinitions = (ArrayList)requestCriteria.get("definitions") ; ArrayList requestedDefinitions = (ArrayList)requestCriteria.get("definitions") ;
ArrayList newdefintions = (ArrayList) newCriteria.get("definitions") ; ArrayList newdefintions = (ArrayList) newCriteria.get("definitions") ;
Assert.assertEquals(newdefintions.size(), requestedDefinitions.size()) ; Assert.assertEquals(newdefintions.size(), requestedDefinitions.size()) ;
for(int i = 0 ; i < newdefintions.size() ; i++) { for(int i = 0 ; i < newdefintions.size() ; i++) {
Map requestedMap = (Map)requestedDefinitions.get(i) ; Map requestedMap = (Map)requestedDefinitions.get(i) ;
Object requestedCategoryId = requestedMap.get("categoryId") ; Object requestedCategoryId = requestedMap.get("categoryId") ;
boolean found = false ; boolean found = false ;
for(int j = 0 ; j < newdefintions.size(); j++) { for(int j = 0 ; j < newdefintions.size(); j++) {
Map newMap = (Map)newdefintions.get(j) ; Map newMap = (Map)newdefintions.get(j) ;
Object newCategoryId = newMap.get("categoryId") ; Object newCategoryId = newMap.get("categoryId") ;
@@ -175,13 +175,13 @@ public class ProvisioningIntegrationTest {
if(!found) Assert.fail("No Category found with Id:"+requestedCategoryId); if(!found) Assert.fail("No Category found with Id:"+requestedCategoryId);
} }
} }
private void checkProperty(String propertyName, Map requestMap, Map newMap) { private void checkProperty(String propertyName, Map requestMap, Map newMap) {
Object requested = requestMap.get(propertyName) ; Object requested = requestMap.get(propertyName) ;
Object modified = newMap.get(propertyName) ; Object modified = newMap.get(propertyName) ;
Assert.assertEquals(requested, modified) ; Assert.assertEquals(requested, modified) ;
} }
private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() // LoanProductTestBuilder builder = new LoanProductTestBuilder() //
@@ -199,7 +199,7 @@ public class ProvisioningIntegrationTest {
builder = builder.withInterestCalculationPeriodTypeAsRepaymentPeriod(true); builder = builder.withInterestCalculationPeriodTypeAsRepaymentPeriod(true);
} }
final String loanProductJSON = builder.build(null); final String loanProductJSON = builder.build(null);
return this.loanTransactionHelper.getLoanProductId(loanProductJSON); return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
} }
@@ -222,7 +222,7 @@ public class ProvisioningIntegrationTest {
.withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId); .withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
return this.loanTransactionHelper.getLoanId(loanApplicationJSON); return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
} }
private boolean isAlreadyProvisioningEntriesCreated() { private boolean isAlreadyProvisioningEntriesCreated() {
ProvisioningTransactionHelper transactionHelper = new ProvisioningTransactionHelper(requestSpec, responseSpec); ProvisioningTransactionHelper transactionHelper = new ProvisioningTransactionHelper(requestSpec, responseSpec);
Map entries = transactionHelper.retrieveAllProvisioningEntries() ; Map entries = transactionHelper.retrieveAllProvisioningEntries() ;
@@ -67,13 +67,13 @@ public class AccountHelper {
liabilityAccountJSON, this.GL_ACCOUNT_ID_RESPONSE); liabilityAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.LIABILITY); return new Account(accountID, Account.AccountType.LIABILITY);
} }
public ArrayList getAccountingWithRunningBalances() { public ArrayList getAccountingWithRunningBalances() {
final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts?fetchRunningBalance=true"; final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts?fetchRunningBalance=true";
final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_RUNNING_BALANCE_URL, ""); final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_RUNNING_BALANCE_URL, "");
return accountRunningBalance; return accountRunningBalance;
} }
public HashMap getAccountingWithRunningBalanceById(final String accountId) { public HashMap getAccountingWithRunningBalanceById(final String accountId) {
final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts/" + accountId + "?fetchRunningBalance=true"; final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts/" + accountId + "?fetchRunningBalance=true";
final HashMap accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_RUNNING_BALANCE_URL, ""); final HashMap accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_RUNNING_BALANCE_URL, "");
@@ -61,7 +61,7 @@ public class GLAccountBuilder {
accountType = ASSET_ACCOUNT; accountType = ASSET_ACCOUNT;
glCode = Utils.randomStringGenerator("ASSET_", 2); glCode = Utils.randomStringGenerator("ASSET_", 2);
// Add unique timestamp to avoid random collisions // Add unique timestamp to avoid random collisions
glCode += Calendar.getInstance().getTimeInMillis() + ""; glCode += Calendar.getInstance().getTimeInMillis() + "";
return this; return this;
} }
@@ -39,7 +39,7 @@ public class ChargesHelper {
private static final Integer CHARGE_APPLIES_TO_SAVINGS = 2; private static final Integer CHARGE_APPLIES_TO_SAVINGS = 2;
private static final Integer CHARGE_APPLIES_TO_CLIENT = 3; private static final Integer CHARGE_APPLIES_TO_CLIENT = 3;
private static final Integer CHARGE_APPLIES_TO_SHARES = 4; private static final Integer CHARGE_APPLIES_TO_SHARES = 4;
private static final Integer CHARGE_DISBURSEMENT_FEE = 1; private static final Integer CHARGE_DISBURSEMENT_FEE = 1;
private static final Integer CHARGE_SPECIFIED_DUE_DATE = 2; private static final Integer CHARGE_SPECIFIED_DUE_DATE = 2;
private static final Integer CHARGE_SAVINGS_ACTIVATION_FEE = 3; private static final Integer CHARGE_SAVINGS_ACTIVATION_FEE = 3;
@@ -53,9 +53,9 @@ public class ChargesHelper {
private static final Integer SHAREACCOUNT_ACTIVATION = 13 ; private static final Integer SHAREACCOUNT_ACTIVATION = 13 ;
private static final Integer SHARE_PURCHASE = 14 ; private static final Integer SHARE_PURCHASE = 14 ;
private static final Integer SHARE_REDEEM = 15 ; private static final Integer SHARE_REDEEM = 15 ;
private static final Integer CHARGE_SAVINGS_NO_ACTIVITY_FEE = 16; private static final Integer CHARGE_SAVINGS_NO_ACTIVITY_FEE = 16;
private static final Integer CHARGE_CLIENT_SPECIFIED_DUE_DATE = 1; private static final Integer CHARGE_CLIENT_SPECIFIED_DUE_DATE = 1;
public static final Integer CHARGE_CALCULATION_TYPE_FLAT = 1; public static final Integer CHARGE_CALCULATION_TYPE_FLAT = 1;
@@ -125,7 +125,7 @@ public class ChargesHelper {
System.out.println(chargesCreateJson); System.out.println(chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getSavingsWeeklyFeeJSON() { public static String getSavingsWeeklyFeeJSON() {
final HashMap<String, Object> map = populateDefaultsForSavings(); final HashMap<String, Object> map = populateDefaultsForSavings();
map.put("chargeTimeType", WEEKLY_FEE); map.put("chargeTimeType", WEEKLY_FEE);
@@ -247,21 +247,21 @@ public class ChargesHelper {
System.out.println(chargesCreateJson); System.out.println(chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getShareAccountPurchaseChargeJson() { public static String getShareAccountPurchaseChargeJson() {
HashMap<String, Object> map = populateDefaultsSharePurchaseFlatCharge() ; HashMap<String, Object> map = populateDefaultsSharePurchaseFlatCharge() ;
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); System.out.println(chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getShareAccountRedeemChargeJson() { public static String getShareAccountRedeemChargeJson() {
HashMap<String, Object> map = populateDefaultsShareRedeemFlatCharge() ; HashMap<String, Object> map = populateDefaultsShareRedeemFlatCharge() ;
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); System.out.println(chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanOverdueFeeJSON() { public static String getLoanOverdueFeeJSON() {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("penalty", ChargesHelper.penalty); map.put("penalty", ChargesHelper.penalty);
@@ -274,7 +274,7 @@ public class ChargesHelper {
System.out.println(chargesCreateJson); System.out.println(chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanOverdueFeeJSONWithCalculattionTypePercentage(String penaltyPercentageAmount) { public static String getLoanOverdueFeeJSONWithCalculattionTypePercentage(String penaltyPercentageAmount) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("penalty", ChargesHelper.penalty); map.put("penalty", ChargesHelper.penalty);
@@ -299,7 +299,7 @@ public class ChargesHelper {
map.put("name", Utils.randomNameGenerator("Charge_Loans_", 6)); map.put("name", Utils.randomNameGenerator("Charge_Loans_", 6));
return map; return map;
} }
public static HashMap<String, Object> populateDefaultsClientCharge() { public static HashMap<String, Object> populateDefaultsClientCharge() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.active);
@@ -326,7 +326,7 @@ public class ChargesHelper {
map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8));
return map; return map;
} }
public static HashMap<String, Object> populateDefaultsSharePurchaseFlatCharge() { public static HashMap<String, Object> populateDefaultsSharePurchaseFlatCharge() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.active);
@@ -339,7 +339,7 @@ public class ChargesHelper {
map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8));
return map; return map;
} }
public static HashMap<String, Object> populateDefaultsShareRedeemFlatCharge() { public static HashMap<String, Object> populateDefaultsShareRedeemFlatCharge() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.active);
@@ -352,7 +352,7 @@ public class ChargesHelper {
map.put("name", Utils.randomNameGenerator("Charge_Share_Redeem_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Redeem_", 8));
return map; return map;
} }
public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String request) { final String request) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
@@ -472,7 +472,7 @@ public class ChargesHelper {
System.out.println(json); System.out.println(json);
return json; return json;
} }
public static String getChargeSpecifiedDueDateJSON() { public static String getChargeSpecifiedDueDateJSON() {
final HashMap<String, Object> map = populateDefaultsClientCharge(); final HashMap<String, Object> map = populateDefaultsClientCharge();
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
@@ -482,6 +482,6 @@ public class ChargesHelper {
public static String applyCharge(RequestSpecification requestSpec,ResponseSpecification responseSpec, String chargeId,String json) { public static String applyCharge(RequestSpecification requestSpec,ResponseSpecification responseSpec, String chargeId,String json) {
return Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json,"status"); return Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json,"status");
} }
} }
@@ -87,7 +87,7 @@ public class FixedDepositAccountStatusChecker {
assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "prematureClosed")); assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "prematureClosed"));
System.out.println(fixedDepositStatusHashMap); System.out.println(fixedDepositStatusHashMap);
} }
public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------"); System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue("ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "matured")); assertTrue("ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "matured"));
@@ -74,7 +74,7 @@ public class FixedDepositProductHelper {
private static final String ACCRUAL_UPFRONT = "4"; private static final String ACCRUAL_UPFRONT = "4";
private static final String WHOLE_TERM = "1"; private static final String WHOLE_TERM = "1";
private static final String TILL_PREMATURE_WITHDRAWAL = "2"; private static final String TILL_PREMATURE_WITHDRAWAL = "2";
private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6); private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6);
private String shortName = Utils.randomNameGenerator("", 4); private String shortName = Utils.randomNameGenerator("", 4);
@@ -147,7 +147,7 @@ public class FixedDepositProductHelper {
map.put("taxGroupId", taxGroupId); map.put("taxGroupId", taxGroupId);
} }
if (this.accountingRule.equals(CASH_BASED)) { if (this.accountingRule.equals(CASH_BASED)) {
map.putAll(getAccountMappingForCashBased()); map.putAll(getAccountMappingForCashBased());
@@ -389,7 +389,7 @@ public class FixedDepositProductHelper {
this.chartSlabs = constructChartSlabWithAmountAndPeriodRange(); this.chartSlabs = constructChartSlabWithAmountAndPeriodRange();
return this; return this;
} }
public FixedDepositProductHelper withWithHoldTax(final String taxGroupId) { public FixedDepositProductHelper withWithHoldTax(final String taxGroupId) {
if (taxGroupId != null) { if (taxGroupId != null) {
this.withHoldTax = true; this.withHoldTax = true;
@@ -303,7 +303,7 @@ public class LoanApplicationTestBuilder {
* disbursement with the group meetings (it seems that if we do use this * disbursement with the group meetings (it seems that if we do use this
* parameter we should also use calendarID to sync repayment with group * parameter we should also use calendarID to sync repayment with group
* meetings) * meetings)
* *
* @return * @return
*/ */
public LoanApplicationTestBuilder withSyncDisbursementWithMeetin() { public LoanApplicationTestBuilder withSyncDisbursementWithMeetin() {
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals;
import java.util.HashMap; import java.util.HashMap;
public class LoanDisbursementTestBuilder { public class LoanDisbursementTestBuilder {
String dueDate = null; String dueDate = null;
Float totalOriginalDueForPeriod = null; Float totalOriginalDueForPeriod = null;
Float totalOutstandingForPeriod = null; Float totalOutstandingForPeriod = null;
@@ -32,8 +32,8 @@ public class LoanDisbursementTestBuilder {
Float principalLoanBalanceOutstanding = null; Float principalLoanBalanceOutstanding = null;
Float principalDue = null; Float principalDue = null;
Float principalOriginalDue = null; Float principalOriginalDue = null;
String fromDate = null; String fromDate = null;
public LoanDisbursementTestBuilder(String dueDate,Float totalOriginalDueForPeriod,Float totalOutstandingForPeriod, public LoanDisbursementTestBuilder(String dueDate,Float totalOriginalDueForPeriod,Float totalOutstandingForPeriod,
Float interestOutstanding, Float principalOutstanding, Float principalLoanBalanceOutstanding, Float principalDue, Float interestOutstanding, Float principalOutstanding, Float principalLoanBalanceOutstanding, Float principalDue,
Float principalOriginalDue, String fromDate) { Float principalOriginalDue, String fromDate) {
@@ -45,7 +45,7 @@ public class LoanDisbursementTestBuilder {
this.principalLoanBalanceOutstanding = principalLoanBalanceOutstanding; this.principalLoanBalanceOutstanding = principalLoanBalanceOutstanding;
this.principalDue = principalDue; this.principalDue = principalDue;
this.principalOriginalDue = principalOriginalDue; this.principalOriginalDue = principalOriginalDue;
this.fromDate = fromDate; this.fromDate = fromDate;
} }
public String getDueDate() { public String getDueDate() {
@@ -83,7 +83,7 @@ public class LoanDisbursementTestBuilder {
public String getFromDate() { public String getFromDate() {
return this.fromDate; return this.fromDate;
} }
/*public HashMap<String, String> build(String dueDate,String totalOriginalDueForPeriod,String totalOutstandingForPeriod, /*public HashMap<String, String> build(String dueDate,String totalOriginalDueForPeriod,String totalOutstandingForPeriod,
String interestOutstanding, String principalOutstanding, String principalLoanBalanceOutstanding, String principalDue, String interestOutstanding, String principalOutstanding, String principalLoanBalanceOutstanding, String principalDue,
String principalOriginalDue, String fromDate) { String principalOriginalDue, String fromDate) {
@@ -102,7 +102,7 @@ public class LoanDisbursementTestBuilder {
expectedRepaymentSchedule.put("principalOriginalDue", expectedRepaymentSchedule.put("principalOriginalDue",
principalOriginalDue); principalOriginalDue);
expectedRepaymentSchedule.put("fromDate", fromDate); expectedRepaymentSchedule.put("fromDate", fromDate);
return expectedRepaymentSchedule; return expectedRepaymentSchedule;
}*/ }*/
} }
@@ -116,7 +116,7 @@ public class LoanProductTestBuilder {
private String graceOnInterestPayment = "1"; private String graceOnInterestPayment = "1";
private JsonObject allowAttributeOverrides = null; private JsonObject allowAttributeOverrides = null;
private Boolean allowPartialPeriodInterestCalcualtion = false; private Boolean allowPartialPeriodInterestCalcualtion = false;
private Boolean allowVariableInstallments = Boolean.FALSE; private Boolean allowVariableInstallments = Boolean.FALSE;
private Integer minimumGap; private Integer minimumGap;
private Integer maximumGap; private Integer maximumGap;
@@ -212,7 +212,7 @@ public class LoanProductTestBuilder {
map.put("minimumGap", minimumGap) ; map.put("minimumGap", minimumGap) ;
map.put("maximumGap", maximumGap) ; map.put("maximumGap", maximumGap) ;
} }
map.put("syncExpectedWithDisbursementDate", map.put("syncExpectedWithDisbursementDate",
this.syncExpectedWithDisbursementDate); this.syncExpectedWithDisbursementDate);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -494,16 +494,16 @@ public class LoanProductTestBuilder {
this.allowAttributeOverrides = loanProductConfigurableAttributes; this.allowAttributeOverrides = loanProductConfigurableAttributes;
return this; return this;
} }
public LoanProductTestBuilder withVariableInstallmentsConfig(Boolean allowVariableInstallments, Integer minimumGap, Integer maximumGap) { public LoanProductTestBuilder withVariableInstallmentsConfig(Boolean allowVariableInstallments, Integer minimumGap, Integer maximumGap) {
this.allowVariableInstallments = allowVariableInstallments ; this.allowVariableInstallments = allowVariableInstallments ;
this.minimumGap = minimumGap; this.minimumGap = minimumGap;
this.maximumGap = maximumGap; this.maximumGap = maximumGap;
return this ; return this ;
} }
public LoanProductTestBuilder withSyncExpectedWithDisbursementDate(Boolean syncExpectedWithDisbursementDate) { public LoanProductTestBuilder withSyncExpectedWithDisbursementDate(Boolean syncExpectedWithDisbursementDate) {
this.syncExpectedWithDisbursementDate = this.syncExpectedWithDisbursementDate =
syncExpectedWithDisbursementDate ; syncExpectedWithDisbursementDate ;
return this ; return this ;
} }
@@ -190,7 +190,7 @@ public class LoanTransactionHelper {
public HashMap disburseLoan(final String date, final Integer loanID) { public HashMap disburseLoan(final String date, final Integer loanID) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null)); return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null));
} }
public HashMap disburseLoanWithRepaymentReschedule(final String date, final Integer loanID, String adjustRepaymentDate) { public HashMap disburseLoanWithRepaymentReschedule(final String date, final Integer loanID, String adjustRepaymentDate) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanWithRepaymentRescheduleAsJSON(date, return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanWithRepaymentRescheduleAsJSON(date,
null, adjustRepaymentDate)); null, adjustRepaymentDate));
@@ -203,7 +203,7 @@ public class LoanTransactionHelper {
public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError) { public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null), responseValidationError); return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null), responseValidationError);
} }
public HashMap disburseLoanToSavings(final String date, final Integer loanID) { public HashMap disburseLoanToSavings(final String date, final Integer loanID) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), getDisburseLoanAsJSON(date, null)); return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), getDisburseLoanAsJSON(date, null));
} }
@@ -215,7 +215,7 @@ public class LoanTransactionHelper {
System.out.println("IN DISBURSE LOAN URL " + url); System.out.println("IN DISBURSE LOAN URL " + url);
return performLoanTransaction(createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND, loanID), undoDisburseJson); return performLoanTransaction(createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND, loanID), undoDisburseJson);
} }
public Float undoLastDisbursal(final Integer loanID) { public Float undoLastDisbursal(final Integer loanID) {
final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}"; final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}";
final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID); final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID);
@@ -267,7 +267,7 @@ public class LoanTransactionHelper {
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER; final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, responseSpecification, ADD_CHARGES_URL, request, ""); return Utils.performServerPost(this.requestSpec, responseSpecification, ADD_CHARGES_URL, request, "");
} }
public Integer updateChargesForLoan(final Integer loanId, final Integer loanchargeId, final String request) { public Integer updateChargesForLoan(final Integer loanId, final Integer loanchargeId, final String request) {
System.out.println("--------------------------------- ADD CHARGES FOR LOAN --------------------------------"); System.out.println("--------------------------------- ADD CHARGES FOR LOAN --------------------------------");
final String UPDATE_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?" final String UPDATE_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?"
@@ -312,7 +312,7 @@ public class LoanTransactionHelper {
System.out.println("Loan Application disburse request : " + map); System.out.println("Loan Application disburse request : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
private String getDisburseLoanWithRepaymentRescheduleAsJSON(final String actualDisbursementDate, final String transactionAmount, final String adjustRepaymentDate) { private String getDisburseLoanWithRepaymentRescheduleAsJSON(final String actualDisbursementDate, final String transactionAmount, final String adjustRepaymentDate) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
@@ -509,7 +509,7 @@ public class LoanTransactionHelper {
"changes"); "changes");
return (HashMap) response.get("status"); return (HashMap) response.get("status");
} }
private Float performUndoLastLoanDisbursementTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) { private Float performUndoLastLoanDisbursementTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) {
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent,
@@ -520,10 +520,10 @@ public class LoanTransactionHelper {
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, final String responseAttribute) { private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, responseAttribute); return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, responseAttribute);
} }
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, ResponseSpecification responseValidationError) { private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, ResponseSpecification responseValidationError) {
return Utils.performServerPost(this.requestSpec, responseValidationError, postURLForLoanTransaction, jsonToBeSent, CommonConstants.RESPONSE_ERROR); return Utils.performServerPost(this.requestSpec, responseValidationError, postURLForLoanTransaction, jsonToBeSent, CommonConstants.RESPONSE_ERROR);
} }
public Object adjustLoanTransaction(final Integer loanId, final Integer transactionId, final String date, public Object adjustLoanTransaction(final Integer loanId, final Integer transactionId, final String date,
@@ -635,7 +635,7 @@ public class LoanTransactionHelper {
map.put("locale", "en"); map.put("locale", "en");
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public HashMap createTrancheDetail(final String id, final String date, final String amount) { public HashMap createTrancheDetail(final String id, final String date, final String amount) {
HashMap<String, Object> detail = new HashMap<>(); HashMap<String, Object> detail = new HashMap<>();
if(id != null){ if(id != null){
@@ -646,30 +646,30 @@ public class LoanTransactionHelper {
return detail; return detail;
} }
public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, final String approvalAmount, final String expectedDisbursementDate, public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, final String approvalAmount, final String expectedDisbursementDate,
final String updatedExpectedDisbursementDate, final String updatedPrincipal, final String jsonAttributeToGetBack) { final String updatedExpectedDisbursementDate, final String updatedPrincipal, final String jsonAttributeToGetBack) {
return Utils.performServerPut(this.requestSpec, this.responseSpec, createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, return Utils.performServerPut(this.requestSpec, this.responseSpec, createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount, expectedDisbursementDate,
updatedExpectedDisbursementDate, updatedPrincipal), jsonAttributeToGetBack); updatedExpectedDisbursementDate, updatedPrincipal), jsonAttributeToGetBack);
} }
public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, final String expectedDisbursementDate public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, final String expectedDisbursementDate
, List<HashMap> disbursementData, final String jsonAttributeToGetBack) { , List<HashMap> disbursementData, final String jsonAttributeToGetBack) {
return Utils.performServerPut(this.requestSpec, this.responseSpec, createAddAndDeleteDisbursementURL(loanID), return Utils.performServerPut(this.requestSpec, this.responseSpec, createAddAndDeleteDisbursementURL(loanID),
getAddAndDeleteDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, disbursementData), jsonAttributeToGetBack); getAddAndDeleteDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, disbursementData), jsonAttributeToGetBack);
} }
private String createEditDisbursementURL(Integer loanID, Integer disbursementId) { private String createEditDisbursementURL(Integer loanID, Integer disbursementId) {
return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/" + disbursementId + "?" + Utils.TENANT_IDENTIFIER; return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/" + disbursementId + "?" + Utils.TENANT_IDENTIFIER;
} }
private String createAddAndDeleteDisbursementURL(Integer loanID) { private String createAddAndDeleteDisbursementURL(Integer loanID) {
return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/editDisbursements?" + Utils.TENANT_IDENTIFIER; return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/editDisbursements?" + Utils.TENANT_IDENTIFIER;
} }
public static String getEditDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate, public static String getEditDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate,
final String updatedExpectedDisbursementDate, final String updatedPrincipal) { final String updatedExpectedDisbursementDate, final String updatedPrincipal) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
@@ -682,8 +682,8 @@ public class LoanTransactionHelper {
System.out.println(json); System.out.println(json);
return json; return json;
} }
public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate, public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate,
final List<HashMap> disbursementData) { final List<HashMap> disbursementData) {
final HashMap map = new HashMap<>(); final HashMap map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
@@ -56,7 +56,7 @@ public class ProvisioningHelper {
String provisioningEntryCreateJson = new Gson().toJson(map); String provisioningEntryCreateJson = new Gson().toJson(map);
return provisioningEntryCreateJson; return provisioningEntryCreateJson;
} }
public final static String createProvisioningEntryJsonWithJournalsEnabled() { public final static String createProvisioningEntryJsonWithJournalsEnabled() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("createjournalentries", Boolean.TRUE); map.put("createjournalentries", Boolean.TRUE);
@@ -30,63 +30,63 @@ import com.jayway.restassured.specification.ResponseSpecification;
public class ProvisioningTransactionHelper { public class ProvisioningTransactionHelper {
private static final String PROVISIONING_CATEGORY_URL = "/fineract-provider/api/v1/provisioningcategory?" + Utils.TENANT_IDENTIFIER ; private static final String PROVISIONING_CATEGORY_URL = "/fineract-provider/api/v1/provisioningcategory?" + Utils.TENANT_IDENTIFIER ;
private static final String CREATE_PROVISIONING_CRITERIA_URL = "/fineract-provider/api/v1/provisioningcriteria?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_PROVISIONING_CRITERIA_URL = "/fineract-provider/api/v1/provisioningcriteria?" + Utils.TENANT_IDENTIFIER;
private static final String CREATE_PROVISIONING_ENTRY_URL = "/fineract-provider/api/v1/provisioningentries?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_PROVISIONING_ENTRY_URL = "/fineract-provider/api/v1/provisioningentries?" + Utils.TENANT_IDENTIFIER;
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public ProvisioningTransactionHelper(RequestSpecification requestSpec, ResponseSpecification responeSpec) { public ProvisioningTransactionHelper(RequestSpecification requestSpec, ResponseSpecification responeSpec) {
this.requestSpec = requestSpec ; this.requestSpec = requestSpec ;
this.responseSpec = responeSpec ; this.responseSpec = responeSpec ;
} }
public ArrayList retrieveAllProvisioningCategories() { public ArrayList retrieveAllProvisioningCategories() {
return Utils.performServerGet(requestSpec, responseSpec, PROVISIONING_CATEGORY_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, PROVISIONING_CATEGORY_URL, "");
} }
public Integer createProvisioningCriteria(final String provsioningCriteriaJson) { public Integer createProvisioningCriteria(final String provsioningCriteriaJson) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_PROVISIONING_CRITERIA_URL, provsioningCriteriaJson, "resourceId"); return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_PROVISIONING_CRITERIA_URL, provsioningCriteriaJson, "resourceId");
} }
public Map retrieveProvisioningCriteria(final Integer criteriaId) { public Map retrieveProvisioningCriteria(final Integer criteriaId) {
String url = "/fineract-provider/api/v1/provisioningcriteria/"+criteriaId+"?"+Utils.TENANT_IDENTIFIER ; String url = "/fineract-provider/api/v1/provisioningcriteria/"+criteriaId+"?"+Utils.TENANT_IDENTIFIER ;
return Utils.performServerGet(requestSpec, responseSpec, url, ""); return Utils.performServerGet(requestSpec, responseSpec, url, "");
} }
public Integer updateProvisioningCriteria(final Integer criteriaId, final String provsioningCriteriaJson) { public Integer updateProvisioningCriteria(final Integer criteriaId, final String provsioningCriteriaJson) {
String url = "/fineract-provider/api/v1/provisioningcriteria/"+criteriaId+"?"+Utils.TENANT_IDENTIFIER ; String url = "/fineract-provider/api/v1/provisioningcriteria/"+criteriaId+"?"+Utils.TENANT_IDENTIFIER ;
return Utils.performServerPut(this.requestSpec, this.responseSpec, url, provsioningCriteriaJson, "resourceId"); return Utils.performServerPut(this.requestSpec, this.responseSpec, url, provsioningCriteriaJson, "resourceId");
} }
public Integer deleteProvisioningCriteria(final Integer criteriaId) { public Integer deleteProvisioningCriteria(final Integer criteriaId) {
String url = "/fineract-provider/api/v1/provisioningcriteria/"+criteriaId+"?"+Utils.TENANT_IDENTIFIER; String url = "/fineract-provider/api/v1/provisioningcriteria/"+criteriaId+"?"+Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(this.requestSpec, this.responseSpec, url, "resourceId"); return Utils.performServerDelete(this.requestSpec, this.responseSpec, url, "resourceId");
} }
public Integer createProvisioningEntries(final String provsioningCriteriaJson) { public Integer createProvisioningEntries(final String provsioningCriteriaJson) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_PROVISIONING_ENTRY_URL, provsioningCriteriaJson, "resourceId"); return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_PROVISIONING_ENTRY_URL, provsioningCriteriaJson, "resourceId");
} }
public Integer updateProvisioningEntry(final String command, final Integer entryId, String jsonBody) { public Integer updateProvisioningEntry(final String command, final Integer entryId, String jsonBody) {
String url = "/fineract-provider/api/v1/provisioningentries/" + entryId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; String url = "/fineract-provider/api/v1/provisioningentries/" + entryId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, url, jsonBody, "resourceId") ; return Utils.performServerPost(requestSpec, responseSpec, url, jsonBody, "resourceId") ;
} }
public Map retrieveProvisioningEntry(final Integer provisioningEntry) { public Map retrieveProvisioningEntry(final Integer provisioningEntry) {
String url = "/fineract-provider/api/v1/provisioningentries/"+provisioningEntry+"?"+Utils.TENANT_IDENTIFIER; ; String url = "/fineract-provider/api/v1/provisioningentries/"+provisioningEntry+"?"+Utils.TENANT_IDENTIFIER; ;
return Utils.performServerGet(requestSpec, responseSpec, url, "") ; return Utils.performServerGet(requestSpec, responseSpec, url, "") ;
} }
public Map retrieveProvisioningEntries(final Integer provisioningEntry) { public Map retrieveProvisioningEntries(final Integer provisioningEntry) {
String url = "/fineract-provider/api/v1/provisioningentries/entries?entryId="+provisioningEntry+"&"+Utils.TENANT_IDENTIFIER; ; String url = "/fineract-provider/api/v1/provisioningentries/entries?entryId="+provisioningEntry+"&"+Utils.TENANT_IDENTIFIER; ;
return Utils.performServerGet(requestSpec, responseSpec, url, "") ; return Utils.performServerGet(requestSpec, responseSpec, url, "") ;
} }
public Map retrieveAllProvisioningEntries() { public Map retrieveAllProvisioningEntries() {
String url = "/fineract-provider/api/v1/provisioningentries?dateFormat=dd MMMM yyyy"+"&"+"locale=en"+"&"+Utils.TENANT_IDENTIFIER; ; String url = "/fineract-provider/api/v1/provisioningentries?dateFormat=dd MMMM yyyy"+"&"+"locale=en"+"&"+Utils.TENANT_IDENTIFIER; ;
return Utils.performServerGet(requestSpec, responseSpec, url, "") ; return Utils.performServerGet(requestSpec, responseSpec, url, "") ;
} }
} }
@@ -504,7 +504,7 @@ public class RecurringDepositAccountHelper {
this.interestPostingPeriodType = interestPostingPeriodTypeId; this.interestPostingPeriodType = interestPostingPeriodTypeId;
return this; return this;
} }
public RecurringDepositAccountHelper withDepositPeriod(final String depositPeriod) { public RecurringDepositAccountHelper withDepositPeriod(final String depositPeriod) {
this.depositPeriod = depositPeriod; this.depositPeriod = depositPeriod;
return this; return this;
@@ -89,7 +89,7 @@ public class RecurringDepositAccountStatusChecker {
getStatus(recurringDepositStatusHashMap, "prematureClosed")); getStatus(recurringDepositStatusHashMap, "prematureClosed"));
System.out.println(recurringDepositStatusHashMap); System.out.println(recurringDepositStatusHashMap);
} }
public static void verifyRecurringDepositAccountIsMatured(HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositAccountIsMatured(HashMap recurringDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS MATURED ---------------------"); System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue("ERROR IN MATURITY JOB OF THE RECURRING DEPOSIT ACCOUNT", getStatus(recurringDepositStatusHashMap, "matured")); assertTrue("ERROR IN MATURITY JOB OF THE RECURRING DEPOSIT ACCOUNT", getStatus(recurringDepositStatusHashMap, "matured"));
@@ -190,7 +190,7 @@ public class RecurringDepositProductHelper {
this.chartSlabs = constructChartSlabWithAmountAndPeriodRange(); this.chartSlabs = constructChartSlabWithAmountAndPeriodRange();
return this; return this;
} }
public RecurringDepositProductHelper withWithHoldTax(final String taxGroupId) { public RecurringDepositProductHelper withWithHoldTax(final String taxGroupId) {
if (taxGroupId != null) { if (taxGroupId != null) {
this.withHoldTax = true; this.withHoldTax = true;
@@ -84,7 +84,7 @@ public class AccountTransferHelper {
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER,
accountTransferJSON, "savingsId"); accountTransferJSON, "savingsId");
} }
public Integer refundLoanByTransfer(final String date, final Integer fromClientId, final Integer fromAccountId, final Integer toClientId, public Integer refundLoanByTransfer(final String date, final Integer fromClientId, final Integer fromAccountId, final Integer toClientId,
final Integer toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) { final Integer toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) {
System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------"); System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------");
@@ -59,7 +59,7 @@ public class SavingsAccountHelper {
private static final String WITHDRAW_SAVINGS_COMMAND = "withdrawal"; private static final String WITHDRAW_SAVINGS_COMMAND = "withdrawal";
private static final String MODIFY_TRASACTION_COMMAND = "modify"; private static final String MODIFY_TRASACTION_COMMAND = "modify";
private static final String UNDO_TRASACTION_COMMAND = "undo"; private static final String UNDO_TRASACTION_COMMAND = "undo";
private static final String BLOCK_SAVINGS_COMMAND = "block"; private static final String BLOCK_SAVINGS_COMMAND = "block";
private static final String UNBLOCK_SAVINGS_COMMAND = "unblock"; private static final String UNBLOCK_SAVINGS_COMMAND = "unblock";
private static final String BLOCK_DEBITS_SAVINGS_COMMAND = "blockDebit"; private static final String BLOCK_DEBITS_SAVINGS_COMMAND = "blockDebit";
@@ -246,7 +246,7 @@ public class SavingsAccountHelper {
performSavingActions(createSavingsCalculateInterestURL(POST_INTEREST_SAVINGS_COMMAND, savingsId), performSavingActions(createSavingsCalculateInterestURL(POST_INTEREST_SAVINGS_COMMAND, savingsId),
getCalculatedInterestForSavingsApplicationAsJSON(), ""); getCalculatedInterestForSavingsApplicationAsJSON(), "");
} }
public void postInterestAsOnSavings(final Integer savingsId, final String today) { public void postInterestAsOnSavings(final Integer savingsId, final String today) {
System.out.println("--------------------------------- POST INTEREST AS ON FOR SAVINGS --------------------------------"); System.out.println("--------------------------------- POST INTEREST AS ON FOR SAVINGS --------------------------------");
performSavingActions(createSavingsPostInterestAsOnURL(POST_INTEREST_AS_ON_SAVINGS_COMMAND, savingsId), performSavingActions(createSavingsPostInterestAsOnURL(POST_INTEREST_AS_ON_SAVINGS_COMMAND, savingsId),
@@ -287,7 +287,7 @@ public class SavingsAccountHelper {
return Utils.performServerDelete(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "/" + savingsId + "/charges/" return Utils.performServerDelete(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "/" + savingsId + "/charges/"
+ chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID); + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID);
} }
public HashMap blockSavings(final Integer savingsID) { public HashMap blockSavings(final Integer savingsID) {
System.out.println("---------------------------------- BLOCKING SAVINGS ACCOUNT ----------------------------------"); System.out.println("---------------------------------- BLOCKING SAVINGS ACCOUNT ----------------------------------");
Boolean isBlock = true; Boolean isBlock = true;
@@ -406,7 +406,7 @@ public class SavingsAccountHelper {
System.out.println(savingsAccountCalculatedInterestJson); System.out.println(savingsAccountCalculatedInterestJson);
return savingsAccountCalculatedInterestJson; return savingsAccountCalculatedInterestJson;
} }
private String getCalculatedInterestForSavingsApplicationAsJSON(final String today) { private String getCalculatedInterestForSavingsApplicationAsJSON(final String today) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
@@ -451,11 +451,11 @@ public class SavingsAccountHelper {
map.put("closedOnDate", closedOnDate); map.put("closedOnDate", closedOnDate);
map.put("withdrawBalance", withdrawBalance); map.put("withdrawBalance", withdrawBalance);
map.put("note", "Close Test"); map.put("note", "Close Test");
String josn = new Gson().toJson(map); String josn = new Gson().toJson(map);
return josn; return josn;
} }
private String getCloseAccountPostInterestJSON(String withdrawBalance, String closedOnDate) { private String getCloseAccountPostInterestJSON(String withdrawBalance, String closedOnDate) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
@@ -464,7 +464,7 @@ public class SavingsAccountHelper {
map.put("withdrawBalance", withdrawBalance); map.put("withdrawBalance", withdrawBalance);
map.put("note", "Close Test"); map.put("note", "Close Test");
map.put("postInterestValidationOnClosure", "true"); map.put("postInterestValidationOnClosure", "true");
String josn = new Gson().toJson(map); String josn = new Gson().toJson(map);
return josn; return josn;
} }
@@ -485,7 +485,7 @@ public class SavingsAccountHelper {
private String createSavingsCalculateInterestURL(final String command, final Integer savingsID) { private String createSavingsCalculateInterestURL(final String command, final Integer savingsID) {
return SAVINGS_ACCOUNT_URL + "/" + savingsID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; return SAVINGS_ACCOUNT_URL + "/" + savingsID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
} }
private String createSavingsPostInterestAsOnURL(final String command, final Integer savingsID) { private String createSavingsPostInterestAsOnURL(final String command, final Integer savingsID) {
return SAVINGS_ACCOUNT_URL + "/" + savingsID + "/transactions/" + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; return SAVINGS_ACCOUNT_URL + "/" + savingsID + "/transactions/" + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
} }
@@ -569,7 +569,7 @@ public class SavingsAccountHelper {
return performSavingActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), return performSavingActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID),
getCloseAccountJSON(withdrawBalance, closedOnDate), jsonAttributeToGetBack); getCloseAccountJSON(withdrawBalance, closedOnDate), jsonAttributeToGetBack);
} }
public Object closeSavingsAccountPostInterestAndGetBackRequiredField(final Integer savingsID, String withdrawBalance, public Object closeSavingsAccountPostInterestAndGetBackRequiredField(final Integer savingsID, String withdrawBalance,
final String jsonAttributeToGetBack, final String closedOnDate) { final String jsonAttributeToGetBack, final String closedOnDate) {
System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------"); System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
@@ -29,7 +29,7 @@ import com.jayway.restassured.specification.ResponseSpecification;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class SavingsStatusChecker { public class SavingsStatusChecker {
private static final String SAVINGS_ACCOUNT_URL = "/fineract-provider/api/v1/savingsaccounts"; private static final String SAVINGS_ACCOUNT_URL = "/fineract-provider/api/v1/savingsaccounts";
public static void verifySavingsIsApproved(final HashMap savingsStatusHashMap) { public static void verifySavingsIsApproved(final HashMap savingsStatusHashMap) {
@@ -49,19 +49,19 @@ public class SavingsStatusChecker {
assertTrue("ERROR IN ACTIVATING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "active")); assertTrue("ERROR IN ACTIVATING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "active"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
} }
public static void verifySavingsIsRejected(final HashMap savingsStatusHashMap) { public static void verifySavingsIsRejected(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS REJECTED ------------------------------------"); System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS REJECTED ------------------------------------");
assertTrue("ERROR IN REJECTING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "rejected")); assertTrue("ERROR IN REJECTING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "rejected"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
} }
public static void verifySavingsIsWithdrawn(final HashMap savingsStatusHashMap) { public static void verifySavingsIsWithdrawn(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------"); System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------");
assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "withdrawnByApplicant")); assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "withdrawnByApplicant"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
} }
public static void verifySavingsAccountIsClosed(final HashMap savingsStatusHashMap) { public static void verifySavingsAccountIsClosed(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS CLOSED ------------------------------------"); System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS CLOSED ------------------------------------");
assertTrue("ERROR IN CLOSING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "closed")); assertTrue("ERROR IN CLOSING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "closed"));
@@ -95,13 +95,13 @@ public class SavingsStatusChecker {
assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "inactive")); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "inactive"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
} }
public static void verifySavingsSubStatusDormant(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusDormant(HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------");
assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "dormant")); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "dormant"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
} }
public static void verifySavingsSubStatusEscheat(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusEscheat(HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------");
assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "escheat")); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "escheat"));
@@ -113,7 +113,7 @@ public class SavingsStatusChecker {
assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "none")); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "none"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
} }
public static void verifySavingsSubStatusblock(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusblock(HashMap savingsStatusHashMap) {
System.out.println( System.out.println(
"\n-------------------------------------- VERIFYING SAVINGS ACCOUNT IS BLOCKED ------------------------------------"); "\n-------------------------------------- VERIFYING SAVINGS ACCOUNT IS BLOCKED ------------------------------------");
@@ -46,7 +46,7 @@ public class DividendsIntegrationTests {
private final String[] dates = {"01 Jan 2015", "01 Apr 2015", "01 Oct 2015", "01 Dec 2015", "01 Mar 2016"} ; private final String[] dates = {"01 Jan 2015", "01 Apr 2015", "01 Oct 2015", "01 Dec 2015", "01 Mar 2016"} ;
private final String[] shares = {"100", "200", "300", "100", "500"} ; private final String[] shares = {"100", "200", "300", "100", "500"} ;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -57,7 +57,7 @@ public class DividendsIntegrationTests {
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testCreateDividends() { public void testCreateDividends() {
@@ -78,7 +78,7 @@ public class DividendsIntegrationTests {
Assert.assertNotNull(shareAccountId); Assert.assertNotNull(shareAccountId);
Map<String, Object> shareAccountData = ShareAccountTransactionHelper Map<String, Object> shareAccountData = ShareAccountTransactionHelper
.retrieveShareAccount(shareAccountId, requestSpec, responseSpec); .retrieveShareAccount(shareAccountId, requestSpec, responseSpec);
Assert.assertNotNull(shareAccountData); Assert.assertNotNull(shareAccountData);
// Approve share Account // Approve share Account
Map<String, Object> approveMap = new HashMap<>(); Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note"); approveMap.put("note", "Share Account Approval Note");
@@ -95,7 +95,7 @@ public class DividendsIntegrationTests {
String activateJson = new Gson().toJson(activateMap); String activateJson = new Gson().toJson(activateMap);
ShareAccountTransactionHelper.postCommand("activate", shareAccountId, activateJson, requestSpec, responseSpec); ShareAccountTransactionHelper.postCommand("activate", shareAccountId, activateJson, requestSpec, responseSpec);
} }
Map<String, Object> dividendsMap = new HashMap<>() ; Map<String, Object> dividendsMap = new HashMap<>() ;
dividendsMap.put("dividendPeriodStartDate", "01 Jan 2015") ; dividendsMap.put("dividendPeriodStartDate", "01 Jan 2015") ;
dividendsMap.put("dividendPeriodEndDate", "01 Apr 2016") ; dividendsMap.put("dividendPeriodEndDate", "01 Apr 2016") ;
@@ -104,7 +104,7 @@ public class DividendsIntegrationTests {
dividendsMap.put("locale", "en"); dividendsMap.put("locale", "en");
String createDividendsJson = new Gson().toJson(dividendsMap); String createDividendsJson = new Gson().toJson(dividendsMap);
final Integer dividendId = ShareDividendsTransactionHelper.createShareProductDividends(productId, createDividendsJson, requestSpec, responseSpec) ; final Integer dividendId = ShareDividendsTransactionHelper.createShareProductDividends(productId, createDividendsJson, requestSpec, responseSpec) ;
Map<String, Object> productdividends = ShareDividendsTransactionHelper.retrieveAllDividends(productId, requestSpec, responseSpec); Map<String, Object> productdividends = ShareDividendsTransactionHelper.retrieveAllDividends(productId, requestSpec, responseSpec);
Assert.assertEquals("1", String.valueOf(productdividends.get("totalFilteredRecords"))); Assert.assertEquals("1", String.valueOf(productdividends.get("totalFilteredRecords")));
Map<String,Object> dividend = ((List<Map<String,Object>>)productdividends.get("pageItems")).get(0) ; Map<String,Object> dividend = ((List<Map<String,Object>>)productdividends.get("pageItems")).get(0) ;
@@ -121,14 +121,14 @@ public class DividendsIntegrationTests {
cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2)); cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2));
Date endDate = cal.getTime(); Date endDate = cal.getTime();
Assert.assertEquals("01 Apr 2016", simple.format(endDate)); Assert.assertEquals("01 Apr 2016", simple.format(endDate));
Map<String, Object> dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec, responseSpec) ; Map<String, Object> dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec, responseSpec) ;
Assert.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords"))); Assert.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords")));
List<Map<String, Object>> pageItems = (List<Map<String, Object>>)dividenddetails.get("pageItems") ; List<Map<String, Object>> pageItems = (List<Map<String, Object>>)dividenddetails.get("pageItems") ;
for(Map<String, Object> dividendData: pageItems) { for(Map<String, Object> dividendData: pageItems) {
Map<String, Object> accountData = (Map<String, Object>) dividendData.get("accountData") ; Map<String, Object> accountData = (Map<String, Object>) dividendData.get("accountData") ;
String accountId = String.valueOf(accountData.get("id")) ; String accountId = String.valueOf(accountData.get("id")) ;
if(String.valueOf(shareAccounts.get(0)).equals(accountId)) { if(String.valueOf(shareAccounts.get(0)).equals(accountId)) {
Assert.assertEquals("11320.755", String.valueOf(dividendData.get("amount"))); Assert.assertEquals("11320.755", String.valueOf(dividendData.get("amount")));
@@ -144,10 +144,10 @@ public class DividendsIntegrationTests {
Map<String, Object> statusMap = (Map<String, Object>) dividendData.get("status") ; Map<String, Object> statusMap = (Map<String, Object>) dividendData.get("status") ;
Assert.assertEquals("shareAccountDividendStatusType.initiated", String.valueOf(statusMap.get("code"))) ; Assert.assertEquals("shareAccountDividendStatusType.initiated", String.valueOf(statusMap.get("code"))) ;
} }
String jsonString = "" ; String jsonString = "" ;
ShareDividendsTransactionHelper.postCommand("approve", productId, dividendId, jsonString, requestSpec, responseSpec) ; ShareDividendsTransactionHelper.postCommand("approve", productId, dividendId, jsonString, requestSpec, responseSpec) ;
productdividends = ShareDividendsTransactionHelper.retrieveAllDividends(productId, requestSpec, responseSpec); productdividends = ShareDividendsTransactionHelper.retrieveAllDividends(productId, requestSpec, responseSpec);
Assert.assertEquals("1", String.valueOf(productdividends.get("totalFilteredRecords"))); Assert.assertEquals("1", String.valueOf(productdividends.get("totalFilteredRecords")));
dividend = ((List<Map<String,Object>>)productdividends.get("pageItems")).get(0) ; dividend = ((List<Map<String,Object>>)productdividends.get("pageItems")).get(0) ;
@@ -164,12 +164,12 @@ public class DividendsIntegrationTests {
cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2)); cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2));
endDate = cal.getTime(); endDate = cal.getTime();
Assert.assertEquals("01 Apr 2016", simple.format(endDate)); Assert.assertEquals("01 Apr 2016", simple.format(endDate));
dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec, responseSpec) ; dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec, responseSpec) ;
Assert.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords"))); Assert.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords")));
pageItems = (List<Map<String, Object>>)dividenddetails.get("pageItems") ; pageItems = (List<Map<String, Object>>)dividenddetails.get("pageItems") ;
for(Map<String, Object> dividendData: pageItems) { for(Map<String, Object> dividendData: pageItems) {
Map<String, Object> accountData = (Map<String, Object>) dividendData.get("accountData") ; Map<String, Object> accountData = (Map<String, Object>) dividendData.get("accountData") ;
String accountId = String.valueOf(accountData.get("id")) ; String accountId = String.valueOf(accountData.get("id")) ;
if(String.valueOf(shareAccounts.get(0)).equals(accountId)) { if(String.valueOf(shareAccounts.get(0)).equals(accountId)) {
Assert.assertEquals("11320.755", String.valueOf(dividendData.get("amount"))); Assert.assertEquals("11320.755", String.valueOf(dividendData.get("amount")));
@@ -185,14 +185,14 @@ public class DividendsIntegrationTests {
Map<String, Object> statusMap = (Map<String, Object>) dividendData.get("status") ; Map<String, Object> statusMap = (Map<String, Object>) dividendData.get("status") ;
Assert.assertEquals("shareAccountDividendStatusType.initiated", String.valueOf(statusMap.get("code"))) ; Assert.assertEquals("shareAccountDividendStatusType.initiated", String.valueOf(statusMap.get("code"))) ;
} }
} }
private Integer createShareProduct() { private Integer createShareProduct() {
String shareProductJson = new ShareProductHelper().build(); String shareProductJson = new ShareProductHelper().build();
return ShareProductTransactionHelper.createShareProduct(shareProductJson, requestSpec, responseSpec); return ShareProductTransactionHelper.createShareProduct(shareProductJson, requestSpec, responseSpec);
} }
private Integer createShareAccount(final Integer clientId, final Integer productId, final Integer savingsAccountId, private Integer createShareAccount(final Integer clientId, final Integer productId, final Integer savingsAccountId,
String applicationDate, String requestedShares) { String applicationDate, String requestedShares) {
String josn = new ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId)) String josn = new ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId))
@@ -29,113 +29,113 @@ import com.google.gson.Gson;
public class ShareAccountHelper { public class ShareAccountHelper {
private static final String LOCALE = "en_GB"; private static final String LOCALE = "en_GB";
private String clientId ; private String clientId ;
private String productId ; private String productId ;
private String submittedDate ; private String submittedDate ;
private String externalId ; private String externalId ;
private String savingsAccountId ; private String savingsAccountId ;
private String requestedShares ; private String requestedShares ;
private String applicationDate ; private String applicationDate ;
private String allowDividendCalculationForInactiveClients ; private String allowDividendCalculationForInactiveClients ;
private String minimumActivePeriod ; private String minimumActivePeriod ;
private String minimumActivePeriodFrequencyType ; private String minimumActivePeriodFrequencyType ;
private String lockinPeriodFrequency ; private String lockinPeriodFrequency ;
private String lockinPeriodFrequencyType ; private String lockinPeriodFrequencyType ;
private List<Map<String, Object>> charges = null ; private List<Map<String, Object>> charges = null ;
//chargeId , amount //chargeId , amount
public String build() { public String build() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("locale", LOCALE); map.put("locale", LOCALE);
if(this.clientId != null) { if(this.clientId != null) {
map.put("clientId", this.clientId) ; map.put("clientId", this.clientId) ;
} }
if(this.productId != null) { if(this.productId != null) {
map.put("productId", this.productId) ; map.put("productId", this.productId) ;
} }
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
if(this.savingsAccountId != null) { if(this.savingsAccountId != null) {
map.put("savingsAccountId", savingsAccountId) ; map.put("savingsAccountId", savingsAccountId) ;
} }
if(externalId != null) { if(externalId != null) {
map.put("externalId", this.externalId) ; map.put("externalId", this.externalId) ;
} }
if(submittedDate != null) { if(submittedDate != null) {
map.put("submittedDate", this.submittedDate) ; map.put("submittedDate", this.submittedDate) ;
} }
if(applicationDate != null) { if(applicationDate != null) {
map.put("applicationDate", this.applicationDate) ; map.put("applicationDate", this.applicationDate) ;
} }
if(this.requestedShares != null) { if(this.requestedShares != null) {
map.put("requestedShares", this.requestedShares) ; map.put("requestedShares", this.requestedShares) ;
} }
if(this.allowDividendCalculationForInactiveClients != null) { if(this.allowDividendCalculationForInactiveClients != null) {
map.put("allowDividendCalculationForInactiveClients", this.allowDividendCalculationForInactiveClients) ; map.put("allowDividendCalculationForInactiveClients", this.allowDividendCalculationForInactiveClients) ;
} }
if(this.charges != null) { if(this.charges != null) {
map.put("charges", this.charges) ; map.put("charges", this.charges) ;
} }
String shareAccountCreateJson = new Gson().toJson(map); String shareAccountCreateJson = new Gson().toJson(map);
System.out.println(shareAccountCreateJson); System.out.println(shareAccountCreateJson);
return shareAccountCreateJson; return shareAccountCreateJson;
} }
public ShareAccountHelper withClientId(final String clientId) { public ShareAccountHelper withClientId(final String clientId) {
this.clientId = clientId ; this.clientId = clientId ;
return this ; return this ;
} }
public ShareAccountHelper withProductId(final String productId) { public ShareAccountHelper withProductId(final String productId) {
this.productId = productId ; this.productId = productId ;
return this ; return this ;
} }
public ShareAccountHelper withSavingsAccountId(final String savingsAccountId) { public ShareAccountHelper withSavingsAccountId(final String savingsAccountId) {
this.savingsAccountId = savingsAccountId ; this.savingsAccountId = savingsAccountId ;
return this ; return this ;
} }
public ShareAccountHelper withSubmittedDate(final String submittedDate) { public ShareAccountHelper withSubmittedDate(final String submittedDate) {
this.submittedDate = submittedDate ; this.submittedDate = submittedDate ;
return this ; return this ;
} }
public ShareAccountHelper withRequestedShares(final String requestedShares) { public ShareAccountHelper withRequestedShares(final String requestedShares) {
this.requestedShares = requestedShares ; this.requestedShares = requestedShares ;
return this ; return this ;
} }
public ShareAccountHelper withApplicationDate(final String applicationDate) { public ShareAccountHelper withApplicationDate(final String applicationDate) {
this.applicationDate = applicationDate ; this.applicationDate = applicationDate ;
return this ; return this ;
} }
public ShareAccountHelper withExternalId(final String externalId) { public ShareAccountHelper withExternalId(final String externalId) {
this.externalId = externalId ; this.externalId = externalId ;
return this ; return this ;
} }
public ShareAccountHelper withCharges(final List<Map<String,Object>> charges) { public ShareAccountHelper withCharges(final List<Map<String,Object>> charges) {
this.charges = new ArrayList<>() ; this.charges = new ArrayList<>() ;
this.charges.addAll(charges) ; this.charges.addAll(charges) ;
@@ -156,7 +156,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> shareAccountData = ShareAccountTransactionHelper Map<String, Object> shareAccountData = ShareAccountTransactionHelper
.retrieveShareAccount(shareAccountId, requestSpec, responseSpec); .retrieveShareAccount(shareAccountId, requestSpec, responseSpec);
Assert.assertNotNull(shareAccountData); Assert.assertNotNull(shareAccountData);
// Approve share Account // Approve share Account
Map<String, Object> approveMap = new HashMap<>(); Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note"); approveMap.put("note", "Share Account Approval Note");
@@ -205,7 +205,7 @@ public class ShareAccountIntegrationTests {
Assert.assertEquals("25", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("25", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void rejectShareAccount() { public void rejectShareAccount() {
@@ -231,7 +231,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> shareAccountData = ShareAccountTransactionHelper Map<String, Object> shareAccountData = ShareAccountTransactionHelper
.retrieveShareAccount(shareAccountId, requestSpec, responseSpec); .retrieveShareAccount(shareAccountId, requestSpec, responseSpec);
Assert.assertNotNull(shareAccountData); Assert.assertNotNull(shareAccountData);
// Reject share Account // Reject share Account
Map<String, Object> rejectMap = new HashMap<>(); Map<String, Object> rejectMap = new HashMap<>();
rejectMap.put("note", "Share Account Rejection Note"); rejectMap.put("note", "Share Account Rejection Note");
@@ -249,7 +249,7 @@ public class ShareAccountIntegrationTests {
Date rejectedDate = cal.getTime(); Date rejectedDate = cal.getTime();
Date currentTenantDate = DateUtils.getDateOfTenant() ; Date currentTenantDate = DateUtils.getDateOfTenant() ;
Assert.assertEquals(simple.format(currentTenantDate), simple.format(rejectedDate)); Assert.assertEquals(simple.format(currentTenantDate), simple.format(rejectedDate));
List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares"); List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares");
Assert.assertNotNull(transactions); Assert.assertNotNull(transactions);
Assert.assertEquals(2, transactions.size()); Assert.assertEquals(2, transactions.size());
@@ -280,7 +280,7 @@ public class ShareAccountIntegrationTests {
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testShareAccountUndoApproval() { public void testShareAccountUndoApproval() {
@@ -307,7 +307,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> shareAccountData = ShareAccountTransactionHelper Map<String, Object> shareAccountData = ShareAccountTransactionHelper
.retrieveShareAccount(shareAccountId, requestSpec, responseSpec); .retrieveShareAccount(shareAccountId, requestSpec, responseSpec);
Assert.assertNotNull(shareAccountData); Assert.assertNotNull(shareAccountData);
// Approve share Account // Approve share Account
Map<String, Object> approveMap = new HashMap<>(); Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note"); approveMap.put("note", "Share Account Approval Note");
@@ -326,18 +326,18 @@ public class ShareAccountIntegrationTests {
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2)); cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date approvedDate = cal.getTime(); Date approvedDate = cal.getTime();
Assert.assertEquals("01 Jan 2016", simple.format(approvedDate)); Assert.assertEquals("01 Jan 2016", simple.format(approvedDate));
// Undo Approval share Account // Undo Approval share Account
Map<String, Object> undoApprovalMap = new HashMap<>(); Map<String, Object> undoApprovalMap = new HashMap<>();
String undoApprovalJson = new Gson().toJson(undoApprovalMap); String undoApprovalJson = new Gson().toJson(undoApprovalMap);
ShareAccountTransactionHelper.postCommand("undoapproval", shareAccountId, undoApprovalJson, requestSpec, responseSpec); ShareAccountTransactionHelper.postCommand("undoapproval", shareAccountId, undoApprovalJson, requestSpec, responseSpec);
shareAccountData = ShareAccountTransactionHelper shareAccountData = ShareAccountTransactionHelper
.retrieveShareAccount(shareAccountId, requestSpec, responseSpec); .retrieveShareAccount(shareAccountId, requestSpec, responseSpec);
statusMap = (Map<String, Object>) shareAccountData.get("status"); statusMap = (Map<String, Object>) shareAccountData.get("status");
Assert.assertEquals("shareAccountStatusType.submitted.and.pending.approval", String.valueOf(statusMap.get("code"))); Assert.assertEquals("shareAccountStatusType.submitted.and.pending.approval", String.valueOf(statusMap.get("code")));
List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares"); List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares");
Assert.assertNotNull(transactions); Assert.assertNotNull(transactions);
Assert.assertEquals(2, transactions.size()); Assert.assertEquals(2, transactions.size());
@@ -368,7 +368,7 @@ public class ShareAccountIntegrationTests {
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("25", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("25", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testCreateShareAccountWithCharges() { public void testCreateShareAccountWithCharges() {
@@ -453,7 +453,7 @@ public class ShareAccountIntegrationTests {
Assert.fail("Other Charge defintion found"); Assert.fail("Other Charge defintion found");
} }
} }
// Approve share Account // Approve share Account
Map<String, Object> approveMap = new HashMap<>(); Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note"); approveMap.put("note", "Share Account Approval Note");
@@ -495,7 +495,7 @@ public class ShareAccountIntegrationTests {
Assert.fail("Other Charge defintion found"); Assert.fail("Other Charge defintion found");
} }
} }
Map<String, Object> activateMap = new HashMap<>(); Map<String, Object> activateMap = new HashMap<>();
activateMap.put("dateFormat", "dd MMMM yyyy"); activateMap.put("dateFormat", "dd MMMM yyyy");
activateMap.put("activatedDate", "01 Jan 2016"); activateMap.put("activatedDate", "01 Jan 2016");
@@ -560,7 +560,7 @@ public class ShareAccountIntegrationTests {
Assert.fail("Other Charge defintion found"); Assert.fail("Other Charge defintion found");
} }
} }
Map<String, Object> summaryMap = (Map<String, Object>) shareAccountData.get("summary"); Map<String, Object> summaryMap = (Map<String, Object>) shareAccountData.get("summary");
Assert.assertEquals("30", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("30", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
@@ -634,7 +634,7 @@ public class ShareAccountIntegrationTests {
Assert.fail("Other Charge defintion found"); Assert.fail("Other Charge defintion found");
} }
} }
summaryMap = (Map<String, Object>) shareAccountData.get("summary"); summaryMap = (Map<String, Object>) shareAccountData.get("summary");
Assert.assertEquals("30", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("30", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("15", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("15", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
@@ -708,7 +708,7 @@ public class ShareAccountIntegrationTests {
Assert.fail("Other Charge defintion found"); Assert.fail("Other Charge defintion found");
} }
} }
summaryMap = (Map<String, Object>) shareAccountData.get("summary"); summaryMap = (Map<String, Object>) shareAccountData.get("summary");
Assert.assertEquals("45", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("45", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
@@ -770,7 +770,7 @@ public class ShareAccountIntegrationTests {
Assert.fail("Other Charge defintion found"); Assert.fail("Other Charge defintion found");
} }
} }
summaryMap = (Map<String, Object>) shareAccountData.get("summary"); summaryMap = (Map<String, Object>) shareAccountData.get("summary");
Assert.assertEquals("45", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("45", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("20", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("20", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
@@ -832,7 +832,7 @@ public class ShareAccountIntegrationTests {
Assert.fail("Other Charge defintion found"); Assert.fail("Other Charge defintion found");
} }
} }
summaryMap = (Map<String, Object>) shareAccountData.get("summary"); summaryMap = (Map<String, Object>) shareAccountData.get("summary");
Assert.assertEquals("45", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("45", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
@@ -912,7 +912,7 @@ public class ShareAccountIntegrationTests {
summaryMap = (Map<String, Object>) shareAccountData.get("summary"); summaryMap = (Map<String, Object>) shareAccountData.get("summary");
Assert.assertEquals("30", String.valueOf(summaryMap.get("totalApprovedShares"))); Assert.assertEquals("30", String.valueOf(summaryMap.get("totalApprovedShares")));
Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares"))); Assert.assertEquals("0", String.valueOf(summaryMap.get("totalPendingForApprovalShares")));
//Close Share Account //Close Share Account
Map<String, Object> closeAccountMap = new HashMap<>(); Map<String, Object> closeAccountMap = new HashMap<>();
closeAccountMap.put("note", "Share Account Close Note"); closeAccountMap.put("note", "Share Account Close Note");
@@ -31,25 +31,25 @@ public class ShareDividendsTransactionHelper {
private static final String SHARE_PRODUCT_URL = "/fineract-provider/api/v1/shareproduct"; private static final String SHARE_PRODUCT_URL = "/fineract-provider/api/v1/shareproduct";
private static final String DIVIDEND = "dividend" ; private static final String DIVIDEND = "dividend" ;
public static Integer createShareProductDividends(final Integer productId, final String dividendJson, final RequestSpecification requestSpec, public static Integer createShareProductDividends(final Integer productId, final String dividendJson, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
String url = SHARE_PRODUCT_URL + "/" + productId + "/" + DIVIDEND + "?" + Utils.TENANT_IDENTIFIER ; String url = SHARE_PRODUCT_URL + "/" + productId + "/" + DIVIDEND + "?" + Utils.TENANT_IDENTIFIER ;
return Utils.performServerPost(requestSpec, responseSpec, url, dividendJson, "subResourceId"); return Utils.performServerPost(requestSpec, responseSpec, url, dividendJson, "subResourceId");
} }
public static Integer postCommand(final String command, final Integer productId, final Integer dividendId, String jsonBody, final RequestSpecification requestSpec, public static Integer postCommand(final String command, final Integer productId, final Integer dividendId, String jsonBody, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
String url = SHARE_PRODUCT_URL + "/" + productId + "/"+DIVIDEND + "/"+ dividendId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; String url = SHARE_PRODUCT_URL + "/" + productId + "/"+DIVIDEND + "/"+ dividendId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPut(requestSpec, responseSpec, url, jsonBody, "resourceId"); return Utils.performServerPut(requestSpec, responseSpec, url, jsonBody, "resourceId");
} }
public static Map<String, Object> retrieveDividendDetails(final Integer productId, final Integer dividendId, final RequestSpecification requestSpec, public static Map<String, Object> retrieveDividendDetails(final Integer productId, final Integer dividendId, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
String url = SHARE_PRODUCT_URL + "/" + productId + "/"+DIVIDEND + "/"+ dividendId +"?" + Utils.TENANT_IDENTIFIER; String url = SHARE_PRODUCT_URL + "/" + productId + "/"+DIVIDEND + "/"+ dividendId +"?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, url, ""); return Utils.performServerGet(requestSpec, responseSpec, url, "");
} }
public static Map<String, Object> retrieveAllDividends(final Integer productId, final RequestSpecification requestSpec, public static Map<String, Object> retrieveAllDividends(final Integer productId, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
String url = SHARE_PRODUCT_URL + "/" + productId + "/"+DIVIDEND +"?" + Utils.TENANT_IDENTIFIER; String url = SHARE_PRODUCT_URL + "/" + productId + "/"+DIVIDEND +"?" + Utils.TENANT_IDENTIFIER;
@@ -34,14 +34,14 @@ import java.util.Map;
public class ShareProductHelper { public class ShareProductHelper {
private static final String NONE = "1"; private static final String NONE = "1";
private static final String CASH_BASED = "2"; private static final String CASH_BASED = "2";
private static final String LOCALE = "en_GB"; private static final String LOCALE = "en_GB";
private static final String DIGITS_AFTER_DECIMAL = "4"; private static final String DIGITS_AFTER_DECIMAL = "4";
private static final String IN_MULTIPLES_OF = "0"; private static final String IN_MULTIPLES_OF = "0";
private static final String USD = "USD"; private static final String USD = "USD";
private String productName = Utils.randomNameGenerator("SHARE_PRODUCT_", 6); private String productName = Utils.randomNameGenerator("SHARE_PRODUCT_", 6);
private String shortName = Utils.randomNameGenerator("", 4); private String shortName = Utils.randomNameGenerator("", 4);
private String description = Utils.randomNameGenerator("", 20); private String description = Utils.randomNameGenerator("", 20);
@@ -56,14 +56,14 @@ public class ShareProductHelper {
private String lockinPeriodFrequency = "1"; private String lockinPeriodFrequency = "1";
private String lockinPeriodFrequencyType = "0"; private String lockinPeriodFrequencyType = "0";
private String accountingRule = NONE; private String accountingRule = NONE;
String minimumActivePeriodForDividends = "1"; String minimumActivePeriodForDividends = "1";
String minimumactiveperiodFrequencyType = "0"; String minimumactiveperiodFrequencyType = "0";
private List<Map<String, String>> charges = null ; private List<Map<String, String>> charges = null ;
private List<Map<String, String>> marketPrices = null ; private List<Map<String, String>> marketPrices = null ;
public String build() { public String build() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("name", this.productName); map.put("name", this.productName);
@@ -85,25 +85,25 @@ public class ShareProductHelper {
map.put("minimumactiveperiodFrequencyType", this.minimumactiveperiodFrequencyType) ; map.put("minimumactiveperiodFrequencyType", this.minimumactiveperiodFrequencyType) ;
map.put("lockinPeriodFrequency", this.lockinPeriodFrequency) ; map.put("lockinPeriodFrequency", this.lockinPeriodFrequency) ;
map.put("lockinPeriodFrequencyType", this.lockinPeriodFrequencyType) ; map.put("lockinPeriodFrequencyType", this.lockinPeriodFrequencyType) ;
if(charges != null) { if(charges != null) {
map.put("chargesSelected", charges) ; map.put("chargesSelected", charges) ;
} }
if(marketPrices != null) { if(marketPrices != null) {
map.put("marketPricePeriods", marketPrices) ; map.put("marketPricePeriods", marketPrices) ;
} }
String shareProductCreateJson = new Gson().toJson(map); String shareProductCreateJson = new Gson().toJson(map);
System.out.println(shareProductCreateJson); System.out.println(shareProductCreateJson);
return shareProductCreateJson; return shareProductCreateJson;
} }
public ShareProductHelper withCashBasedAccounting() { public ShareProductHelper withCashBasedAccounting() {
this.accountingRule = CASH_BASED ; this.accountingRule = CASH_BASED ;
return this ; return this ;
} }
public ShareProductHelper withMarketPrice() { public ShareProductHelper withMarketPrice() {
this.marketPrices = new ArrayList<>() ; this.marketPrices = new ArrayList<>() ;
LocalDate currentDate = DateUtils.getLocalDateOfTenant() ; LocalDate currentDate = DateUtils.getLocalDateOfTenant() ;
@@ -118,7 +118,7 @@ public class ShareProductHelper {
} }
return this ; return this ;
} }
public ShareProductHelper withCharges(final ArrayList<Long> charges) { public ShareProductHelper withCharges(final ArrayList<Long> charges) {
if(charges != null && !charges.isEmpty()) { if(charges != null && !charges.isEmpty()) {
this.charges = new ArrayList<>() ; this.charges = new ArrayList<>() ;
@@ -137,62 +137,62 @@ public class ShareProductHelper {
Assert.assertEquals(this.productName, productName); Assert.assertEquals(this.productName, productName);
String shortName = (String)shareProductData.get("shortName") ; String shortName = (String)shareProductData.get("shortName") ;
Assert.assertEquals(this.shortName, shortName); Assert.assertEquals(this.shortName, shortName);
String description = (String)shareProductData.get("description") ; String description = (String)shareProductData.get("description") ;
Assert.assertEquals(this.description, description); Assert.assertEquals(this.description, description);
Map<String, String> currency = (Map<String,String>)shareProductData.get("currency") ; Map<String, String> currency = (Map<String,String>)shareProductData.get("currency") ;
String currencyCode = currency.get("code") ; String currencyCode = currency.get("code") ;
Assert.assertEquals(this.currencyCode, currencyCode); Assert.assertEquals(this.currencyCode, currencyCode);
String digitsAfterDecimal = String.valueOf(currency.get("decimalPlaces")) ; String digitsAfterDecimal = String.valueOf(currency.get("decimalPlaces")) ;
Assert.assertEquals(DIGITS_AFTER_DECIMAL, digitsAfterDecimal); Assert.assertEquals(DIGITS_AFTER_DECIMAL, digitsAfterDecimal);
String inMultiplesOf = String.valueOf(currency.get("inMultiplesOf")) ; String inMultiplesOf = String.valueOf(currency.get("inMultiplesOf")) ;
Assert.assertEquals(IN_MULTIPLES_OF, inMultiplesOf); Assert.assertEquals(IN_MULTIPLES_OF, inMultiplesOf);
String totalShares = String.valueOf(shareProductData.get("totalShares")) ; String totalShares = String.valueOf(shareProductData.get("totalShares")) ;
Assert.assertEquals(this.totalShares, totalShares); Assert.assertEquals(this.totalShares, totalShares);
String sharesIssued = String.valueOf(shareProductData.get("totalSharesIssued")) ; String sharesIssued = String.valueOf(shareProductData.get("totalSharesIssued")) ;
Assert.assertEquals(this.sharesIssued, sharesIssued); Assert.assertEquals(this.sharesIssued, sharesIssued);
String unitPrice = String.valueOf(shareProductData.get("unitPrice")) ; String unitPrice = String.valueOf(shareProductData.get("unitPrice")) ;
Assert.assertEquals(this.unitPrice, unitPrice); Assert.assertEquals(this.unitPrice, unitPrice);
String minimumShares = String.valueOf(shareProductData.get("minimumShares")) ; String minimumShares = String.valueOf(shareProductData.get("minimumShares")) ;
Assert.assertEquals(this.minimumShares, minimumShares); Assert.assertEquals(this.minimumShares, minimumShares);
String nominalShares = String.valueOf(shareProductData.get("nominalShares")) ; String nominalShares = String.valueOf(shareProductData.get("nominalShares")) ;
Assert.assertEquals(this.nominalShares, nominalShares); Assert.assertEquals(this.nominalShares, nominalShares);
String maximumShares = String.valueOf(shareProductData.get("maximumShares")) ; String maximumShares = String.valueOf(shareProductData.get("maximumShares")) ;
Assert.assertEquals(this.maximumShares, maximumShares); Assert.assertEquals(this.maximumShares, maximumShares);
String allowDividendCalculationForInactiveClients = String.valueOf(shareProductData.get("allowDividendCalculationForInactiveClients")) ; String allowDividendCalculationForInactiveClients = String.valueOf(shareProductData.get("allowDividendCalculationForInactiveClients")) ;
Assert.assertEquals(this.allowDividendCalculationForInactiveClients, allowDividendCalculationForInactiveClients); Assert.assertEquals(this.allowDividendCalculationForInactiveClients, allowDividendCalculationForInactiveClients);
Map<String, Object> accountingRuleMap = (Map<String, Object>) shareProductData.get("accountingRule") ; Map<String, Object> accountingRuleMap = (Map<String, Object>) shareProductData.get("accountingRule") ;
String accountingRule = String.valueOf(accountingRuleMap.get("id")) ; String accountingRule = String.valueOf(accountingRuleMap.get("id")) ;
Assert.assertEquals(this.accountingRule, accountingRule); Assert.assertEquals(this.accountingRule, accountingRule);
String minimumActivePeriodForDividends = String.valueOf(shareProductData.get("minimumActivePeriod")) ; String minimumActivePeriodForDividends = String.valueOf(shareProductData.get("minimumActivePeriod")) ;
Assert.assertEquals(this.minimumActivePeriodForDividends, minimumActivePeriodForDividends); Assert.assertEquals(this.minimumActivePeriodForDividends, minimumActivePeriodForDividends);
Map<String, Object> minimumActivePeriodType = (Map<String, Object>) shareProductData.get("minimumActivePeriodForDividendsTypeEnum") ; Map<String, Object> minimumActivePeriodType = (Map<String, Object>) shareProductData.get("minimumActivePeriodForDividendsTypeEnum") ;
String minimumactiveperiodFrequencyType = String.valueOf(minimumActivePeriodType.get("id")) ; String minimumactiveperiodFrequencyType = String.valueOf(minimumActivePeriodType.get("id")) ;
Assert.assertEquals(this.minimumactiveperiodFrequencyType, minimumactiveperiodFrequencyType); Assert.assertEquals(this.minimumactiveperiodFrequencyType, minimumactiveperiodFrequencyType);
String lockinPeriodFrequency = String.valueOf(shareProductData.get("lockinPeriod")) ; String lockinPeriodFrequency = String.valueOf(shareProductData.get("lockinPeriod")) ;
Assert.assertEquals(this.lockinPeriodFrequency, lockinPeriodFrequency); Assert.assertEquals(this.lockinPeriodFrequency, lockinPeriodFrequency);
Map<String, Object> lockinPeriodType = (Map<String, Object>) shareProductData.get("lockPeriodTypeEnum") ; Map<String, Object> lockinPeriodType = (Map<String, Object>) shareProductData.get("lockPeriodTypeEnum") ;
String lockinPeriodFrequencyType = String.valueOf(lockinPeriodType.get("id")) ; String lockinPeriodFrequencyType = String.valueOf(lockinPeriodType.get("id")) ;
Assert.assertEquals(this.lockinPeriodFrequencyType, lockinPeriodFrequencyType); Assert.assertEquals(this.lockinPeriodFrequencyType, lockinPeriodFrequencyType);
//ArrayList<Map<String, String>> charges = (ArrayList<Map<String, String>>)shareProductData.get("chargesSelected") ; //ArrayList<Map<String, String>> charges = (ArrayList<Map<String, String>>)shareProductData.get("chargesSelected") ;
// ArrayList<Map<String, String>> marketPrices = (ArrayList<Map<String, String>>)shareProductData.get("marketPricePeriods") ; // ArrayList<Map<String, String>> marketPrices = (ArrayList<Map<String, String>>)shareProductData.get("marketPricePeriods") ;
} }
} }
@@ -30,18 +30,18 @@ public class ShareProductTransactionHelper {
private static final String SHARE_PRODUCT_URL = "/fineract-provider/api/v1/products/share"; private static final String SHARE_PRODUCT_URL = "/fineract-provider/api/v1/products/share";
private static final String CREATE_SHARE_PRODUCT_URL = SHARE_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_SHARE_PRODUCT_URL = SHARE_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER;
public static Integer createShareProduct(final String savingsProductJSON, final RequestSpecification requestSpec, public static Integer createShareProduct(final String savingsProductJSON, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_SHARE_PRODUCT_URL, savingsProductJSON, "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_SHARE_PRODUCT_URL, savingsProductJSON, "resourceId");
} }
public static Map<String, Object> retrieveShareProduct(final Integer shareProductId, final RequestSpecification requestSpec, public static Map<String, Object> retrieveShareProduct(final Integer shareProductId, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
String url = SHARE_PRODUCT_URL+"/"+shareProductId+"?"+Utils.TENANT_IDENTIFIER ; String url = SHARE_PRODUCT_URL+"/"+shareProductId+"?"+Utils.TENANT_IDENTIFIER ;
return Utils.performServerGet(requestSpec, responseSpec, url, ""); return Utils.performServerGet(requestSpec, responseSpec, url, "");
} }
public static Integer updateShareProduct(final Integer shareProductId, final String provsioningCriteriaJson, public static Integer updateShareProduct(final Integer shareProductId, final String provsioningCriteriaJson,
final RequestSpecification requestSpec, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
@@ -84,7 +84,7 @@ public class AccountNumberPreferencesHelper {
requestJSON, jsonAttributeToGetBack); requestJSON, jsonAttributeToGetBack);
} }
public Object createGroupsAccountNumberPreference( public Object createGroupsAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out System.out
@@ -99,7 +99,7 @@ public class AccountNumberPreferencesHelper {
requestJSON, jsonAttributeToGetBack); requestJSON, jsonAttributeToGetBack);
} }
public Object createCenterAccountNumberPreference( public Object createCenterAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out System.out
@@ -200,13 +200,13 @@ public class AccountNumberPreferencesHelper {
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
Utils.performServerGet(requestSpec, responseSpec, savingsURL, "id"); Utils.performServerGet(requestSpec, responseSpec, savingsURL, "id");
final String groupsURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/" final String groupsURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
+ groupsAccountNumberPreferenceId + "?" + groupsAccountNumberPreferenceId + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
Utils.performServerGet(requestSpec, responseSpec, groupsURL, "id"); Utils.performServerGet(requestSpec, responseSpec, groupsURL, "id");
final String centerURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/" final String centerURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
+ centerAccountNumberPreferenceId + "?" + centerAccountNumberPreferenceId + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
@@ -57,7 +57,7 @@ public class AccountNumberPreferencesTestBuilder {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public String groupsBuild() { public String groupsBuild() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("accountType", groupsAccountType); map.put("accountType", groupsAccountType);
@@ -73,7 +73,7 @@ public class AccountNumberPreferencesTestBuilder {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public String invalidDataBuild(String accountType, String prefixType) { public String invalidDataBuild(String accountType, String prefixType) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("accountType", accountType); map.put("accountType", accountType);
@@ -107,7 +107,7 @@ public class CodeHelper {
codeValueId = (Integer) CodeHelper.createCodeValue(requestSpec, codeValueId = (Integer) CodeHelper.createCodeValue(requestSpec,
responseSpec, codeId, codeValue, codeValuePosition, responseSpec, codeId, codeValue, codeValuePosition,
"subResourceId"); "subResourceId");
} else { } else {
return codeValuesList.get(0); return codeValuesList.get(0);
} }
@@ -115,7 +115,7 @@ public class CodeHelper {
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/" CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
+ codeValueId.toString() + "?" + codeValueId.toString() + "?"
+ Utils.TENANT_IDENTIFIER, ""); + Utils.TENANT_IDENTIFIER, "");
} }
public static ArrayList<HashMap<String, Object>> getAllCodes( public static ArrayList<HashMap<String, Object>> getAllCodes(
@@ -201,7 +201,7 @@ public class CodeHelper {
return Utils.performServerGet(requestSpec, responseSpec, return Utils.performServerGet(requestSpec, responseSpec,
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?" CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetback); + Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
} }
public static Object getCodeValueById( public static Object getCodeValueById(
@@ -504,7 +504,7 @@ public class GuarantorTest {
Float externalBalance = new Float(10000); Float externalBalance = new Float(10000);
Float selfguarantee = new Float(6000); Float selfguarantee = new Float(6000);
Float externalguarantee = new Float(7000); Float externalguarantee = new Float(7000);
final Integer selfSavigsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID, final Integer selfSavigsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID,
String.valueOf(selfBalance)); String.valueOf(selfBalance));
final Integer externalSavigsId_1 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external, final Integer externalSavigsId_1 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external,
@@ -562,7 +562,7 @@ public class GuarantorTest {
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
@Test @Test
public void testGuarantor_WRITE_OFF_LOAN() { public void testGuarantor_WRITE_OFF_LOAN() {
@@ -79,7 +79,7 @@ public class GuarantorTestBuilder {
this.guarantorTypeId = GUARANTOR_TYPE_CUSTOMER; this.guarantorTypeId = GUARANTOR_TYPE_CUSTOMER;
return this; return this;
} }
public GuarantorTestBuilder externalCustomer() { public GuarantorTestBuilder externalCustomer() {
this.guarantorTypeId = GUARANTOR_TYPE_EXTERNAL; this.guarantorTypeId = GUARANTOR_TYPE_EXTERNAL;
return this; return this;
@@ -51,7 +51,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
.withAccounting(accountingRule, accounts).build(null); .withAccounting(accountingRule, accounts).build(null);
return loanProductJSON ; return loanProductJSON ;
} }
public static String createLoanProductWithVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { public static String createLoanProductWithVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
@@ -69,7 +69,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
.withAccounting(accountingRule, accounts).build(null); .withAccounting(accountingRule, accounts).build(null);
return loanProductJSON ; return loanProductJSON ;
} }
public static String createLoanProductWithVaribleConfigwithEqualPrincipal(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { public static String createLoanProductWithVaribleConfigwithEqualPrincipal(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
@@ -87,7 +87,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
.withAccounting(accountingRule, accounts).build(null); .withAccounting(accountingRule, accounts).build(null);
return loanProductJSON ; return loanProductJSON ;
} }
public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges, public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges,
final String savingsId, String principal) { final String savingsId, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
@@ -107,7 +107,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
.withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId); .withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
return loanApplicationJSON ; return loanApplicationJSON ;
} }
public static String applyForLoanApplicationWithEqualPrincipal(final Integer clientID, final Integer loanProductID, List<HashMap> charges, public static String applyForLoanApplicationWithEqualPrincipal(final Integer clientID, final Integer loanProductID, List<HashMap> charges,
final String savingsId, String principal) { final String savingsId, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
@@ -127,7 +127,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
.withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId); .withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
return loanApplicationJSON ; return loanApplicationJSON ;
} }
public static String createDeleteVariations(ArrayList<Map> deletedInstallments) { public static String createDeleteVariations(ArrayList<Map> deletedInstallments) {
Map<String, Object> toReturn = new HashMap<>(); Map<String, Object> toReturn = new HashMap<>();
toReturn.put("locale", "en"); toReturn.put("locale", "en");
@@ -180,7 +180,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
String json = new Gson().toJson(toReturn); String json = new Gson().toJson(toReturn);
return json; return json;
} }
private static ArrayList createNewInstallments(String date) { private static ArrayList createNewInstallments(String date) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
Map tosend = new HashMap(); Map tosend = new HashMap();
@@ -189,7 +189,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
private static ArrayList createModifyMap(Map firstSchedule) { private static ArrayList createModifyMap(Map firstSchedule) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
ArrayList dueDate = (ArrayList) firstSchedule.get("dueDate"); ArrayList dueDate = (ArrayList) firstSchedule.get("dueDate");
@@ -199,7 +199,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
public static String createAllVariations() { public static String createAllVariations() {
Map<String, Object> toReturn = new HashMap<>(); Map<String, Object> toReturn = new HashMap<>();
toReturn.put("locale", "en"); toReturn.put("locale", "en");
@@ -212,7 +212,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
String json = new Gson().toJson(toReturn); String json = new Gson().toJson(toReturn);
return json; return json;
} }
public static String createAllVariationsWithEqualPrincipal() { public static String createAllVariationsWithEqualPrincipal() {
Map<String, Object> toReturn = new HashMap<>(); Map<String, Object> toReturn = new HashMap<>();
toReturn.put("locale", "en"); toReturn.put("locale", "en");
@@ -225,7 +225,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
String json = new Gson().toJson(toReturn); String json = new Gson().toJson(toReturn);
return json; return json;
} }
private static ArrayList createNewInstallmentsWithPrincipal(String date) { private static ArrayList createNewInstallmentsWithPrincipal(String date) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
Map tosend = new HashMap(); Map tosend = new HashMap();
@@ -234,7 +234,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
private static ArrayList createModifyMapWithPrinciapl(String date) { private static ArrayList createModifyMapWithPrinciapl(String date) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
Map tosend = new HashMap(); Map tosend = new HashMap();
@@ -250,7 +250,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
private static ArrayList createModifyMap(String date) { private static ArrayList createModifyMap(String date) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
Map tosend = new HashMap(); Map tosend = new HashMap();
@@ -259,7 +259,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
public static String createModifiyDateVariations(String[] date, String[] newdate, String[] principal) { public static String createModifiyDateVariations(String[] date, String[] newdate, String[] principal) {
Map<String, Object> toReturn = new HashMap<>(); Map<String, Object> toReturn = new HashMap<>();
toReturn.put("locale", "en"); toReturn.put("locale", "en");
@@ -270,7 +270,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
String json = new Gson().toJson(toReturn); String json = new Gson().toJson(toReturn);
return json; return json;
} }
private static ArrayList createDateModifyMap(String[] date, String[] newdate, String[] installments) { private static ArrayList createDateModifyMap(String[] date, String[] newdate, String[] installments) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
for(int i = 0 ; i < date.length; i++) { for(int i = 0 ; i < date.length; i++) {
@@ -280,7 +280,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
if(i < installments.length) { if(i < installments.length) {
tosend.put("installmentAmount", installments[i]) ; tosend.put("installmentAmount", installments[i]) ;
} }
toReturn.add(tosend); toReturn.add(tosend);
} }
return toReturn; return toReturn;
} }
@@ -44,7 +44,7 @@ public class VariableInstallmentsFlatHelper {
.withRepaymentAfterEvery("1") // .withRepaymentAfterEvery("1") //
.withRepaymentTypeAsMonth() // .withRepaymentTypeAsMonth() //
.withinterestRatePerPeriod("1") // .withinterestRatePerPeriod("1") //
.withAmortizationTypeAsEqualPrincipalPayment() .withAmortizationTypeAsEqualPrincipalPayment()
.withInterestTypeAsFlat() // .withInterestTypeAsFlat() //
.withTranches(multiDisburseLoan) // .withTranches(multiDisburseLoan) //
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true)// .withInterestCalculationPeriodTypeAsRepaymentPeriod(true)//
@@ -52,9 +52,9 @@ public class VariableInstallmentsFlatHelper {
.withAccounting(accountingRule, accounts).build(null); .withAccounting(accountingRule, accounts).build(null);
return loanProductJSON ; return loanProductJSON ;
} }
public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges, public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges,
final String savingsId, String principal) { final String savingsId, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
@@ -74,7 +74,7 @@ public class VariableInstallmentsFlatHelper {
.withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId); .withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
return loanApplicationJSON ; return loanApplicationJSON ;
} }
public static String createDeleteVariations(ArrayList<Map> deletedInstallments) { public static String createDeleteVariations(ArrayList<Map> deletedInstallments) {
Map<String, Object> toReturn = new HashMap<>(); Map<String, Object> toReturn = new HashMap<>();
toReturn.put("locale", "en"); toReturn.put("locale", "en");
@@ -127,7 +127,7 @@ public class VariableInstallmentsFlatHelper {
String json = new Gson().toJson(toReturn); String json = new Gson().toJson(toReturn);
return json; return json;
} }
private static ArrayList createNewInstallments(String date) { private static ArrayList createNewInstallments(String date) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
Map tosend = new HashMap(); Map tosend = new HashMap();
@@ -136,7 +136,7 @@ public class VariableInstallmentsFlatHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
public static String createModifiyDateVariations(String[] date, String[] newdate, String[] principal) { public static String createModifiyDateVariations(String[] date, String[] newdate, String[] principal) {
Map<String, Object> toReturn = new HashMap<>(); Map<String, Object> toReturn = new HashMap<>();
toReturn.put("locale", "en"); toReturn.put("locale", "en");
@@ -147,7 +147,7 @@ public class VariableInstallmentsFlatHelper {
String json = new Gson().toJson(toReturn); String json = new Gson().toJson(toReturn);
return json; return json;
} }
private static ArrayList createDateModifyMap(String[] date, String[] newdate, String[] principal) { private static ArrayList createDateModifyMap(String[] date, String[] newdate, String[] principal) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
for(int i = 0 ; i < date.length; i++) { for(int i = 0 ; i < date.length; i++) {
@@ -157,12 +157,12 @@ public class VariableInstallmentsFlatHelper {
if(i < principal.length) { if(i < principal.length) {
tosend.put("principal", principal[i]) ; tosend.put("principal", principal[i]) ;
} }
toReturn.add(tosend); toReturn.add(tosend);
} }
return toReturn; return toReturn;
} }
private static ArrayList createModifyMap(Map firstSchedule) { private static ArrayList createModifyMap(Map firstSchedule) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
ArrayList dueDate = (ArrayList) firstSchedule.get("dueDate"); ArrayList dueDate = (ArrayList) firstSchedule.get("dueDate");
@@ -172,7 +172,7 @@ public class VariableInstallmentsFlatHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
public static String createAllVariations() { public static String createAllVariations() {
Map<String, Object> toReturn = new HashMap<>(); Map<String, Object> toReturn = new HashMap<>();
toReturn.put("locale", "en"); toReturn.put("locale", "en");
@@ -185,7 +185,7 @@ public class VariableInstallmentsFlatHelper {
String json = new Gson().toJson(toReturn); String json = new Gson().toJson(toReturn);
return json; return json;
} }
private static ArrayList createDeletedMap(String date) { private static ArrayList createDeletedMap(String date) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
Map tosend = new HashMap(); Map tosend = new HashMap();
@@ -193,7 +193,7 @@ public class VariableInstallmentsFlatHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
private static ArrayList createModifyMap(String date) { private static ArrayList createModifyMap(String date) {
ArrayList toReturn = new ArrayList<>(); ArrayList toReturn = new ArrayList<>();
Map tosend = new HashMap(); Map tosend = new HashMap();
@@ -202,7 +202,7 @@ public class VariableInstallmentsFlatHelper {
toReturn.add(tosend); toReturn.add(tosend);
return toReturn; return toReturn;
} }
public static String formatDate(ArrayList list) { public static String formatDate(ArrayList list) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, (int) list.get(0)); cal.set(Calendar.YEAR, (int) list.get(0));
@@ -39,12 +39,12 @@ import com.jayway.restassured.specification.ResponseSpecification;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class VariableInstallmentsIntegrationTest { public class VariableInstallmentsIntegrationTest {
private static final String NONE = "1"; private static final String NONE = "1";
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@Before @Before
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -53,7 +53,7 @@ public class VariableInstallmentsIntegrationTest {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
} }
@Test @Test
public void testVariableLoanProductCreation() { public void testVariableLoanProductCreation() {
final String json = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE); final String json = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE);
@@ -64,8 +64,8 @@ public class VariableInstallmentsIntegrationTest {
Assert.assertEquals(new Integer(5), loanProduct.get("minimumGap")) ; Assert.assertEquals(new Integer(5), loanProduct.get("minimumGap")) ;
Assert.assertEquals(new Integer(90), loanProduct.get("maximumGap")) ; Assert.assertEquals(new Integer(90), loanProduct.get("maximumGap")) ;
} }
@Test @Test
public void testLoanProductCreation() { public void testLoanProductCreation() {
final String josn = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithoutVaribleConfig(false, NONE); final String josn = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithoutVaribleConfig(false, NONE);
@@ -74,7 +74,7 @@ public class VariableInstallmentsIntegrationTest {
Map loanProduct = (Map)loanTransactionHelper.getLoanProductDetail(requestSpec, responseSpec, loanProductID, "") ; Map loanProduct = (Map)loanTransactionHelper.getLoanProductDetail(requestSpec, responseSpec, loanProductID, "") ;
Assert.assertTrue(!(Boolean)loanProduct.get("allowVariableInstallments")) ; Assert.assertTrue(!(Boolean)loanProduct.get("allowVariableInstallments")) ;
} }
@Test @Test
public void testDeleteInstallmentsWithDecliningBalanceEqualInstallments() { public void testDeleteInstallmentsWithDecliningBalanceEqualInstallments() {
VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ; VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ;
@@ -95,7 +95,7 @@ public class VariableInstallmentsIntegrationTest {
String toDeletedata = VariableInstallmentsDecliningBalanceHelper.createDeleteVariations(toDelete) ; String toDeletedata = VariableInstallmentsDecliningBalanceHelper.createDeleteVariations(toDelete) ;
HashMap modifiedReschdule = transactionHelper.validateVariations(toDeletedata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(toDeletedata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 November 2011", "20 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 November 2011", "20 December 2011", "20 January 2012"},
new String[] {"34675.47", "34675.47", "36756.26"}) ; new String[] {"34675.47", "34675.47", "36756.26"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(toDeletedata, loanID) ; transactionHelper.submitVariations(toDeletedata, loanID) ;
@@ -104,7 +104,7 @@ public class VariableInstallmentsIntegrationTest {
periods = (ArrayList)repaymentSchedule.get("periods") ; periods = (ArrayList)repaymentSchedule.get("periods") ;
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
private void assertAfterSubmit(ArrayList<Map> serverData, ArrayList<Map> expectedData) { private void assertAfterSubmit(ArrayList<Map> serverData, ArrayList<Map> expectedData) {
Assert.assertTrue(serverData.size() == expectedData.size()) ; Assert.assertTrue(serverData.size() == expectedData.size()) ;
@@ -115,7 +115,7 @@ public class VariableInstallmentsIntegrationTest {
Assert.assertTrue(serverMap.get("totalOutstandingForPeriod").toString().equals(expectedMap.get("installmentAmount"))) ; Assert.assertTrue(serverMap.get("totalOutstandingForPeriod").toString().equals(expectedMap.get("installmentAmount"))) ;
} }
} }
@Test @Test
public void testAddInstallmentsWithDecliningBalanceEqualInstallments() { public void testAddInstallmentsWithDecliningBalanceEqualInstallments() {
//31 October 2011 - 5000 //31 October 2011 - 5000
@@ -136,7 +136,7 @@ public class VariableInstallmentsIntegrationTest {
String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createAddVariations() ; String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createAddVariations() ;
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "31 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "31 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"},
new String[] {"21215.84", "5000.0", "26477.31", "26477.31", "25947.7"}) ; new String[] {"21215.84", "5000.0", "26477.31", "26477.31", "25947.7"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
@@ -146,7 +146,7 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testModifyInstallmentWithDecliningBalanceEqualInstallments() { public void testModifyInstallmentWithDecliningBalanceEqualInstallments() {
//20 October 2011 - 30000 modify //20 October 2011 - 30000 modify
@@ -164,10 +164,10 @@ public class VariableInstallmentsIntegrationTest {
Map list = transactionHelper.retrieveSchedule(loanID) ; Map list = transactionHelper.retrieveSchedule(loanID) ;
Map repaymentSchedule = (Map)list.get("repaymentSchedule") ; Map repaymentSchedule = (Map)list.get("repaymentSchedule") ;
ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ; ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ;
String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createModifiyVariations((Map)periods.get(1)) ; //0th position will have disbursement String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createModifiyVariations((Map)periods.get(1)) ; //0th position will have disbursement
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"},
new String[] {"30000.0", "24966.34", "24966.34", "24966.33"}) ; new String[] {"30000.0", "24966.34", "24966.34", "24966.33"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
@@ -176,13 +176,13 @@ public class VariableInstallmentsIntegrationTest {
periods = (ArrayList)repaymentSchedule.get("periods") ; periods = (ArrayList)repaymentSchedule.get("periods") ;
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testAllVariationsDecliningBalancewithEqualInstallments() { public void testAllVariationsDecliningBalancewithEqualInstallments() {
// Request: Delete 20 December 2011 26,262.38, Modify 20 November 2011 from 26,262.38 to 30000, Add 25 December 2011 5000 // Request: Delete 20 December 2011 26,262.38, Modify 20 November 2011 from 26,262.38 to 30000, Add 25 December 2011 5000
// Result: 20 October 2011 - 26262.38, 20 November 2011 - 30000, 25 December 2011 - 5000, 20 January 2012 - 44077 // Result: 20 October 2011 - 26262.38, 20 November 2011 - 30000, 25 December 2011 - 5000, 20 January 2012 - 44077
VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ; VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ;
final String loanProductJson = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE); final String loanProductJson = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE);
Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductJson); Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductJson);
@@ -196,11 +196,11 @@ public class VariableInstallmentsIntegrationTest {
Map list = transactionHelper.retrieveSchedule(loanID) ; Map list = transactionHelper.retrieveSchedule(loanID) ;
Map repaymentSchedule = (Map)list.get("repaymentSchedule") ; Map repaymentSchedule = (Map)list.get("repaymentSchedule") ;
ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ; ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ;
String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createAllVariations() ; //0th position will have disbursement String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createAllVariations() ; //0th position will have disbursement
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "25 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "25 December 2011", "20 January 2012"},
new String[] {"26262.38", "30000.0", "5000.0", "44077.0"}) ; new String[] {"26262.38", "30000.0", "5000.0", "44077.0"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
@@ -210,11 +210,11 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testAllVariationsDecliningBalancewithEqualPrincipal() { public void testAllVariationsDecliningBalancewithEqualPrincipal() {
// Request: Delete 20 December 2011 26,262.38, Modify 20 November 2011 from 26,262.38 to 30000, Add 25 December 2011 5000 // Request: Delete 20 December 2011 26,262.38, Modify 20 November 2011 from 26,262.38 to 30000, Add 25 December 2011 5000
// Result: 20 October 2011 - 27000.0, 20 November 2011 - 31500.0, 25 December 2011 - 6045.16, 20 January 2012 - 40670.97 // Result: 20 October 2011 - 27000.0, 20 November 2011 - 31500.0, 25 December 2011 - 6045.16, 20 January 2012 - 40670.97
VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ; VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ;
final String loanProductJson = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfigwithEqualPrincipal(false, NONE); final String loanProductJson = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfigwithEqualPrincipal(false, NONE);
Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductJson); Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductJson);
@@ -228,11 +228,11 @@ public class VariableInstallmentsIntegrationTest {
Map list = transactionHelper.retrieveSchedule(loanID) ; Map list = transactionHelper.retrieveSchedule(loanID) ;
Map repaymentSchedule = (Map)list.get("repaymentSchedule") ; Map repaymentSchedule = (Map)list.get("repaymentSchedule") ;
ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ; ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ;
String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createAllVariationsWithEqualPrincipal() ; //0th position will have disbursement String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createAllVariationsWithEqualPrincipal() ; //0th position will have disbursement
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "25 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "25 December 2011", "20 January 2012"},
new String[] {"27000.0", "31500.0", "6045.16", "40670.97"}) ; new String[] {"27000.0", "31500.0", "6045.16", "40670.97"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
@@ -242,7 +242,7 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testModifyDatesWithDecliningBalanceEqualInstallments() { public void testModifyDatesWithDecliningBalanceEqualInstallments() {
//Modify 20 December 2011:25000 -> 04 January 2012:20000 //Modify 20 December 2011:25000 -> 04 January 2012:20000
@@ -258,18 +258,18 @@ public class VariableInstallmentsIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
//Integer loanID = 57 ; //Integer loanID = 57 ;
Map list = transactionHelper.retrieveSchedule(loanID) ; Map list = transactionHelper.retrieveSchedule(loanID) ;
Map repaymentSchedule = (Map)list.get("repaymentSchedule") ; Map repaymentSchedule = (Map)list.get("repaymentSchedule") ;
ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ; ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ;
// //
// //
String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createModifiyDateVariations(new String[]{"20 December 2011", "20 January 2012"}, new String[]{"04 January 2012", "08 February 2012"}, new String[]{"20000"}) ; //0th position will have disbursement String addVariationsjsondata = VariableInstallmentsDecliningBalanceHelper.createModifiyDateVariations(new String[]{"20 December 2011", "20 January 2012"}, new String[]{"04 January 2012", "08 February 2012"}, new String[]{"20000"}) ; //0th position will have disbursement
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "04 January 2012", "08 February 2012"}, ArrayList toVerifyData = VariableInstallmentsDecliningBalanceHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "04 January 2012", "08 February 2012"},
new String[] {"26262.38", "26262.38", "20000.0", "33242.97"}) ; new String[] {"26262.38", "26262.38", "20000.0", "33242.97"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
list = transactionHelper.retrieveSchedule(loanID) ; list = transactionHelper.retrieveSchedule(loanID) ;
repaymentSchedule = (Map)list.get("repaymentSchedule") ; repaymentSchedule = (Map)list.get("repaymentSchedule") ;
@@ -277,7 +277,7 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
// Interest Type is FLAT // Interest Type is FLAT
@Test @Test
public void testDeleteInstallmentsWithInterestTypeFlat() { public void testDeleteInstallmentsWithInterestTypeFlat() {
@@ -298,7 +298,7 @@ public class VariableInstallmentsIntegrationTest {
String toDeletedata = VariableInstallmentsFlatHelper.createDeleteVariations(toDelete) ; String toDeletedata = VariableInstallmentsFlatHelper.createDeleteVariations(toDelete) ;
HashMap modifiedReschdule = transactionHelper.validateVariations(toDeletedata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(toDeletedata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 November 2011", "20 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 November 2011", "20 December 2011", "20 January 2012"},
new String[] {"36000.0", "36000.0", "36000.0"}) ; new String[] {"36000.0", "36000.0", "36000.0"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(toDeletedata, loanID) ; transactionHelper.submitVariations(toDeletedata, loanID) ;
@@ -308,7 +308,7 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testAddInstallmentsWithInterestTypeFlat() { public void testAddInstallmentsWithInterestTypeFlat() {
//31 October 2011 - 5000 //31 October 2011 - 5000
@@ -329,7 +329,7 @@ public class VariableInstallmentsIntegrationTest {
String addVariationsjsondata = VariableInstallmentsFlatHelper.createAddVariations() ; String addVariationsjsondata = VariableInstallmentsFlatHelper.createAddVariations() ;
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "31 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "31 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"},
new String[] {"21600.0", "6600.0", "26600.0", "26600.0", "26600.0"}) ; new String[] {"21600.0", "6600.0", "26600.0", "26600.0", "26600.0"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
@@ -339,7 +339,7 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testModifyInstallmentsWithInterestTypeisFlat() { public void testModifyInstallmentsWithInterestTypeisFlat() {
//20 October 2011 - 30000 modify //20 October 2011 - 30000 modify
@@ -357,10 +357,10 @@ public class VariableInstallmentsIntegrationTest {
Map list = transactionHelper.retrieveSchedule(loanID) ; Map list = transactionHelper.retrieveSchedule(loanID) ;
Map repaymentSchedule = (Map)list.get("repaymentSchedule") ; Map repaymentSchedule = (Map)list.get("repaymentSchedule") ;
ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ; ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ;
String addVariationsjsondata = VariableInstallmentsFlatHelper.createModifiyVariations((Map)periods.get(1)) ; //0th position will have disbursement String addVariationsjsondata = VariableInstallmentsFlatHelper.createModifiyVariations((Map)periods.get(1)) ; //0th position will have disbursement
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "20 December 2011", "20 January 2012"},
new String[] {"32000.0", "25333.33", "25333.33", "25333.34"}) ; new String[] {"32000.0", "25333.33", "25333.33", "25333.34"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
@@ -370,11 +370,11 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testAllVariationsWithInterestTypeFlat() { public void testAllVariationsWithInterestTypeFlat() {
// Request: Delete 20 December 2011 25000.0, Modify 20 November 2011 from 25,000 to 30000, Add 25 December 2011 5000 // Request: Delete 20 December 2011 25000.0, Modify 20 November 2011 from 25,000 to 30000, Add 25 December 2011 5000
// Result: 20 October 2011 - 27000.0, 20 November 2011 - 32000.0, 25 December 2011 - 7000.0, 20 January 2012 - 42000.0 // Result: 20 October 2011 - 27000.0, 20 November 2011 - 32000.0, 25 December 2011 - 7000.0, 20 January 2012 - 42000.0
VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ; VariableIntallmentsTransactionHelper transactionHelper = new VariableIntallmentsTransactionHelper(requestSpec, responseSpec) ;
final String loanProductJson = VariableInstallmentsFlatHelper.createLoanProductWithVaribleConfig(false, NONE); final String loanProductJson = VariableInstallmentsFlatHelper.createLoanProductWithVaribleConfig(false, NONE);
Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductJson); Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductJson);
@@ -388,11 +388,11 @@ public class VariableInstallmentsIntegrationTest {
Map list = transactionHelper.retrieveSchedule(loanID) ; Map list = transactionHelper.retrieveSchedule(loanID) ;
Map repaymentSchedule = (Map)list.get("repaymentSchedule") ; Map repaymentSchedule = (Map)list.get("repaymentSchedule") ;
ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ; ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ;
String addVariationsjsondata = VariableInstallmentsFlatHelper.createAllVariations() ; //0th position will have disbursement String addVariationsjsondata = VariableInstallmentsFlatHelper.createAllVariations() ; //0th position will have disbursement
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "25 December 2011", "20 January 2012"}, ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "25 December 2011", "20 January 2012"},
new String[] {"27000.0", "32000.0", "7000.0", "42000.0"}) ; new String[] {"27000.0", "32000.0", "7000.0", "42000.0"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
@@ -402,7 +402,7 @@ public class VariableInstallmentsIntegrationTest {
periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this. periods.remove(0) ; //Repayments Schedule includes disbursement also. So remove this.
assertAfterSubmit(periods, toVerifyData) ; assertAfterSubmit(periods, toVerifyData) ;
} }
@Test @Test
public void testModifyDatesWithInterestTypeFlat() { public void testModifyDatesWithInterestTypeFlat() {
//Modify 20 December 2011:25000 -> 04 January 2012:20000 //Modify 20 December 2011:25000 -> 04 January 2012:20000
@@ -418,18 +418,18 @@ public class VariableInstallmentsIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
//Integer loanID = 67 ; //Integer loanID = 67 ;
Map list = transactionHelper.retrieveSchedule(loanID) ; Map list = transactionHelper.retrieveSchedule(loanID) ;
Map repaymentSchedule = (Map)list.get("repaymentSchedule") ; Map repaymentSchedule = (Map)list.get("repaymentSchedule") ;
ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ; ArrayList periods = (ArrayList)repaymentSchedule.get("periods") ;
// //
// //
String addVariationsjsondata = VariableInstallmentsFlatHelper.createModifiyDateVariations(new String[]{"20 December 2011", "20 January 2012"}, new String[]{"04 January 2012", "08 February 2012"}, new String[]{"20000"}) ; //0th position will have disbursement String addVariationsjsondata = VariableInstallmentsFlatHelper.createModifiyDateVariations(new String[]{"20 December 2011", "20 January 2012"}, new String[]{"04 January 2012", "08 February 2012"}, new String[]{"20000"}) ; //0th position will have disbursement
HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ; HashMap modifiedReschdule = transactionHelper.validateVariations(addVariationsjsondata, loanID) ;
ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ; ArrayList newperiods = (ArrayList) modifiedReschdule.get("periods") ;
ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "04 January 2012", "08 February 2012"}, ArrayList toVerifyData = VariableInstallmentsFlatHelper.constructVerifyData(new String[] {"20 October 2011", "20 November 2011", "04 January 2012", "08 February 2012"},
new String[] {"27306.45", "27306.45", "22306.45", "32306.46"}) ; new String[] {"27306.45", "27306.45", "22306.45", "32306.46"}) ;
assertAfterSubmit(newperiods, toVerifyData) ; assertAfterSubmit(newperiods, toVerifyData) ;
transactionHelper.submitVariations(addVariationsjsondata, loanID) ; transactionHelper.submitVariations(addVariationsjsondata, loanID) ;
list = transactionHelper.retrieveSchedule(loanID) ; list = transactionHelper.retrieveSchedule(loanID) ;
repaymentSchedule = (Map)list.get("repaymentSchedule") ; repaymentSchedule = (Map)list.get("repaymentSchedule") ;
@@ -31,27 +31,27 @@ import com.jayway.restassured.specification.ResponseSpecification;
public class VariableIntallmentsTransactionHelper { public class VariableIntallmentsTransactionHelper {
private final String URL = "https://localhost:8443/fineract-provider/api/v1/loans/" ; private final String URL = "https://localhost:8443/fineract-provider/api/v1/loans/" ;
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public VariableIntallmentsTransactionHelper(final RequestSpecification requestSpec, public VariableIntallmentsTransactionHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec ; this.requestSpec = requestSpec ;
this.responseSpec = responseSpec ; this.responseSpec = responseSpec ;
} }
public Map retrieveSchedule(Integer loanId) { public Map retrieveSchedule(Integer loanId) {
String url = URL+loanId+"?associations=repaymentSchedule&exclude=guarantors&"+Utils.TENANT_IDENTIFIER ; String url = URL+loanId+"?associations=repaymentSchedule&exclude=guarantors&"+Utils.TENANT_IDENTIFIER ;
return Utils.performServerGet(requestSpec, responseSpec, url, ""); return Utils.performServerGet(requestSpec, responseSpec, url, "");
} }
public HashMap validateVariations(final String exceptions, Integer loanId) { public HashMap validateVariations(final String exceptions, Integer loanId) {
String url = URL+loanId+"/schedule?command=calculateLoanSchedule&"+Utils.TENANT_IDENTIFIER ; String url = URL+loanId+"/schedule?command=calculateLoanSchedule&"+Utils.TENANT_IDENTIFIER ;
return Utils.performServerPost(this.requestSpec, this.responseSpec, url, exceptions, ""); return Utils.performServerPost(this.requestSpec, this.responseSpec, url, exceptions, "");
} }
public HashMap submitVariations(final String exceptions, Integer loanId) { public HashMap submitVariations(final String exceptions, Integer loanId) {
String url = URL+loanId+"/schedule?command=addVariations&"+Utils.TENANT_IDENTIFIER ; String url = URL+loanId+"/schedule?command=addVariations&"+Utils.TENANT_IDENTIFIER ;
return Utils.performServerPost(this.requestSpec, this.responseSpec, url, exceptions, ""); return Utils.performServerPost(this.requestSpec, this.responseSpec, url, exceptions, "");
@@ -82,14 +82,14 @@ public class ServerWithMariaDB4jApplication {
if (distResource.exists()) { if (distResource.exists()) {
openWebBrowser(distURI); openWebBrowser(distURI);
} else if (devResource.exists()) { } else if (devResource.exists()) {
openWebBrowser(devURI); openWebBrowser(devURI);
} else { } else {
logger.error("Cannot open Fineract UI in browser; not found: " + distResource.toString()); logger.error("Cannot open Fineract UI in browser; not found: " + distResource.toString());
} }
} }
// TODO Tray Icon stuff; dig out my very own old @see https://github.com/mifos/head/tree/hudsonBuild-MIFOS-5157_Launch4j-EXE_NewDist-squash1/server-jetty/src/main/java/org/mifos/server/tray // TODO Tray Icon stuff; dig out my very own old @see https://github.com/mifos/head/tree/hudsonBuild-MIFOS-5157_Launch4j-EXE_NewDist-squash1/server-jetty/src/main/java/org/mifos/server/tray
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx); ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
} }
@@ -27,7 +27,7 @@ public class AccrualAccountingConstants {
public static final String accrueTillParamName = "tillDate"; public static final String accrueTillParamName = "tillDate";
public static final String localeParamName = "locale"; public static final String localeParamName = "locale";
public static final String dateFormatParamName = "dateFormat"; public static final String dateFormatParamName = "dateFormat";
public static final String PERIODIC_ACCRUAL_ACCOUNTING_RESOURCE_NAME = "periodicaccrual"; public static final String PERIODIC_ACCRUAL_ACCOUNTING_RESOURCE_NAME = "periodicaccrual";
public static final String PERIODIC_ACCRUAL_ACCOUNTING_EXECUTION_ERROR_CODE = "execution.failed"; public static final String PERIODIC_ACCRUAL_ACCOUNTING_EXECUTION_ERROR_CODE = "execution.failed";
} }
@@ -26,7 +26,7 @@ import org.joda.time.LocalDate;
/** /**
* Immutable object representing a General Ledger Account * Immutable object representing a General Ledger Account
* *
* Note: no getter/setters required as google-gson will produce json from fields * Note: no getter/setters required as google-gson will produce json from fields
* of object. * of object.
*/ */
@@ -41,7 +41,7 @@ public interface AccountingDropdownReadPlatformService {
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForCharges(); public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForCharges();
public Map<String, List<GLAccountData>> retrieveAccountMappingOptions(); public Map<String, List<GLAccountData>> retrieveAccountMappingOptions();
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForShareProducts(); public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForShareProducts();
} }
@@ -30,7 +30,7 @@ import java.util.List;
/** /**
* Immutable object representing a General Ledger Account * Immutable object representing a General Ledger Account
* *
* Note: no getter/setters required as google-gson will produce json from fields * Note: no getter/setters required as google-gson will produce json from fields
* of object. * of object.
*/ */
@@ -21,7 +21,7 @@ package org.apache.fineract.accounting.glaccount.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
/** /**
* *
* when gl account is attached with any product(loan/saving) then we can not * when gl account is attached with any product(loan/saving) then we can not
* disable the gl account * disable the gl account
*/ */
@@ -28,7 +28,7 @@ import org.joda.time.LocalDate;
/** /**
* Class for parsing dates sent as query parameters * Class for parsing dates sent as query parameters
* *
* TODO: Vishwas Should move this class to a more generic package * TODO: Vishwas Should move this class to a more generic package
*/ */
public class DateParam { public class DateParam {
@@ -221,7 +221,7 @@ public class JournalEntriesApiResource {
return this.apiJsonSerializerService.serialize(settings, entries, RESPONSE_DATA_PARAMETERS); return this.apiJsonSerializerService.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
} }
@GET @GET
@Path("openingbalance") @Path("openingbalance")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@@ -29,7 +29,7 @@ import org.joda.time.LocalDate;
/** /**
* Immutable object representing a General Ledger Account * Immutable object representing a General Ledger Account
* *
* Note: no getter/setters required as google will produce json from fields of * Note: no getter/setters required as google will produce json from fields of
* object. * object.
*/ */
@@ -220,7 +220,7 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
return this.entityType; return this.entityType;
} }
public Long getShareTransactionId() { public Long getShareTransactionId() {
return this.shareTransactionId; return this.shareTransactionId;
} }
@@ -37,8 +37,8 @@ public interface JournalEntryRepository extends JpaRepository<JournalEntry, Long
@Query("select DISTINCT j.transactionId from JournalEntry j where j.office.id = :officeId and j.glAccount.id = :contraId and j.reversed=false and j.transactionId not in (select DISTINCT je.reversalJournalEntry.transactionId from JournalEntry je where je.reversed=true)") @Query("select DISTINCT j.transactionId from JournalEntry j where j.office.id = :officeId and j.glAccount.id = :contraId and j.reversed=false and j.transactionId not in (select DISTINCT je.reversalJournalEntry.transactionId from JournalEntry je where je.reversed=true)")
List<String> findNonReversedContraTansactionIds(@Param("contraId") Long contraId, @Param("officeId") Long officeId); List<String> findNonReversedContraTansactionIds(@Param("contraId") Long contraId, @Param("officeId") Long officeId);
@Query("select journalEntry from JournalEntry journalEntry where journalEntry.entityId= :entityId and journalEntry.entityType = :entityType") @Query("select journalEntry from JournalEntry journalEntry where journalEntry.entityId= :entityId and journalEntry.entityType = :entityType")
List<JournalEntry> findProvisioningJournalEntriesByEntityId(@Param("entityId") Long entityId, @Param("entityType") Integer entityType) ; List<JournalEntry> findProvisioningJournalEntriesByEntityId(@Param("entityId") Long entityId, @Param("entityType") Integer entityType) ;
@Query("select journalEntry from JournalEntry journalEntry where journalEntry.transactionId= :transactionId and journalEntry.reversed=false and journalEntry.entityType = :entityType") @Query("select journalEntry from JournalEntry journalEntry where journalEntry.transactionId= :transactionId and journalEntry.reversed=false and journalEntry.entityType = :entityType")
@@ -29,7 +29,7 @@ import org.springframework.stereotype.Service;
@Service @Service
@CommandType(entity = "JOURNALENTRY", action = "DEFINEOPENINGBALANCE") @CommandType(entity = "JOURNALENTRY", action = "DEFINEOPENINGBALANCE")
public class DefineOpeningBalanceCommandHandler implements NewCommandSourceHandler { public class DefineOpeningBalanceCommandHandler implements NewCommandSourceHandler {
private final JournalEntryWritePlatformService writePlatformService; private final JournalEntryWritePlatformService writePlatformService;
@Autowired @Autowired
@@ -340,10 +340,10 @@ public class AccountingProcessorHelper {
/** /**
* Convenience method that creates a pair of related Debits and Credits for * Convenience method that creates a pair of related Debits and Credits for
* Accrual Based accounting. * Accrual Based accounting.
* *
* The target accounts for debits and credits are switched in case of a * The target accounts for debits and credits are switched in case of a
* reversal * reversal
* *
* @param office * @param office
* @param accountTypeToBeDebited * @param accountTypeToBeDebited
* Enum of the placeholder GLAccount to be debited * Enum of the placeholder GLAccount to be debited
@@ -375,10 +375,10 @@ public class AccountingProcessorHelper {
/** /**
* Convenience method that creates a pair of related Debits and Credits for * Convenience method that creates a pair of related Debits and Credits for
* Accrual Based accounting. * Accrual Based accounting.
* *
* The target accounts for debits and credits are switched in case of a * The target accounts for debits and credits are switched in case of a
* reversal * reversal
* *
* @param office office * @param office office
* @param currencyCode currencyCode * @param currencyCode currencyCode
* @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited * @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited
@@ -435,10 +435,10 @@ public class AccountingProcessorHelper {
/** /**
* Convenience method that creates a pair of related Debits and Credits for * Convenience method that creates a pair of related Debits and Credits for
* Cash Based accounting. * Cash Based accounting.
* *
* The target accounts for debits and credits are switched in case of a * The target accounts for debits and credits are switched in case of a
* reversal * reversal
* *
* @param office * @param office
* @param accountTypeToBeDebited * @param accountTypeToBeDebited
* Enum of the placeholder GLAccount to be debited * Enum of the placeholder GLAccount to be debited
@@ -470,10 +470,10 @@ public class AccountingProcessorHelper {
/** /**
* Convenience method that creates a pair of related Debits and Credits for * Convenience method that creates a pair of related Debits and Credits for
* Cash Based accounting. * Cash Based accounting.
* *
* The target accounts for debits and credits are switched in case of a * The target accounts for debits and credits are switched in case of a
* reversal * reversal
* *
* @param office * @param office
* @param accountTypeToBeDebited * @param accountTypeToBeDebited
* Enum of the placeholder GLAccount to be debited * Enum of the placeholder GLAccount to be debited
@@ -562,10 +562,10 @@ public class AccountingProcessorHelper {
/** /**
* Convenience method that creates a pair of related Debits and Credits for * Convenience method that creates a pair of related Debits and Credits for
* Cash Based accounting. * Cash Based accounting.
* *
* The target accounts for debits and credits are switched in case of a * The target accounts for debits and credits are switched in case of a
* reversal * reversal
* *
* @param office * @param office
* @param currencyCode * @param currencyCode
* @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited * @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited
@@ -721,10 +721,10 @@ public class AccountingProcessorHelper {
/** /**
* Convenience method that creates a pair of related Debits and Credits for * Convenience method that creates a pair of related Debits and Credits for
* Cash Based accounting. * Cash Based accounting.
* *
* The target accounts for debits and credits are switched in case of a * The target accounts for debits and credits are switched in case of a
* reversal * reversal
* *
* @param office office * @param office office
* @param currencyCode currencyCode * @param currencyCode currencyCode
* @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited * @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited
@@ -1041,7 +1041,7 @@ public class AccountingProcessorHelper {
"Recent Portfolio changes w.r.t Charges for shares have Broken the accounting code", "Recent Portfolio changes w.r.t Charges for shares have Broken the accounting code",
"Recent Portfolio changes w.r.t Charges for shares have Broken the accounting code"); } "Recent Portfolio changes w.r.t Charges for shares have Broken the accounting code"); }
} }
private void createDebitJournalEntryForShares(final Office office, final String currencyCode, final GLAccount account, private void createDebitJournalEntryForShares(final Office office, final String currencyCode, final GLAccount account,
final Long shareAccountId, final String transactionId, final Date transactionDate, final BigDecimal amount) { final Long shareAccountId, final String transactionId, final Date transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
@@ -102,7 +102,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
/** /**
* Debit loan Portfolio and credit Fund source for Disbursement. * Debit loan Portfolio and credit Fund source for Disbursement.
* *
* @param loanDTO * @param loanDTO
* @param loanTransactionDTO * @param loanTransactionDTO
* @param office * @param office
@@ -141,20 +141,20 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
} }
/** /**
* *
* Handles repayments using the following posting rules <br/> * Handles repayments using the following posting rules <br/>
* <br/> * <br/>
* <br/> * <br/>
* *
* <b>Principal Repayment</b>: Debits "Fund Source" and Credits * <b>Principal Repayment</b>: Debits "Fund Source" and Credits
* "Loan Portfolio"<br/> * "Loan Portfolio"<br/>
* *
* <b>Interest Repayment</b>:Debits "Fund Source" and and Credits * <b>Interest Repayment</b>:Debits "Fund Source" and and Credits
* "Receivable Interest" <br/> * "Receivable Interest" <br/>
* *
* <b>Fee Repayment</b>:Debits "Fund Source" (or "Interest on Loans" in case * <b>Fee Repayment</b>:Debits "Fund Source" (or "Interest on Loans" in case
* of repayment at disbursement) and and Credits "Receivable Fees" <br/> * of repayment at disbursement) and and Credits "Receivable Fees" <br/>
* *
* <b>Penalty Repayment</b>: Debits "Fund Source" and and Credits * <b>Penalty Repayment</b>: Debits "Fund Source" and and Credits
* "Receivable Penalties" <br/> * "Receivable Penalties" <br/>
* <br/> * <br/>
@@ -162,24 +162,24 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
* <br/> * <br/>
* <b>Principal Write off</b>: Debits "Losses Written Off" and Credits * <b>Principal Write off</b>: Debits "Losses Written Off" and Credits
* "Loan Portfolio"<br/> * "Loan Portfolio"<br/>
* *
* <b>Interest Write off</b>:Debits "Losses Written off" and and Credits * <b>Interest Write off</b>:Debits "Losses Written off" and and Credits
* "Receivable Interest" <br/> * "Receivable Interest" <br/>
* *
* <b>Fee Write off</b>:Debits "Losses Written off" and and Credits * <b>Fee Write off</b>:Debits "Losses Written off" and and Credits
* "Receivable Fees" <br/> * "Receivable Fees" <br/>
* *
* <b>Penalty Write off</b>: Debits "Losses Written off" and and Credits * <b>Penalty Write off</b>: Debits "Losses Written off" and and Credits
* "Receivable Penalties" <br/> * "Receivable Penalties" <br/>
* <br/> * <br/>
* <br/> * <br/>
* In case the loan transaction has been reversed, all debits are turned * In case the loan transaction has been reversed, all debits are turned
* into credits and vice versa * into credits and vice versa
* *
* @param loanTransactionDTO * @param loanTransactionDTO
* @param loanDTO * @param loanDTO
* @param office * @param office
* *
*/ */
private void createJournalEntriesForRepaymentsAndWriteOffs(final LoanDTO loanDTO, final LoanTransactionDTO loanTransactionDTO, private void createJournalEntriesForRepaymentsAndWriteOffs(final LoanDTO loanDTO, final LoanTransactionDTO loanTransactionDTO,
final Office office, final boolean writeOff, final boolean isIncomeFromFee) { final Office office, final boolean writeOff, final boolean isIncomeFromFee) {
@@ -320,7 +320,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
/** /**
* Create a single Debit to fund source and a single credit to * Create a single Debit to fund source and a single credit to
* "Income from Recovery" * "Income from Recovery"
* *
* In case the loan transaction is a reversal, all debits are turned into * In case the loan transaction is a reversal, all debits are turned into
* credits and vice versa * credits and vice versa
*/ */
@@ -347,15 +347,15 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
/** /**
* Recognize the receivable interest <br/> * Recognize the receivable interest <br/>
* Debit "Interest Receivable" and Credit "Income from Interest" * Debit "Interest Receivable" and Credit "Income from Interest"
* *
* <b>Fees:</b> Debit <i>Fees Receivable</i> and credit <i>Income from * <b>Fees:</b> Debit <i>Fees Receivable</i> and credit <i>Income from
* Fees</i> <br/> * Fees</i> <br/>
* *
* <b>Penalties:</b> Debit <i>Penalties Receivable</i> and credit <i>Income * <b>Penalties:</b> Debit <i>Penalties Receivable</i> and credit <i>Income
* from Penalties</i> * from Penalties</i>
* *
* Also handles reversals for both fees and payment applications * Also handles reversals for both fees and payment applications
* *
* @param loanDTO * @param loanDTO
* @param loanTransactionDTO * @param loanTransactionDTO
* @param office * @param office
@@ -55,7 +55,7 @@ public class CashBasedAccountingProcessorForClientTransactions implements Accoun
/** /**
* Create a single debit to fund source and multiple credits for the income * Create a single debit to fund source and multiple credits for the income
* account mapped with each charge this payment pays off * account mapped with each charge this payment pays off
* *
* In case the loan transaction is a reversal, all debits are turned into * In case the loan transaction is a reversal, all debits are turned into
* credits and vice versa * credits and vice versa
*/ */
@@ -110,11 +110,11 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
/** /**
* Debit loan Portfolio and credit Fund source for a Disbursement <br/> * Debit loan Portfolio and credit Fund source for a Disbursement <br/>
* *
* All debits are turned into credits and vice versa in case of disbursement * All debits are turned into credits and vice versa in case of disbursement
* reversals * reversals
* *
* *
* @param loanDTO * @param loanDTO
* @param loanTransactionDTO * @param loanTransactionDTO
* @param office * @param office
@@ -150,11 +150,11 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
/** /**
* Debit loan Portfolio and credit Fund source for a Disbursement <br/> * Debit loan Portfolio and credit Fund source for a Disbursement <br/>
* *
* All debits are turned into credits and vice versa in case of disbursement * All debits are turned into credits and vice versa in case of disbursement
* reversals * reversals
* *
* *
* @param loanDTO * @param loanDTO
* @param loanTransactionDTO * @param loanTransactionDTO
* @param office * @param office
@@ -188,7 +188,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
* (loan portfolio for principal repayments, Interest on loans for interest * (loan portfolio for principal repayments, Interest on loans for interest
* repayments, Income from fees for fees payment and Income from penalties * repayments, Income from fees for fees payment and Income from penalties
* for penalty payment) * for penalty payment)
* *
* In case the loan transaction is a reversal, all debits are turned into * In case the loan transaction is a reversal, all debits are turned into
* credits and vice versa * credits and vice versa
*/ */
@@ -259,7 +259,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
/** /**
* Create a single Debit to fund source and a single credit to * Create a single Debit to fund source and a single credit to
* "Income from Recovery" * "Income from Recovery"
* *
* In case the loan transaction is a reversal, all debits are turned into * In case the loan transaction is a reversal, all debits are turned into
* credits and vice versa * credits and vice versa
*/ */
@@ -287,11 +287,11 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
* Credit loan Portfolio and Debit Suspense Account for a Transfer * Credit loan Portfolio and Debit Suspense Account for a Transfer
* Initiation. A Transfer acceptance would be treated the opposite i.e Debit * Initiation. A Transfer acceptance would be treated the opposite i.e Debit
* Loan Portfolio and Credit Suspense Account <br/> * Loan Portfolio and Credit Suspense Account <br/>
* *
* All debits are turned into credits and vice versa in case of Transfer * All debits are turned into credits and vice versa in case of Transfer
* Initiation disbursals * Initiation disbursals
* *
* *
* @param loanDTO * @param loanDTO
* @param loanTransactionDTO * @param loanTransactionDTO
* @param office * @param office
@@ -320,7 +320,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
null, loanId, transactionId, transactionDate, principalAmount, isReversal); null, loanId, transactionId, transactionDate, principalAmount, isReversal);
} }
} }
private void createJournalEntriesForRefundForActiveLoan(LoanDTO loanDTO, LoanTransactionDTO loanTransactionDTO, Office office) { private void createJournalEntriesForRefundForActiveLoan(LoanDTO loanDTO, LoanTransactionDTO loanTransactionDTO, Office office) {
// loan properties // loan properties
final Long loanProductId = loanDTO.getLoanProductId(); final Long loanProductId = loanDTO.getLoanProductId();
@@ -354,11 +354,11 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) { if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(feesAmount); totalDebitAmount = totalDebitAmount.add(feesAmount);
List<ChargePaymentDTO> chargePaymentDTOs = new ArrayList<>(); List<ChargePaymentDTO> chargePaymentDTOs = new ArrayList<>();
for(ChargePaymentDTO chargePaymentDTO : loanTransactionDTO.getFeePayments()) { for(ChargePaymentDTO chargePaymentDTO : loanTransactionDTO.getFeePayments()) {
chargePaymentDTOs.add(new ChargePaymentDTO(chargePaymentDTO.getChargeId(), chargePaymentDTO.getLoanChargeId(), chargePaymentDTOs.add(new ChargePaymentDTO(chargePaymentDTO.getChargeId(), chargePaymentDTO.getLoanChargeId(),
chargePaymentDTO.getAmount().floatValue() < 0 ? chargePaymentDTO.getAmount().multiply(new BigDecimal(-1)):chargePaymentDTO.getAmount() )); chargePaymentDTO.getAmount().floatValue() < 0 ? chargePaymentDTO.getAmount().multiply(new BigDecimal(-1)):chargePaymentDTO.getAmount() ));
} }
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
@@ -369,12 +369,12 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) { if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(penaltiesAmount); totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
List<ChargePaymentDTO> chargePaymentDTOs = new ArrayList<>(); List<ChargePaymentDTO> chargePaymentDTOs = new ArrayList<>();
for(ChargePaymentDTO chargePaymentDTO : loanTransactionDTO.getPenaltyPayments()) { for(ChargePaymentDTO chargePaymentDTO : loanTransactionDTO.getPenaltyPayments()) {
chargePaymentDTOs.add(new ChargePaymentDTO(chargePaymentDTO.getChargeId(), chargePaymentDTO.getLoanChargeId(), chargePaymentDTOs.add(new ChargePaymentDTO(chargePaymentDTO.getChargeId(), chargePaymentDTO.getLoanChargeId(),
chargePaymentDTO.getAmount().floatValue() < 0 ? chargePaymentDTO.getAmount().multiply(new BigDecimal(-1)):chargePaymentDTO.getAmount() )); chargePaymentDTO.getAmount().floatValue() < 0 ? chargePaymentDTO.getAmount().multiply(new BigDecimal(-1)):chargePaymentDTO.getAmount() ));
} }
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate, CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
penaltiesAmount, !isReversal, chargePaymentDTOs); penaltiesAmount, !isReversal, chargePaymentDTOs);
@@ -389,6 +389,6 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
/*** create a single debit entry (or reversal) for the entire amount **/ /*** create a single debit entry (or reversal) for the entire amount **/
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId, this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, !isReversal); paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, !isReversal);
} }
} }
@@ -123,13 +123,13 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
transactionId, transactionDate, amount.subtract(chargeAmount)); transactionId, transactionDate, amount.subtract(chargeAmount));
this.helper.createCreditJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, this.helper.createCreditJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId,
transactionId, transactionDate, amount); transactionId, transactionDate, amount);
}else{ }else{
this.helper.createJournalEntriesForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amount); transactionDate, amount);
} }
} }
} }
@@ -362,7 +362,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
if (searchParameters.isOrderByRequested()) { if (searchParameters.isOrderByRequested()) {
sqlBuilder.append(" order by ").append(searchParameters.getOrderBy()); sqlBuilder.append(" order by ").append(searchParameters.getOrderBy());
this.columnValidator.validateSqlInjection(sqlBuilder.toString(), searchParameters.getOrderBy()); this.columnValidator.validateSqlInjection(sqlBuilder.toString(), searchParameters.getOrderBy());
if (searchParameters.isSortOrderProvided()) { if (searchParameters.isSortOrderProvided()) {
sqlBuilder.append(' ').append(searchParameters.getSortOrder()); sqlBuilder.append(' ').append(searchParameters.getSortOrder());
this.columnValidator.validateSqlInjection(sqlBuilder.toString(), searchParameters.getOrderBy()); this.columnValidator.validateSqlInjection(sqlBuilder.toString(), searchParameters.getOrderBy());
@@ -65,11 +65,11 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
private final GLJournalEntryMapper entryMapper = new GLJournalEntryMapper(); private final GLJournalEntryMapper entryMapper = new GLJournalEntryMapper();
// if a limit is not added to the running balance select statements below and the resultset is more than 400,000, // if a limit is not added to the running balance select statements below and the resultset is more than 400,000,
// the script will eat up all of the server memory // the script will eat up all of the server memory
private final String selectRunningBalanceSqlLimit = "limit 0, 10000"; private final String selectRunningBalanceSqlLimit = "limit 0, 10000";
private final String officeRunningBalanceSql = "select je.office_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je " private final String officeRunningBalanceSql = "select je.office_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je "
+ "inner join (select max(id) as id from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id,entry_date) je2 " + "inner join (select max(id) as id from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id,entry_date) je2 "
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id) je3 " + "inner join (select max(entry_date) as date from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id) je3 "
@@ -39,12 +39,12 @@ public interface JournalEntryWritePlatformService {
void createJournalEntriesForClientTransactions(Map<String, Object> accountingBridgeData); void createJournalEntriesForClientTransactions(Map<String, Object> accountingBridgeData);
CommandProcessingResult defineOpeningBalance(JsonCommand command); CommandProcessingResult defineOpeningBalance(JsonCommand command);
public String revertProvisioningJournalEntries(final Date reversalTransactionDate, final Long entityId, final Integer entityType) ; public String revertProvisioningJournalEntries(final Date reversalTransactionDate, final Long entityId, final Integer entityType) ;
public String createProvisioningJournalEntries(ProvisioningEntry entry) ; public String createProvisioningJournalEntries(ProvisioningEntry entry) ;
void createJournalEntriesForShares(Map<String, Object> accountingBridgeData); void createJournalEntriesForShares(Map<String, Object> accountingBridgeData);
void revertShareAccountJournalEntries(final ArrayList<Long> transactionId, final Date transactionDate); void revertShareAccountJournalEntries(final ArrayList<Long> transactionId, final Date transactionDate);
} }
@@ -323,7 +323,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final boolean useDefaultComment = StringUtils.isBlank(reversalComment); final boolean useDefaultComment = StringUtils.isBlank(reversalComment);
validateCommentForReversal(reversalComment); validateCommentForReversal(reversalComment);
//Before reversal validate accounting closure is done for that branch or not. //Before reversal validate accounting closure is done for that branch or not.
final Date journalEntriesTransactionDate = journalEntries.get(0).getTransactionDate(); final Date journalEntriesTransactionDate = journalEntries.get(0).getTransactionDate();
final GLClosure latestGLClosureByBranch = this.glClosureRepository.getLatestGLClosureByBranch(officeId); final GLClosure latestGLClosureByBranch = this.glClosureRepository.getLatestGLClosureByBranch(officeId);
@@ -563,7 +563,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
} }
} }
} }
private void validateBusinessRulesForJournalEntries(final JournalEntryCommand command) { private void validateBusinessRulesForJournalEntries(final JournalEntryCommand command) {
/** check if date of Journal entry is valid ***/ /** check if date of Journal entry is valid ***/
final LocalDate entryLocalDate = command.getTransactionDate(); final LocalDate entryLocalDate = command.getTransactionDate();
@@ -48,27 +48,27 @@ import com.google.gson.JsonElement;
/** /**
* TODO Vishwas find a better approach for validation * TODO Vishwas find a better approach for validation
* *
* Currently, validation of the passed in JSON is done before calling save or * Currently, validation of the passed in JSON is done before calling save or
* update method on the target resource (in our case the loan Product) * update method on the target resource (in our case the loan Product)
* *
* However, in the case of a loan product it would be difficult to validate the * However, in the case of a loan product it would be difficult to validate the
* passed in JSON for valid {@link LoanProduct} to {@link GLAccount} mappings * passed in JSON for valid {@link LoanProduct} to {@link GLAccount} mappings
* during update because of the following scenario * during update because of the following scenario
* *
* The accounting rule type may be changed in the update command, so we would * The accounting rule type may be changed in the update command, so we would
* have to validate if all required account heads for a particular account type * have to validate if all required account heads for a particular account type
* have been passed in (would be different for CASH and Accrual based). However, * have been passed in (would be different for CASH and Accrual based). However,
* till we have access to the domain object it would not be possible to detect * till we have access to the domain object it would not be possible to detect
* if an accounting rule has actually been changed * if an accounting rule has actually been changed
* *
* Hence, method {@link #validateForLoanProductCreate(String)} from this class * Hence, method {@link #validateForLoanProductCreate(String)} from this class
* is called separately for validation only if an accounting rule change is * is called separately for validation only if an accounting rule change is
* detected by {@link ProductToGLAccountMappingWritePlatformService} * detected by {@link ProductToGLAccountMappingWritePlatformService}
* *
* Also, the class is probably named wrong (*FromApiJsonDeserializer) should * Also, the class is probably named wrong (*FromApiJsonDeserializer) should
* probably be named as (*Validator) instead * probably be named as (*Validator) instead
* *
*/ */
@Component @Component
public final class ProductToGLAccountMappingFromApiJsonDeserializer { public final class ProductToGLAccountMappingFromApiJsonDeserializer {
@@ -207,7 +207,7 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()) baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue())
.value(incomeFromPenaltyId).notNull().integerGreaterThanZero(); .value(incomeFromPenaltyId).notNull().integerGreaterThanZero();
final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element); final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element);
if(null != isDormancyTrackingActive && isDormancyTrackingActive){ if(null != isDormancyTrackingActive && isDormancyTrackingActive){
final Long escheatLiabilityId = this.fromApiJsonHelper.extractLongNamed( final Long escheatLiabilityId = this.fromApiJsonHelper.extractLongNamed(
@@ -258,17 +258,17 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), element); SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue()) baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue())
.value(shareReferenceId).notNull().integerGreaterThanZero(); .value(shareReferenceId).notNull().integerGreaterThanZero();
final Long shareSuspenseId = this.fromApiJsonHelper.extractLongNamed( final Long shareSuspenseId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), element); SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue()) baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue())
.value(shareSuspenseId).notNull().integerGreaterThanZero(); .value(shareSuspenseId).notNull().integerGreaterThanZero();
final Long incomeFromFeeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeeAccountId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()) baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue())
.value(incomeFromFeeAccountId).notNull().integerGreaterThanZero(); .value(incomeFromFeeAccountId).notNull().integerGreaterThanZero();
final Long shareEquityId = this.fromApiJsonHelper.extractLongNamed( final Long shareEquityId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), element); SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue()) baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue())
@@ -212,7 +212,7 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
/** /**
* Examines and updates each account mapping for given loan product with * Examines and updates each account mapping for given loan product with
* changes passed in from the Json element * changes passed in from the Json element
* *
* @param loanProductId * @param loanProductId
* @param changes * @param changes
* @param element * @param element
@@ -129,7 +129,7 @@ public class ProductToGLAccountMappingHelper {
/** /**
* Saves the payment type to Fund source mappings for a particular * Saves the payment type to Fund source mappings for a particular
* product/product type (also populates the changes array if passed in) * product/product type (also populates the changes array if passed in)
* *
* @param command * @param command
* @param element * @param element
* @param productId * @param productId
@@ -156,7 +156,7 @@ public class ProductToGLAccountMappingHelper {
/** /**
* Saves the Charge to Income / Liability account mappings for a particular * Saves the Charge to Income / Liability account mappings for a particular
* product/product type (also populates the changes array if passed in) * product/product type (also populates the changes array if passed in)
* *
* @param command * @param command
* @param element * @param element
* @param productId * @param productId
@@ -242,7 +242,7 @@ public class ProductToGLAccountMappingHelper {
* as a part of Jsoncommand)<br/> * as a part of Jsoncommand)<br/>
* Create new mappings for charges that are passed in as a part of * Create new mappings for charges that are passed in as a part of
* the Jsoncommand but not already present * the Jsoncommand but not already present
* *
**/ **/
else { else {
for (final ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) { for (final ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) {
@@ -328,7 +328,7 @@ public class ProductToGLAccountMappingHelper {
* as a part of Jsoncommand)<br/> * as a part of Jsoncommand)<br/>
* Create new mappings for payment types that are passed in as a * Create new mappings for payment types that are passed in as a
* part of the Jsoncommand but not already present * part of the Jsoncommand but not already present
* *
**/ **/
else { else {
for (final ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) { for (final ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
@@ -417,7 +417,7 @@ public class ProductToGLAccountMappingHelper {
/** /**
* Fetches account with a particular Id and throws and Exception it is not * Fetches account with a particular Id and throws and Exception it is not
* of the expected Account Category ('ASSET','liability' etc) * of the expected Account Category ('ASSET','liability' etc)
* *
* @param paramName * @param paramName
* @param expectedAccountType * @param expectedAccountType
* @param accountId * @param accountId
@@ -41,7 +41,7 @@ public interface ProductToGLAccountMappingReadPlatformService {
public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForSavingsProduct(final Long savingsProductId); public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForSavingsProduct(final Long savingsProductId);
public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForSavingsProduct(final Long savingsProductId); public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForSavingsProduct(final Long savingsProductId);
public Map<String, Object> fetchAccountMappingDetailsForShareProduct(final Long productId, final Integer accountingType); public Map<String, Object> fetchAccountMappingDetailsForShareProduct(final Long productId, final Integer accountingType);
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForShareProduct(final Long productId); public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForShareProduct(final Long productId);
@@ -225,7 +225,7 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), savingProductId, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue()); CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue());
final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element); final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element);
if(null != isDormancyTrackingActive && isDormancyTrackingActive){ if(null != isDormancyTrackingActive && isDormancyTrackingActive){
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
@@ -103,7 +103,7 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
createOrmergeProductToAccountMappingChanges(element, paramName, productId, accountTypeId, changes, createOrmergeProductToAccountMappingChanges(element, paramName, productId, accountTypeId, changes,
GLAccountType.LIABILITY, PortfolioProductType.SAVING); GLAccountType.LIABILITY, PortfolioProductType.SAVING);
} }
/*** Abstractions for payments channel related to savings products ***/ /*** Abstractions for payments channel related to savings products ***/
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId, public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
@@ -179,7 +179,7 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
/** /**
* Examines and updates each account mapping for given loan product with * Examines and updates each account mapping for given loan product with
* changes passed in from the Json element * changes passed in from the Json element
* *
* @param savingsProductId * @param savingsProductId
* @param changes * @param changes
* @param element * @param element
@@ -157,7 +157,7 @@ public class ShareProductToGLAccountMappingHelper extends ProductToGLAccountMapp
/** /**
* Examines and updates each account mapping for given loan product with * Examines and updates each account mapping for given loan product with
* changes passed in from the Json element * changes passed in from the Json element
* *
* @param sharesProductId * @param sharesProductId
* @param changes * @param changes
* @param element * @param element
@@ -25,11 +25,11 @@ import java.util.Set;
public interface ProvisioningEntriesApiConstants { public interface ProvisioningEntriesApiConstants {
public final static String JSON_DATE_PARAM = "date" ; public final static String JSON_DATE_PARAM = "date" ;
public final static String JSON_DATEFORMAT_PARAM = "dateFormat" ; public final static String JSON_DATEFORMAT_PARAM = "dateFormat" ;
public final static String JSON_LOCALE_PARAM = "locale" ; public final static String JSON_LOCALE_PARAM = "locale" ;
public final static String JSON_CREATEJOURNALENTRIES_PARAM = "createjournalentries" ; public final static String JSON_CREATEJOURNALENTRIES_PARAM = "createjournalentries" ;
public final static String PROVISIONINGENTRY_PARAM = "provisioningentry"; public final static String PROVISIONINGENTRY_PARAM = "provisioningentry";
@@ -27,17 +27,17 @@ public class LoanProductProvisioningEntryData {
private final Long officeId; private final Long officeId;
private final String officeName ; private final String officeName ;
private final String currencyCode; private final String currencyCode;
private final Long productId; private final Long productId;
private final String productName ; private final String productName ;
private final Long categoryId; private final Long categoryId;
private final String categoryName ; private final String categoryName ;
private final Long overdueInDays; private final Long overdueInDays;
private final BigDecimal percentage; private final BigDecimal percentage;
@@ -45,21 +45,21 @@ public class LoanProductProvisioningEntryData {
private final BigDecimal balance; private final BigDecimal balance;
private final BigDecimal amountreserved ; private final BigDecimal amountreserved ;
private final Long liablityAccount; private final Long liablityAccount;
private final String liabilityAccountCode ; private final String liabilityAccountCode ;
private final String liabilityAccountName ; private final String liabilityAccountName ;
private final Long expenseAccount; private final Long expenseAccount;
private final String expenseAccountCode ; private final String expenseAccountCode ;
private final String expenseAccountName ; private final String expenseAccountName ;
private final Long criteriaId ; private final Long criteriaId ;
public LoanProductProvisioningEntryData(final Long historyId, final Long officeId, final String currencyCode, final Long productId, public LoanProductProvisioningEntryData(final Long historyId, final Long officeId, final String currencyCode, final Long productId,
final Long categoryId, final Long overdueInDays, final BigDecimal percentage, final BigDecimal balance, Long liablityAccount, final Long categoryId, final Long overdueInDays, final BigDecimal percentage, final BigDecimal balance, Long liablityAccount,
Long expenseAccount, final Long criteriaId) { Long expenseAccount, final Long criteriaId) {
@@ -85,7 +85,7 @@ public class LoanProductProvisioningEntryData {
} }
public LoanProductProvisioningEntryData(final Long historyId, final Long officeId, final String officeName, final String currencyCode, final Long productId, public LoanProductProvisioningEntryData(final Long historyId, final Long officeId, final String officeName, final String currencyCode, final Long productId,
final String productName, final Long categoryId, final String categoryName, final Long overdueInDays, final BigDecimal amountReserved, final String productName, final Long categoryId, final String categoryName, final Long overdueInDays, final BigDecimal amountReserved,
Long liablityAccount, String liabilityAccountglCode, String liabilityAccountName, Long expenseAccount, String expenseAccountglCode, String expenseAccountName, final Long criteriaId) { Long liablityAccount, String liabilityAccountglCode, String liabilityAccountName, Long expenseAccount, String expenseAccountglCode, String expenseAccountName, final Long criteriaId) {
this.historyId = historyId; this.historyId = historyId;
this.officeId = officeId; this.officeId = officeId;
@@ -146,7 +146,7 @@ public class LoanProductProvisioningEntryData {
public String getCurrencyCode() { public String getCurrencyCode() {
return this.currencyCode; return this.currencyCode;
} }
public Long getCriteriaId() { public Long getCriteriaId() {
return this.criteriaId ; return this.criteriaId ;
} }
@@ -26,23 +26,23 @@ import java.util.Date;
public class ProvisioningEntryData { public class ProvisioningEntryData {
private Long id ; private Long id ;
private Boolean journalEntry ; private Boolean journalEntry ;
private Long createdById ; private Long createdById ;
private String createdUser ; private String createdUser ;
Date createdDate ; Date createdDate ;
Long modifiedById ; Long modifiedById ;
private String modifiedUser ; private String modifiedUser ;
private BigDecimal reservedAmount ; private BigDecimal reservedAmount ;
private Collection<LoanProductProvisioningEntryData> provisioningEntries ; private Collection<LoanProductProvisioningEntryData> provisioningEntries ;
public ProvisioningEntryData(final Long id, final Collection<LoanProductProvisioningEntryData> provisioningEntries) { public ProvisioningEntryData(final Long id, final Collection<LoanProductProvisioningEntryData> provisioningEntries) {
this.provisioningEntries = provisioningEntries ; this.provisioningEntries = provisioningEntries ;
this.id = id ; this.id = id ;
@@ -59,7 +59,7 @@ public class ProvisioningEntryData {
this.createdDate = createdDate ; this.createdDate = createdDate ;
this.reservedAmount = totalReservedAmount ; this.reservedAmount = totalReservedAmount ;
} }
public void setEntries(Collection<LoanProductProvisioningEntryData> provisioningEntries) { public void setEntries(Collection<LoanProductProvisioningEntryData> provisioningEntries) {
this.provisioningEntries = provisioningEntries ; this.provisioningEntries = provisioningEntries ;
} }
@@ -67,7 +67,7 @@ public class ProvisioningEntryData {
public Long getId() { public Long getId() {
return this.id ; return this.id ;
} }
public Date getCreatedDate() { public Date getCreatedDate() {
return this.createdDate ; return this.createdDate ;
} }
@@ -100,7 +100,7 @@ public class LoanProductProvisioningEntry extends AbstractPersistableCustom<Long
public void addReservedAmount(BigDecimal value) { public void addReservedAmount(BigDecimal value) {
this.reservedAmount = this.reservedAmount.add(value); this.reservedAmount = this.reservedAmount.add(value);
} }
public Office getOffice() { public Office getOffice() {
return this.office; return this.office;
} }
@@ -43,10 +43,10 @@ public class ProvisioningEntry extends AbstractPersistableCustom<Long> {
@Column(name = "journal_entry_created") @Column(name = "journal_entry_created")
private Boolean isJournalEntryCreated; private Boolean isJournalEntryCreated;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", orphanRemoval = true, fetch=FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", orphanRemoval = true, fetch=FetchType.EAGER)
private Set<LoanProductProvisioningEntry> provisioningEntries = new HashSet<>(); private Set<LoanProductProvisioningEntry> provisioningEntries = new HashSet<>();
@OneToOne @OneToOne
@JoinColumn(name = "createdby_id") @JoinColumn(name = "createdby_id")
private AppUser createdBy; private AppUser createdBy;
@@ -64,9 +64,9 @@ public class ProvisioningEntry extends AbstractPersistableCustom<Long> {
private Date lastModifiedDate; private Date lastModifiedDate;
protected ProvisioningEntry() { protected ProvisioningEntry() {
} }
public ProvisioningEntry(AppUser createdBy, Date createdDate, AppUser lastModifiedBy, Date lastModifiedDate, Set<LoanProductProvisioningEntry> provisioningEntries ) { public ProvisioningEntry(AppUser createdBy, Date createdDate, AppUser lastModifiedBy, Date lastModifiedDate, Set<LoanProductProvisioningEntry> provisioningEntries ) {
this.provisioningEntries = provisioningEntries ; this.provisioningEntries = provisioningEntries ;
this.createdBy = createdBy ; this.createdBy = createdBy ;
@@ -74,22 +74,22 @@ public class ProvisioningEntry extends AbstractPersistableCustom<Long> {
this.lastModifiedBy = lastModifiedBy ; this.lastModifiedBy = lastModifiedBy ;
this.lastModifiedDate = lastModifiedDate ; this.lastModifiedDate = lastModifiedDate ;
} }
public void setProvisioningEntries(Collection<LoanProductProvisioningEntry> provisioningEntries) { public void setProvisioningEntries(Collection<LoanProductProvisioningEntry> provisioningEntries) {
if(this.provisioningEntries == null) this.provisioningEntries = new HashSet<>(); if(this.provisioningEntries == null) this.provisioningEntries = new HashSet<>();
this.provisioningEntries.addAll(provisioningEntries) ; this.provisioningEntries.addAll(provisioningEntries) ;
} }
public Collection<LoanProductProvisioningEntry> getLoanProductProvisioningEntries() { public Collection<LoanProductProvisioningEntry> getLoanProductProvisioningEntries() {
return this.provisioningEntries ; return this.provisioningEntries ;
} }
public void setJournalEntryCreated(Boolean bool) { public void setJournalEntryCreated(Boolean bool) {
this.isJournalEntryCreated = bool ; this.isJournalEntryCreated = bool ;
} }
public Date getCreatedDate() { public Date getCreatedDate() {
return this.createdDate ; return this.createdDate ;
} }
} }
@@ -27,10 +27,10 @@ import org.springframework.data.repository.query.Param;
public interface ProvisioningEntryRepository extends JpaRepository<ProvisioningEntry, Long>, JpaSpecificationExecutor<ProvisioningEntry> { public interface ProvisioningEntryRepository extends JpaRepository<ProvisioningEntry, Long>, JpaSpecificationExecutor<ProvisioningEntry> {
//OPENJPA throws error if we use entry //OPENJPA throws error if we use entry
@Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = :createdDate") @Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = :createdDate")
ProvisioningEntry findByProvisioningEntryDate(@Param("createdDate") Date createdDate); ProvisioningEntry findByProvisioningEntryDate(@Param("createdDate") Date createdDate);
@Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = (select max(entry2.createdDate) from ProvisioningEntry entry2 where entry2.isJournalEntryCreated=true)") @Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = (select max(entry2.createdDate) from ProvisioningEntry entry2 where entry2.isJournalEntryCreated=true)")
ProvisioningEntry findExistingProvisioningEntryWithJournalEntries() ; ProvisioningEntry findExistingProvisioningEntryWithJournalEntries() ;
} }
@@ -32,7 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
public class ReCreateProvisioningEntryRequestCommandHandler implements NewCommandSourceHandler { public class ReCreateProvisioningEntryRequestCommandHandler implements NewCommandSourceHandler {
private final ProvisioningEntriesWritePlatformService provisioningEntriesWritePlatformService ; private final ProvisioningEntriesWritePlatformService provisioningEntriesWritePlatformService ;
@Autowired @Autowired
public ReCreateProvisioningEntryRequestCommandHandler( public ReCreateProvisioningEntryRequestCommandHandler(
final ProvisioningEntriesWritePlatformService provisioningEntriesWritePlatformService) { final ProvisioningEntriesWritePlatformService provisioningEntriesWritePlatformService) {

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