FINERACT-942 Remove bad logging pattern(Use of system.out) and added checkstyle

This commit is contained in:
thesmallstar
2020-05-16 18:13:43 +02:00
committed by Michael Vorburger ⛑️
parent 9ce72fe67b
commit 20e8a02294
87 changed files with 4231 additions and 3460 deletions
@@ -47,7 +47,13 @@
<property name="fileExtensions" value="java"/> <property name="fileExtensions" value="java"/>
</module> </module>
--> -->
<module name="TreeWalker"> <module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="System\.(out)|(err)\.print(ln)?\("/>
<property name="message" value="Line contains console output."/>
<property name="ignoreComments" value="false" />
</module>
<module name="EqualsHashCode"/> <module name="EqualsHashCode"/>
<module name="RedundantImport"/> <module name="RedundantImport"/>
@@ -84,12 +90,6 @@
<property name="forbiddenImportsExcludesRegexp" value="" /> <property name="forbiddenImportsExcludesRegexp" value="" />
<message key="forbid.certain.imports" value="Use ''java.nio.charset.StandardCharsets'' instead of ''{0}''" /> <message key="forbid.certain.imports" value="Use ''java.nio.charset.StandardCharsets'' instead of ''{0}''" />
</module> </module>
<module name="RegexpSinglelineJava">
<property name="format" value="System\.(out)|(err)\.print(ln)?\("/>
<property name="message" value="Line contains console output."/>
<property name="ignoreComments" value="false" />
</module>
<module name="RegexpSinglelineJava"> <module name="RegexpSinglelineJava">
<property name="format" value="\.printStackTrace?\("/> <property name="format" value="\.printStackTrace?\("/>
<property name="message" value="Line contains printStacktrace()."/> <property name="message" value="Line contains printStacktrace()."/>
@@ -43,9 +43,12 @@ import org.apache.fineract.integrationtests.common.system.CodeHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AccountNumberPreferencesTest { public class AccountNumberPreferencesTest {
private final static Logger LOG = LoggerFactory.getLogger(AccountNumberPreferencesTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification responseValidationError; private ResponseSpecification responseValidationError;
@@ -149,10 +152,10 @@ public class AccountNumberPreferencesTest {
Integer id = (Integer) preferenceId.get("id"); Integer id = (Integer) preferenceId.get("id");
HashMap<String, Object> delResponse = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(id, this.responseSpec, HashMap<String, Object> delResponse = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(id, this.responseSpec,
""); "");
System.out.println("Successfully deleted account number preference (ID: " + delResponse.get("resourceId") + ")"); LOG.info("Successfully deleted account number preference (ID: {} )",delResponse.get("resourceId"));
} }
/* Deletion of invalid account preference ID should fail */ /* Deletion of invalid account preference ID should fail */
System.out.println("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE WITH INVALID ID------------------------------------------"); LOG.info("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE WITH INVALID ID------------------------------------------");
HashMap<String, Object> deletionError = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(10, HashMap<String, Object> deletionError = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(10,
this.responseNotFoundError, ""); this.responseNotFoundError, "");
@@ -179,23 +182,23 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreference() { private void createAccountNumberPreference() {
this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference( this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Client (ID: " + this.clientAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Client (ID: {})",this.clientAccountNumberPreferenceId);
this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createLoanAccountNumberPreference( this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createLoanAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Loan (ID: " + this.loanAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Loan (ID: {} )", this.loanAccountNumberPreferenceId);
this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference( this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Savings (ID: " + this.savingsAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Savings (ID: {})" , this.savingsAccountNumberPreferenceId);
this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference( this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Groups (ID: " + this.groupsAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Groups (ID: {})" , this.groupsAccountNumberPreferenceId);
this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference( this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference(
this.responseSpec, "resourceId"); this.responseSpec, "resourceId");
System.out.println("Successfully created account number preferences for Center (ID: " + this.centerAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Center (ID: {})" ,this.centerAccountNumberPreferenceId);
this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId, this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId,
this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId, this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId,
@@ -208,7 +211,7 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) { private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) {
/* Creating account Preference with duplicate data should fail */ /* Creating account Preference with duplicate data should fail */
System.out.println("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH DUPLICATE DATA------------------------------------------"); LOG.info("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH DUPLICATE DATA------------------------------------------");
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData( HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData(
this.responseForbiddenError, accountType, prefixType, ""); this.responseForbiddenError, accountType, prefixType, "");
@@ -221,7 +224,7 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) { private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) {
/* Creating account Preference with invalid data should fail */ /* Creating account Preference with invalid data should fail */
System.out.println("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); LOG.info("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------");
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData( HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData(
this.responseValidationError, accountType, prefixType, ""); this.responseValidationError, accountType, prefixType, "");
@@ -241,14 +244,14 @@ public class AccountNumberPreferencesTest {
HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference( HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference(
this.clientAccountNumberPreferenceId, "101", this.responseSpec, ""); this.clientAccountNumberPreferenceId, "101", this.responseSpec, "");
System.out.println("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID " LOG.info("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID {}"
+ accountNumberPreferences.get("resourceId")); , accountNumberPreferences.get("resourceId"));
this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"), this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"),
this.responseSpec, this.requestSpec); this.responseSpec, this.requestSpec);
/* Update invalid account preference id should fail */ /* Update invalid account preference id should fail */
System.out.println("---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); LOG.info("---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------");
/* Invalid Account Type */ /* Invalid Account Type */
HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101", HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101",
@@ -380,20 +383,20 @@ public class AccountNumberPreferencesTest {
private void createLoanProduct() { private void createLoanProduct() {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount) final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod) .withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear().build(null); .withInterestRateFrequencyTypeAsYear().build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
System.out.println("Successfully created loan product (ID: " + this.loanProductId + ")"); LOG.info("Successfully created loan product (ID: {} )" , this.loanProductId);
} }
private void createAndValidateLoanEntity(Boolean isAccountPreferenceSetUp) { private void createAndValidateLoanEntity(Boolean isAccountPreferenceSetUp) {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
System.out.println("---------------------------------NEW LOAN APPLICATION------------------------------------------"); LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
.withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsMonths().withNumberOfRepayments(numberOfRepayments) .withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsMonths().withNumberOfRepayments(numberOfRepayments)
@@ -402,7 +405,7 @@ public class AccountNumberPreferencesTest {
.withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2") .withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2")
.build(this.clientId.toString(), this.loanProductId.toString(), null); .build(this.clientId.toString(), this.loanProductId.toString(), null);
System.out.println("Loan Application :" + loanApplicationJSON); LOG.info("Loan Application :{}" , loanApplicationJSON);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
String loanAccountNo = (String) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanId, String loanAccountNo = (String) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanId,
@@ -419,17 +422,17 @@ public class AccountNumberPreferencesTest {
this.loanProductId, "shortName"); this.loanProductId, "shortName");
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanShortName); this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanShortName);
} }
System.out.println("SUCCESSFULLY CREATED LOAN APPLICATION BASED ON ACCOUNT PREFERENCES (ID: " + this.loanId + ")"); LOG.info("SUCCESSFULLY CREATED LOAN APPLICATION BASED ON ACCOUNT PREFERENCES (ID: {} )",this.loanId );
} else { } else {
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, null); this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, null);
System.out.println("SUCCESSFULLY CREATED LOAN APPLICATION (ID: " + loanId + ")"); LOG.info("SUCCESSFULLY CREATED LOAN APPLICATION (ID: {} )",loanId);
} }
} }
private void createSavingsProduct() { private void createSavingsProduct() {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
@@ -446,7 +449,7 @@ public class AccountNumberPreferencesTest {
.withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance) .withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance)
.withMinimumOpenningBalance(this.MINIMUM_OPENING_BALANCE).build(); .withMinimumOpenningBalance(this.MINIMUM_OPENING_BALANCE).build();
this.savingsProductId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec); this.savingsProductId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec);
System.out.println("Sucessfully created savings product (ID: " + this.savingsProductId + ")"); LOG.info("Sucessfully created savings product (ID: {} )",this.savingsProductId);
} }
@@ -472,10 +475,10 @@ public class AccountNumberPreferencesTest {
String loanShortName = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "shortName"); String loanShortName = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "shortName");
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, loanShortName); this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, loanShortName);
} }
System.out.println("SUCCESSFULLY CREATED SAVINGS APPLICATION BASED ON ACCOUNT PREFERENCES (ID: " + this.loanId + ")"); LOG.info("SUCCESSFULLY CREATED SAVINGS APPLICATION BASED ON ACCOUNT PREFERENCES (ID: {} )",this.loanId);
} else { } else {
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, null); this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, null);
System.out.println("SUCCESSFULLY CREATED SAVINGS APPLICATION (ID: " + this.savingsId + ")"); LOG.info("SUCCESSFULLY CREATED SAVINGS APPLICATION (ID:{} )",this.savingsId);
} }
} }
} }
@@ -49,6 +49,8 @@ import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* JUnit Test Cases for Account Transfer for. * JUnit Test Cases for Account Transfer for.
@@ -56,6 +58,7 @@ import org.junit.Test;
@SuppressWarnings({ "rawtypes", "unused" }) @SuppressWarnings({ "rawtypes", "unused" })
public class AccountTransferTest { public class AccountTransferTest {
private final static Logger LOG = LoggerFactory.getLogger(AccountTransferTest.class);
public static final String MINIMUM_OPENING_BALANCE = "30000.0"; public static final String MINIMUM_OPENING_BALANCE = "30000.0";
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
public static final String ACCOUNT_TRANSFER_AMOUNT = "15000.0"; public static final String ACCOUNT_TRANSFER_AMOUNT = "15000.0";
@@ -443,7 +446,7 @@ public class AccountTransferTest {
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String minOpenningBalance, final Account... accounts) { final String minOpenningBalance, final Account... accounts) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
final String savingsProductJSON = savingsProductHelper // final String savingsProductJSON = savingsProductHelper //
.withInterestCompoundingPeriodTypeAsDaily() // .withInterestCompoundingPeriodTypeAsDaily() //
@@ -454,7 +457,7 @@ public class AccountTransferTest {
} }
private Integer createLoanProduct(final Account... accounts) { private Integer createLoanProduct(final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("8,000.00") // .withPrincipal("8,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -470,7 +473,7 @@ public class AccountTransferTest {
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("8,000.00") // .withPrincipal("8,000.00") //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -64,10 +64,12 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
public class AccountingScenarioIntegrationTest { public class AccountingScenarioIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class);
private static RequestSpecification requestSpec; private static RequestSpecification requestSpec;
private static ResponseSpecification responseSpec; private static ResponseSpecification responseSpec;
@@ -146,19 +148,19 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
System.out.println("Entries ......"); LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f; final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT), }; new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT), };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
System.out.println("CHECKING INCOME: ******************************************"); LOG.info("CHECKING INCOME: ******************************************");
final JournalEntry incomeJournalEntry = new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.CREDIT); final JournalEntry incomeJournalEntry = new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.CREDIT);
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.EXPECTED_DISBURSAL_DATE, incomeJournalEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.EXPECTED_DISBURSAL_DATE, incomeJournalEntry);
// MAKE 1 // MAKE 1
System.out.println("Repayment 1 ......"); LOG.info("Repayment 1 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
final float FIRST_INTEREST = 200.0f; final float FIRST_INTEREST = 200.0f;
final float FIRST_PRINCIPAL = 2000.0f; final float FIRST_PRINCIPAL = 2000.0f;
@@ -167,10 +169,10 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT),
new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
System.out.println("Repayment 1 Done......"); LOG.info("Repayment 1 Done......");
// REPAYMENT 2 // REPAYMENT 2
System.out.println("Repayment 2 ......"); LOG.info("Repayment 2 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
final float SECOND_AND_THIRD_INTEREST = 400.0f; final float SECOND_AND_THIRD_INTEREST = 400.0f;
final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST; final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST;
@@ -179,10 +181,10 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
System.out.println("Repayment 2 Done ......"); LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST // WAIVE INTEREST
System.out.println("Waive Interest ......"); LOG.info("Waive Interest ......");
this.loanTransactionHelper.waiveInterest(this.REPAYMENT_DATE[4], this.AMOUNT_TO_BE_WAIVE.toString(), loanID); this.loanTransactionHelper.waiveInterest(this.REPAYMENT_DATE[4], this.AMOUNT_TO_BE_WAIVE.toString(), loanID);
final JournalEntry waivedEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.CREDIT); final JournalEntry waivedEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.CREDIT);
@@ -190,41 +192,41 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT); final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT);
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry);
System.out.println("Waive Interest Done......"); LOG.info("Waive Interest Done......");
// REPAYMENT 3 // REPAYMENT 3
System.out.println("Repayment 3 ......"); LOG.info("Repayment 3 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
System.out.println("Repayment 3 Done ......"); LOG.info("Repayment 3 Done ......");
// REPAYMENT 4 // REPAYMENT 4
System.out.println("Repayment 4 ......"); LOG.info("Repayment 4 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
System.out.println("Repayment 4 Done ......"); LOG.info("Repayment 4 Done ......");
// Repayment 5 // Repayment 5
System.out.println("Repayment 5 ......"); LOG.info("Repayment 5 ......");
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry);
System.out.println("Repayment 5 Done ......"); LOG.info("Repayment 5 Done ......");
} }
private Integer createLoanProductWithUpfrontAccrualAccountingEnabled(final Account... accounts) { private Integer createLoanProductWithUpfrontAccrualAccountingEnabled(final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth() final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
@@ -234,7 +236,7 @@ public class AccountingScenarioIntegrationTest {
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()) final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString())
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths().withNumberOfRepayments(this.LP_REPAYMENTS) .withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths().withNumberOfRepayments(this.LP_REPAYMENTS)
.withRepaymentEveryAfter(this.LP_REPAYMENT_PERIOD).withRepaymentFrequencyTypeAsMonths() .withRepaymentEveryAfter(this.LP_REPAYMENT_PERIOD).withRepaymentFrequencyTypeAsMonths()
@@ -283,7 +285,7 @@ public class AccountingScenarioIntegrationTest {
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsID); HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsID);
assertEquals("Verifying Balance after Deposit", balance, summary.get("accountBalance")); assertEquals("Verifying Balance after Deposit", balance, summary.get("accountBalance"));
System.out.println("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------"); LOG.info("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------");
final JournalEntry[] assetAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, final JournalEntry[] assetAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT,
JournalEntry.TransactionType.DEBIT) }; JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liabililityAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, final JournalEntry[] liabililityAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT,
@@ -299,7 +301,7 @@ public class AccountingScenarioIntegrationTest {
summary = this.savingsAccountHelper.getSavingsSummary(savingsID); summary = this.savingsAccountHelper.getSavingsSummary(savingsID);
assertEquals("Verifying Balance after Withdrawal", balance, summary.get("accountBalance")); assertEquals("Verifying Balance after Withdrawal", balance, summary.get("accountBalance"));
System.out.println("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------"); LOG.info("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------");
final JournalEntry[] assetAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, final JournalEntry[] assetAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT,
JournalEntry.TransactionType.CREDIT) }; JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] liabililityAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, final JournalEntry[] liabililityAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT,
@@ -506,7 +508,7 @@ public class AccountingScenarioIntegrationTest {
} }
public static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) { public static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() // final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() //
.withInterestPostingPeriodTypeAsQuarterly() // .withInterestPostingPeriodTypeAsQuarterly() //
.withInterestCalculationPeriodTypeAsDailyBalance() // .withInterestCalculationPeriodTypeAsDailyBalance() //
@@ -515,7 +517,7 @@ public class AccountingScenarioIntegrationTest {
} }
private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) { private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) {
System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
final String fixedDepositProductJSON = fixedDepositProductHelper // final String fixedDepositProductJSON = fixedDepositProductHelper //
.withPeriodRangeChart()// .withPeriodRangeChart()//
@@ -525,7 +527,7 @@ public class AccountingScenarioIntegrationTest {
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom, private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom,
final String validTo, final String submittedOnDate, final String penalInterestType) { final String validTo, final String submittedOnDate, final String penalInterestType) {
System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper return this.fixedDepositAccountHelper
@@ -533,7 +535,7 @@ public class AccountingScenarioIntegrationTest {
} }
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) { private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) {
System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
final String recurringDepositProductJSON = recurringDepositProductHelper // final String recurringDepositProductJSON = recurringDepositProductHelper //
.withPeriodRangeChart()// .withPeriodRangeChart()//
@@ -543,7 +545,7 @@ public class AccountingScenarioIntegrationTest {
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom, private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate) { final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate) {
System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------");
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec)
// //
.withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate)
@@ -577,7 +579,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
System.out.println("Entries ......"); LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f; final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -592,7 +594,7 @@ public class AccountingScenarioIntegrationTest {
} }
// MAKE 1 // MAKE 1
System.out.println("Repayment 1 ......"); LOG.info("Repayment 1 ......");
final float FIRST_INTEREST = 200.0f; final float FIRST_INTEREST = 200.0f;
final float FIRST_PRINCIPAL = 2000.0f; final float FIRST_PRINCIPAL = 2000.0f;
final float FEE_PORTION = 0.0f; final float FEE_PORTION = 0.0f;
@@ -605,10 +607,10 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT),
new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
System.out.println("Repayment 1 Done......"); LOG.info("Repayment 1 Done......");
// REPAYMENT 2 // REPAYMENT 2
System.out.println("Repayment 2 ......"); LOG.info("Repayment 2 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
final float SECOND_AND_THIRD_INTEREST = 400.0f; final float SECOND_AND_THIRD_INTEREST = 400.0f;
final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST; final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST;
@@ -621,10 +623,10 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
System.out.println("Repayment 2 Done ......"); LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST // WAIVE INTEREST
System.out.println("Waive Interest ......"); LOG.info("Waive Interest ......");
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[4]), FIRST_INTEREST, this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[4]), FIRST_INTEREST,
FEE_PORTION, PENALTY_PORTION, loanID); FEE_PORTION, PENALTY_PORTION, loanID);
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[5]), FIRST_INTEREST, this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[5]), FIRST_INTEREST,
@@ -636,37 +638,37 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT); final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT);
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry);
System.out.println("Waive Interest Done......"); LOG.info("Waive Interest Done......");
// REPAYMENT 3 // REPAYMENT 3
System.out.println("Repayment 3 ......"); LOG.info("Repayment 3 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
System.out.println("Repayment 3 Done ......"); LOG.info("Repayment 3 Done ......");
// REPAYMENT 4 // REPAYMENT 4
System.out.println("Repayment 4 ......"); LOG.info("Repayment 4 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
System.out.println("Repayment 4 Done ......"); LOG.info("Repayment 4 Done ......");
// Repayment 5 // Repayment 5
System.out.println("Repayment 5 ......"); LOG.info("Repayment 5 ......");
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry);
System.out.println("Repayment 5 Done ......"); LOG.info("Repayment 5 Done ......");
} }
@Test @Test
@@ -694,7 +696,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
System.out.println("Entries ......"); LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f; final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -709,7 +711,7 @@ public class AccountingScenarioIntegrationTest {
} }
// MAKE 1 // MAKE 1
System.out.println("Repayment 1 ......"); LOG.info("Repayment 1 ......");
final float FIRST_INTEREST = 200.0f; final float FIRST_INTEREST = 200.0f;
final float FIRST_PRINCIPAL = 2000.0f; final float FIRST_PRINCIPAL = 2000.0f;
final float FEE_PORTION = 0.0f; final float FEE_PORTION = 0.0f;
@@ -724,7 +726,7 @@ public class AccountingScenarioIntegrationTest {
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f,
JournalEntry.TransactionType.CREDIT)); JournalEntry.TransactionType.CREDIT));
System.out.println("Repayment Done......"); LOG.info("Repayment Done......");
} }
@@ -783,7 +785,7 @@ public class AccountingScenarioIntegrationTest {
String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION))); String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION)));
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
System.out.println("Entries ......"); LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f; final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -902,7 +904,7 @@ public class AccountingScenarioIntegrationTest {
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION))); dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
System.out.println("Entries ......"); LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f; final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -946,7 +948,7 @@ public class AccountingScenarioIntegrationTest {
} }
private Integer createLoanProductWithPeriodicAccrualAccountingEnabled(final Account... accounts) { private Integer createLoanProductWithPeriodicAccrualAccountingEnabled(final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth() final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
@@ -979,7 +981,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
System.out.println("Entries ......"); LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f; final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -987,7 +989,7 @@ public class AccountingScenarioIntegrationTest {
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
// MAKE 1 // MAKE 1
System.out.println("Repayment 1 ......"); LOG.info("Repayment 1 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
final float FIRST_INTEREST = 200.0f; final float FIRST_INTEREST = 200.0f;
final float FIRST_PRINCIPAL = 2000.0f; final float FIRST_PRINCIPAL = 2000.0f;
@@ -996,13 +998,13 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT),
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
System.out.println("CHECKING INCOME: ******************************************"); LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1], new JournalEntry(FIRST_INTEREST, this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1], new JournalEntry(FIRST_INTEREST,
JournalEntry.TransactionType.CREDIT)); JournalEntry.TransactionType.CREDIT));
System.out.println("Repayment 1 Done......"); LOG.info("Repayment 1 Done......");
// REPAYMENT 2 // REPAYMENT 2
System.out.println("Repayment 2 ......"); LOG.info("Repayment 2 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
final float SECOND_AND_THIRD_INTEREST = 400.0f; final float SECOND_AND_THIRD_INTEREST = 400.0f;
final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST; final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST;
@@ -1011,13 +1013,13 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), }; new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
System.out.println("CHECKING INCOME: ******************************************"); LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2], new JournalEntry( this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2], new JournalEntry(
SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT)); SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT));
System.out.println("Repayment 2 Done ......"); LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST // WAIVE INTEREST
System.out.println("Waive Interest ......"); LOG.info("Waive Interest ......");
Integer transactionId = this.loanTransactionHelper.waiveInterestAndReturnTransactionId(this.REPAYMENT_DATE[4], Integer transactionId = this.loanTransactionHelper.waiveInterestAndReturnTransactionId(this.REPAYMENT_DATE[4],
this.AMOUNT_TO_BE_WAIVE.toString(), loanID); this.AMOUNT_TO_BE_WAIVE.toString(), loanID);
// waive of fees and interest are not considered in cash based // waive of fees and interest are not considered in cash based
@@ -1025,38 +1027,38 @@ public class AccountingScenarioIntegrationTest {
this.journalEntryHelper.ensureNoAccountingTransactionsWithTransactionId("L" + transactionId); this.journalEntryHelper.ensureNoAccountingTransactionsWithTransactionId("L" + transactionId);
// REPAYMENT 3 // REPAYMENT 3
System.out.println("Repayment 3 ......"); LOG.info("Repayment 3 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
System.out.println("Repayment 3 Done ......"); LOG.info("Repayment 3 Done ......");
// REPAYMENT 4 // REPAYMENT 4
System.out.println("Repayment 4 ......"); LOG.info("Repayment 4 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
System.out.println("Repayment 4 Done ......"); LOG.info("Repayment 4 Done ......");
// Repayment 5 // Repayment 5
System.out.println("Repayment 5 ......"); LOG.info("Repayment 5 ......");
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry);
System.out.println("Repayment 5 Done ......"); LOG.info("Repayment 5 Done ......");
} }
private Integer createLoanProductWithCashBasedAccountingEnabled(final Account... accounts) { private Integer createLoanProductWithCashBasedAccountingEnabled(final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth() final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
@@ -36,6 +36,8 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Test class for testing the integration of Batch API with custom batch * Test class for testing the integration of Batch API with custom batch
@@ -46,6 +48,7 @@ import org.junit.Test;
*/ */
public class BatchRequestsIntegrationTest { public class BatchRequestsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(BatchRequestsIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -88,7 +91,7 @@ public class BatchRequestsIntegrationTest {
for (Integer i = 0; i < clientsCount; i++) { for (Integer i = 0; i < clientsCount; i++) {
clientIDs[i] = ClientHelper.createClient(this.requestSpec, this.responseSpec); clientIDs[i] = ClientHelper.createClient(this.requestSpec, this.responseSpec);
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientIDs[i].toString()); groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientIDs[i].toString());
System.out.println("client " + clientIDs[i] + " has been added to the group " + groupID); LOG.info("client {} has been added to the group {}",clientIDs[i] , groupID);
} }
// Generate a random count of number of new loan products to be created // Generate a random count of number of new loan products to be created
@@ -38,9 +38,11 @@ import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CenterIntegrationTest { public class CenterIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(CenterIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -198,7 +200,7 @@ public class CenterIntegrationTest {
public void testStaffAssignmentDuringCenterCreation() { public void testStaffAssignmentDuringCenterCreation() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
System.out.println("--------------creating first staff with id-------------" + staffId); LOG.info("--------------creating first staff with id------------- {}" , staffId);
Assert.assertNotNull(staffId); Assert.assertNotNull(staffId);
final int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId); final int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId);
@@ -212,7 +214,7 @@ public class CenterIntegrationTest {
@Test @Test
public void testAssignStaffToCenter() { public void testAssignStaffToCenter() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
System.out.println("--------------creating first staff with id-------------" + staffId); LOG.info("--------------creating first staff with id------------- {}" , staffId);
Assert.assertNotNull(staffId); Assert.assertNotNull(staffId);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
@@ -233,7 +235,7 @@ public class CenterIntegrationTest {
@Test @Test
public void testUnassignStaffToCenter() { public void testUnassignStaffToCenter() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
System.out.println("--------------creating first staff with id-------------" + staffId); LOG.info("--------------creating first staff with id------------- {}" , staffId);
Assert.assertNotNull(staffId); Assert.assertNotNull(staffId);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
@@ -56,13 +56,15 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Client Savings Integration Test for checking Savings Application. * Client Savings Integration Test for checking Savings Application.
*/ */
@SuppressWarnings({ "rawtypes"}) @SuppressWarnings({ "rawtypes"})
public class ClientSavingsIntegrationTest { public class ClientSavingsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ClientSavingsIntegrationTest.class);
public static final String DEPOSIT_AMOUNT = "2000"; public static final String DEPOSIT_AMOUNT = "2000";
public static final String WITHDRAW_AMOUNT = "1000"; public static final String WITHDRAW_AMOUNT = "1000";
public static final String WITHDRAW_AMOUNT_ADJUSTED = "500"; public static final String WITHDRAW_AMOUNT_ADJUSTED = "500";
@@ -970,8 +972,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3); transactionDate.set(Calendar.DAY_OF_MONTH, 3);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
@@ -1007,8 +1008,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked-------");
.println("-----Post Interest As on Successfully Worked-------");
//DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); //DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar transactionCalendarDateFormat = Calendar.getInstance(); Calendar transactionCalendarDateFormat = Calendar.getInstance();
@@ -1047,8 +1047,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
} }
DateFormat lastTransactionDateFormat = new SimpleDateFormat( DateFormat lastTransactionDateFormat = new SimpleDateFormat(
"dd MMMM yyyy", Locale.US); "dd MMMM yyyy", Locale.US);
@@ -1091,8 +1090,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
} }
transactionDate.set(Calendar.DAY_OF_MONTH, 1); transactionDate.set(Calendar.DAY_OF_MONTH, 1);
@@ -1128,8 +1126,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
} }
@@ -1313,8 +1310,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3); transactionDate.set(Calendar.DAY_OF_MONTH, 3);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
@@ -1350,8 +1346,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked-------");
.println("-----Post Interest As on Successfully Worked-------");
//DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); //DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar transactionCalendarDateFormat = Calendar.getInstance(); Calendar transactionCalendarDateFormat = Calendar.getInstance();
@@ -1390,8 +1385,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
} }
DateFormat lastTransactionDateFormat = new SimpleDateFormat( DateFormat lastTransactionDateFormat = new SimpleDateFormat(
"dd MMMM yyyy", Locale.US); "dd MMMM yyyy", Locale.US);
@@ -1434,8 +1428,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
} }
transactionDate.set(Calendar.DAY_OF_MONTH, 1); transactionDate.set(Calendar.DAY_OF_MONTH, 1);
@@ -1471,8 +1464,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted)); decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted); accountDetailsPostInterestPosted);
System.out LOG.info("-----Post Interest As on Successfully Worked----------");
.println("-----Post Interest As on Successfully Worked----------");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -1619,7 +1611,7 @@ public class ClientSavingsIntegrationTest {
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
//actualInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted)); //actualInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted);
System.out.println("------Post Interest As On After doing a post interest Successfully worked--------"); LOG.info("------Post Interest As On After doing a post interest Successfully worked--------");
todaysDate = Calendar.getInstance(); todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
@@ -1706,7 +1698,7 @@ public class ClientSavingsIntegrationTest {
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); LOG.info("count Of Date---> {}",countOfDate);
postedLastDate.set(Calendar.DAY_OF_MONTH,countOfDate); postedLastDate.set(Calendar.DAY_OF_MONTH,countOfDate);
final String POSTED_LAST_TRANSACTION_DATE = dateFormat.format(postedLastDate.getTime()); final String POSTED_LAST_TRANSACTION_DATE = dateFormat.format(postedLastDate.getTime());
@@ -1786,7 +1778,7 @@ public class ClientSavingsIntegrationTest {
interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
actualInterestPosted = Float.valueOf(decimalFormat.format(actualInterestPosted)); actualInterestPosted = Float.valueOf(decimalFormat.format(actualInterestPosted));
assertEquals("Verifying interest posted", interestPosted, actualInterestPosted); assertEquals("Verifying interest posted", interestPosted, actualInterestPosted);
System.out.println("------Post Interest As On Successful Worked--------"); LOG.info("------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);
@@ -1806,7 +1798,7 @@ public class ClientSavingsIntegrationTest {
interestLastPosted = Float.valueOf(decimalLastFormat.format(interestLastPosted)); interestLastPosted = Float.valueOf(decimalLastFormat.format(interestLastPosted));
actualInterestPosted = Float.valueOf(decimalFormat.format(actualInterestPosted)); actualInterestPosted = Float.valueOf(decimalFormat.format(actualInterestPosted));
assertEquals("Verifying interest posted", interestLastPosted, actualInterestPosted); assertEquals("Verifying interest posted", interestLastPosted, actualInterestPosted);
System.out.println("------Post Interest As On Successful Worked--------"); LOG.info("------Post Interest As On Successful Worked--------");
} }
@@ -2070,7 +2062,7 @@ public class ClientSavingsIntegrationTest {
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) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
if (allowOverdraft) { if (allowOverdraft) {
final String overDraftLimit = "2000.0"; final String overDraftLimit = "2000.0";
@@ -2104,7 +2096,7 @@ public class ClientSavingsIntegrationTest {
/* /*
* private void verifySavingsInterest(final Object savingsInterest) { * private void verifySavingsInterest(final Object savingsInterest) {
* System.out.println( * LOG.info(
* "--------------------VERIFYING THE BALANCE, INTEREST --------------------------" * "--------------------VERIFYING THE BALANCE, INTEREST --------------------------"
* ); * );
* *
@@ -21,41 +21,49 @@ package org.apache.fineract.integrationtests;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.util.HashMap; import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ClientStatusChecker { public class ClientStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(ClientStatusChecker.class);
public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) {
assertEquals((int) clientStatusHashMap.get("id"), 300); assertEquals((int) clientStatusHashMap.get("id"), 300);
} }
public static void verifyClientClosed(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientClosed(final HashMap<String, Object> clientStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
assertEquals((int) clientStatusHashMap.get("id"), 600); assertEquals((int) clientStatusHashMap.get("id"), 600);
System.out.println("Client Status:" + clientStatusHashMap + "\n"); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientPending(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientPending(final HashMap<String, Object> clientStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
assertEquals((int) clientStatusHashMap.get("id"), 100); assertEquals((int) clientStatusHashMap.get("id"), 100);
System.out.println("Client Status:" + clientStatusHashMap + "\n"); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientRejected(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientRejected(final HashMap<String, Object> clientStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
assertEquals((int) clientStatusHashMap.get("id"), 700); assertEquals((int) clientStatusHashMap.get("id"), 700);
System.out.println("Client Status:" + clientStatusHashMap + "\n"); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientActiavted(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientActiavted(final HashMap<String, Object> clientStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
assertEquals((int) clientStatusHashMap.get("id"), 300); assertEquals((int) clientStatusHashMap.get("id"), 300);
System.out.println("Client Status:" + clientStatusHashMap + "\n"); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientWithdrawn(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientWithdrawn(final HashMap<String, Object> clientStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
assertEquals((int) clientStatusHashMap.get("id"), 800); assertEquals((int) clientStatusHashMap.get("id"), 800);
System.out.println("Client Status:" + clientStatusHashMap + "\n"); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
} }
@@ -37,9 +37,11 @@ import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConcurrencyIntegrationTest { public class ConcurrencyIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ConcurrencyIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -73,7 +75,7 @@ public class ConcurrencyIntegrationTest {
date.set(2011, 9, 20); date.set(2011, 9, 20);
Float repaymentAmount = 100.0f; Float repaymentAmount = 100.0f;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
System.out.println("Starting concurrent transaction number " + i); LOG.info("Starting concurrent transaction number {}" , i);
date.add(Calendar.DAY_OF_MONTH, 1); date.add(Calendar.DAY_OF_MONTH, 1);
repaymentAmount = repaymentAmount + 100; repaymentAmount = repaymentAmount + 100;
Runnable worker = new LoanRepaymentExecutor(loanTransactionHelper, loanID, repaymentAmount, date); Runnable worker = new LoanRepaymentExecutor(loanTransactionHelper, loanID, repaymentAmount, date);
@@ -85,12 +87,12 @@ public class ConcurrencyIntegrationTest {
while (!executor.isTerminated()) { while (!executor.isTerminated()) {
} }
System.out.println("\nFinished all threads"); LOG.info("\nFinished all threads");
} }
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() // LoanProductTestBuilder builder = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -111,7 +113,7 @@ public class ConcurrencyIntegrationTest {
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) // .withPrincipal(principal) //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -150,13 +152,12 @@ public class ConcurrencyIntegrationTest {
try { try {
this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId); this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId);
} catch (Exception e) { } catch (Exception e) {
System.out.println("Found an exception" + e.getMessage()); LOG.info("Found an exception {}" , e.getMessage());
System.out.println("Details of failed concurrent transaction (date, amount, loanId) are " + repaymentDate + "," LOG.info("Details of failed concurrent transaction (date, amount, loanId) are {},{},{}" , repaymentDate, repaymentAmount , loanId);
+ repaymentAmount + "," + loanId);
throw (e); throw (e);
} }
System.out.println("Details of passed concurrent transaction, details (date, amount, loanId) are " + repaymentDate + "," LOG.info("Details of passed concurrent transaction, details (date, amount, loanId) are {},{},{}" , repaymentDate
+ repaymentAmount + "," + loanId); , repaymentAmount , loanId);
} }
} }
@@ -53,321 +53,362 @@ import org.junit.Test;
@Ignore @Ignore
public class DisbursalAndRepaymentScheduleTest { public class DisbursalAndRepaymentScheduleTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403; private ResponseSpecification responseSpecForStatusCode403;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
private LoanRescheduleRequestHelper loanRescheduleRequestHelper; private LoanRescheduleRequestHelper loanRescheduleRequestHelper;
private Integer loanRescheduleRequestId; private Integer loanRescheduleRequestId;
private Integer clientId; private Integer clientId;
private Integer groupId; private Integer groupId;
private Integer groupCalendarId; private Integer groupCalendarId;
private Integer loanProductId; private Integer loanProductId;
private Integer loanId; private Integer loanId;
private final String loanPrincipalAmount = "100000.00"; private final String loanPrincipalAmount = "100000.00";
private final String numberOfRepayments = "12"; private final String numberOfRepayments = "12";
private final String interestRatePerPeriod = "18"; private final String interestRatePerPeriod = "18";
private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy"); private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy");
@Before @Before
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
}
@Test
public void testRescheduleJLGLoanSynk() {
System.out.println("---------------------------------STARTING RESCHEDULE JLG LOAN TEST ------------------------------------------");
Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
int today = meetingCalendar.get(Calendar.DAY_OF_WEEK);
// making sure that the meeting calendar is set for the coming monday.
if (today >= Calendar.MONDAY) {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
} else {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
} }
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); @Test
public void testRescheduleJLGLoanSynk() {
// system.out.println("---------------------------------STARTING RESCHEDULE JLG
// LOAN TEST ------------------------------------------");
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3); Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime()); int today = meetingCalendar.get(Calendar.DAY_OF_WEEK);
// making sure that the meeting calendar is set for the coming monday.
if (today >= Calendar.MONDAY) {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
} else {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
}
final String disbursalDate = groupMeetingDate; // first meeting date Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
// after group creation
final String rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date()); meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
final String loanType = "jlg"; final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
final String rescheduleInterestRate = "28.0";
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
final String groupMeetingNewStartDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
// The date
// from
// which we
// start the
// new group
// meeting
// occasion,
// this is a
// tuesday.
groupMeetingChangeCalendar.add(Calendar.WEEK_OF_YEAR, 2);
final String rescheduleDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); final String disbursalDate = groupMeetingDate; // first meeting date
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); // after group creation
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); final String rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date());
System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24") final String loanType = "jlg";
.withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2") final String rescheduleInterestRate = "28.0";
.withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate) final String groupMeetingNewStartDate = this.dateFormatterStandard
.withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin() .format(groupMeetingChangeCalendar.getTime());
.withCalendarID(this.groupCalendarId.toString()) // The date
.build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null); // from
// which we
// start the
// new group
// meeting
// occasion,
// this is a
// tuesday.
groupMeetingChangeCalendar.add(Calendar.WEEK_OF_YEAR, 2);
final String rescheduleDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
// Test for loan account is created this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
Assert.assertNotNull(this.loanId); // system.out.println("---------------------------------CREATING ENTITIES AND
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); // JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
.withLoanTermFrequency("24").withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12")
.withRepaymentEveryAfter("2").withRepaymentFrequencyTypeAsMonths()
.withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks()
.withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate)
.withLoanType(loanType).withSyncDisbursementWithMeetin()
.withCalendarID(this.groupCalendarId.toString()).build(this.clientId.toString(),
this.groupId.toString(), this.loanProductId.toString(), null);
// Test for loan account is created, can be approved this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
// Test for loan account approved can be disbursed // Test for loan account is created
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); Assert.assertNotNull(this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec,
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); this.loanId);
System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(),
groupMeetingNewStartDate, "2", "2", "2"); // New meeting dates
// will be the tuesday
// after the
// coming
// monday
ArrayList loanRepaymnetSchedule = this.loanTransactionHelper // Test for loan account is created, can be approved
.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId); this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); // Test for loan account approved can be disbursed
Calendar dueDateCalendar = Calendar.getInstance(); this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
(Integer) dueDateLoanSchedule.get(2));
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY", 3, dueDateCalendar.get(Calendar.DAY_OF_WEEK));
System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------"); // system.out.println("---------------------------------CHANGING GROUP MEETING
// DATE ------------------------------------------");
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId,
this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New
// meeting
// dates
// will be
// the
// tuesday
// after the
// coming
// monday
String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2").updateGraceOnPrincipal("2") ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
.updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate) generalResponseSpec, this.loanId);
.updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString());
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON); ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId); Calendar dueDateCalendar = Calendar.getInstance();
dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY);
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2));
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY", 3,
dueDateCalendar.get(Calendar.DAY_OF_WEEK));
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId); // system.out.println("---------------------------------CREATING LOAN RESCHEDULE
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); // REQUEST------------------------------------------");
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2));
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT", 3,
dueDateCalendar.get(Calendar.DAY_OF_WEEK));
System.out.println("Successfully created loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2")
.updateGraceOnPrincipal("2").updateNewInterestRate(rescheduleInterestRate)
.updateRescheduleFromDate(rescheduleDate).updateSubmittedOnDate(rescheduleSubmittedDate)
.build(this.loanId.toString());
System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------"); this.loanRescheduleRequestId = this.loanRescheduleRequestHelper
.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate) loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
.getApproveLoanRescheduleRequestJSON(); generalResponseSpec, this.loanId);
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2));
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT",
3, dueDateCalendar.get(Calendar.DAY_OF_WEEK));
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); // system.out.println("Successfully created loan reschedule request (ID: " +
assertTrue((Boolean) response.get("approved")); // this.loanRescheduleRequestId + ")");
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId); // system.out.println("-----------------------------APPROVING LOAN RESCHEDULE
// REQUEST--------------------------");
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate)
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, .getApproveLoanRescheduleRequestJSON();
(Integer) dueDateLoanSchedule.get(2)); this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId,
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE", 3, requestJSON);
dueDateCalendar.get(Calendar.DAY_OF_WEEK));
System.out.println("Successfully changed group meeting date (CAELNDAR ID: " + this.groupCalendarId
+ ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId + ")");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403); final HashMap response = (HashMap) this.loanRescheduleRequestHelper
} .getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean) response.get("approved"));
@Test loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
public void testChangeGroupMeetingMaturedOnDate() { generalResponseSpec, this.loanId);
System.out
.println("---------------------------------STARTING GROUP LOAN MEETING CHANGE DATE EXPECTED MATURED CHANGE------------------------------------------");
Calendar meetingCalendar = Calendar.getInstance(); dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
meetingCalendar.setTime(new java.util.Date()); (Integer) dueDateLoanSchedule.get(2));
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE",
3, dueDateCalendar.get(Calendar.DAY_OF_WEEK));
// system.out.println("Successfully changed group meeting date (CAELNDAR ID: " +
// this.groupCalendarId
// + ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId +
// ")");
int today = meetingCalendar.get(Calendar.DAY_OF_WEEK); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec,
// making sure that the meeting calendar is set for the coming monday. this.responseSpecForStatusCode403);
if (today >= Calendar.MONDAY) {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
} else {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
} }
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); @Test
public void testChangeGroupMeetingMaturedOnDate() {
// system.out
// .println("---------------------------------STARTING GROUP LOAN MEETING CHANGE
// DATE EXPECTED MATURED CHANGE------------------------------------------");
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3); Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime()); int today = meetingCalendar.get(Calendar.DAY_OF_WEEK);
// making sure that the meeting calendar is set for the coming monday.
if (today >= Calendar.MONDAY) {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
} else {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
}
final String disbursalDate = groupMeetingDate; // first meeting date Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
// after group creation
final String loanType = "jlg"; meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
final String groupMeetingNewStartDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
// The date
// from
// which we
// start the
// new group
// meeting
// occasion,
// this is a
// tuesday.
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); final String disbursalDate = groupMeetingDate; // first meeting date
System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------"); // after group creation
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24") final String loanType = "jlg";
.withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2") groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
.withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() final String groupMeetingNewStartDate = this.dateFormatterStandard
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate) .format(groupMeetingChangeCalendar.getTime());
.withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin() // The date
.withCalendarID(this.groupCalendarId.toString()) // from
.build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null); // which we
// start the
// new group
// meeting
// occasion,
// this is a
// tuesday.
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
// Test for loan account is created this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
Assert.assertNotNull(this.loanId); // system.out.println("---------------------------------CREATING ENTITIES AND
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); // JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
.withLoanTermFrequency("24").withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12")
.withRepaymentEveryAfter("2").withRepaymentFrequencyTypeAsMonths()
.withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks()
.withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate)
.withLoanType(loanType).withSyncDisbursementWithMeetin()
.withCalendarID(this.groupCalendarId.toString()).build(this.clientId.toString(),
this.groupId.toString(), this.loanProductId.toString(), null);
// Test for loan account is created, can be approved this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
// Test for loan account approved can be disbursed // Test for loan account is created
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); Assert.assertNotNull(this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec,
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); this.loanId);
System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(),
groupMeetingNewStartDate, "2", "2", "2"); // New meeting dates
// will be the tuesday
// after the
// coming
// monday
Calendar expectedMaturityCalendar = Calendar.getInstance(); // Test for loan account is created, can be approved
expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY); this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
this.loanId, "timeline")).get("expectedMaturityDate")); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), (Integer) expectedMaturityDate.get(1) - 1, // Test for loan account approved can be disbursed
(Integer) expectedMaturityDate.get(2)); this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
assertEquals("AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY", 3, // system.out.println("---------------------------------CHANGING GROUP MEETING
expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK)); // DATE ------------------------------------------");
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId,
this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New
// meeting
// dates
// will be
// the
// tuesday
// after the
// coming
// monday
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403); Calendar expectedMaturityCalendar = Calendar.getInstance();
} expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY);
ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper
.getLoanDetail(requestSpec, generalResponseSpec, this.loanId, "timeline"))
.get("expectedMaturityDate"));
/** expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0),
* entities for jlg loan (Integer) expectedMaturityDate.get(1) - 1, (Integer) expectedMaturityDate.get(2));
**/
private void createRequiredEntitiesForJLGLoanSync(final String groupActivationDate) {
this.createGroupEntityWithCalendar("2", "2", "1", groupActivationDate);// frequency=2:Weekly
// , interval=2:
// Every two weeks ,
// repeatsOnDay=1:Monday
// groupActivationDate is decided by the current date
this.createClientEntity();
this.associateClientToGroup(this.groupId, this.clientId);
this.createLoanProductEntity();
} assertEquals("AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY", 3,
expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK));
/* this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec,
* Associate client to the group this.responseSpecForStatusCode403);
*/ }
private void associateClientToGroup(final Integer groupId, final Integer clientId) { /**
GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString()); * entities for jlg loan
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId); **/
} private void createRequiredEntitiesForJLGLoanSync(final String groupActivationDate) {
this.createGroupEntityWithCalendar("2", "2", "1", groupActivationDate);// frequency=2:Weekly
// , interval=2:
// Every two weeks ,
// repeatsOnDay=1:Monday
// groupActivationDate is decided by the current date
this.createClientEntity();
this.associateClientToGroup(this.groupId, this.clientId);
this.createLoanProductEntity();
private void createGroupEntityWithCalendar(final String frequency, final String interval, final String repeatsOnDay, }
final String groupActivationDate) {
this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate);
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId);
final String startDate = groupActivationDate; /*
* Associate client to the group
*/
this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, startDate, private void associateClientToGroup(final Integer groupId, final Integer clientId) {
frequency, interval, repeatsOnDay)); GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(),
} clientId.toString());
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId);
}
/** private void createGroupEntityWithCalendar(final String frequency, final String interval,
* create a new client final String repeatsOnDay, final String groupActivationDate) {
**/ this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate);
private void createClientEntity() { GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId);
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId);
}
/** final String startDate = groupActivationDate;
* create a new loan product
**/
private void createLoanProductEntity() {
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear().build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
public void setGroupCalendarId(Integer groupCalendarId) { this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec,
this.groupCalendarId = groupCalendarId; this.responseSpec, this.groupId, startDate, frequency, interval, repeatsOnDay));
} }
/**
* create a new client
**/
private void createClientEntity() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId);
}
/**
* create a new loan product
**/
private void createLoanProductEntity() {
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments)
.withinterestRatePerPeriod(interestRatePerPeriod).withInterestRateFrequencyTypeAsYear()
.build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
public void setGroupCalendarId(Integer groupCalendarId) {
this.groupCalendarId = groupCalendarId;
}
} }
@@ -30,10 +30,12 @@ import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
public class ExternalServicesConfigurationTest { public class ExternalServicesConfigurationTest {
private final static Logger LOG = LoggerFactory.getLogger(ExternalServicesConfigurationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ExternalServicesConfigurationHelper externalServicesConfigurationHelper; private ExternalServicesConfigurationHelper externalServicesConfigurationHelper;
@@ -67,7 +69,7 @@ public class ExternalServicesConfigurationTest {
value = "testnull"; value = "testnull";
} }
String newValue = "test"; String newValue = "test";
System.out.println(name + ":" + value); LOG.info( "{} : {}",name, value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec, HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "S3", name, newValue); responseSpec, "S3", name, newValue);
Assert.assertNotNull(arrayListValue.get("value")); Assert.assertNotNull(arrayListValue.get("value"));
@@ -95,7 +97,7 @@ public class ExternalServicesConfigurationTest {
value = "testnull"; value = "testnull";
} }
String newValue = "test"; String newValue = "test";
System.out.println(name + ":" + value); LOG.info("{} : {}",name,value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec, HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "SMTP", name, newValue); responseSpec, "SMTP", name, newValue);
Assert.assertNotNull(arrayListValue.get("value")); Assert.assertNotNull(arrayListValue.get("value"));
@@ -63,10 +63,12 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" }) @SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" })
public class FixedDepositTest { public class FixedDepositTest {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private FixedDepositProductHelper fixedDepositProductHelper; private FixedDepositProductHelper fixedDepositProductHelper;
@@ -1224,7 +1226,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE); todaysDate.getActualMaximum(Calendar.DATE);
@@ -1236,7 +1238,7 @@ public class FixedDepositTest {
decimalFormat.applyPattern("."); decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal)); principal = Float.valueOf(decimalFormat.format(principal));
maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount));
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount);
} }
@@ -1298,7 +1300,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE); todaysDate.getActualMaximum(Calendar.DATE);
@@ -1309,7 +1311,7 @@ public class FixedDepositTest {
decimalFormat.applyPattern("."); decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal)); principal = Float.valueOf(decimalFormat.format(principal));
maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount));
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount);
} }
@@ -1376,7 +1378,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1); todaysDate.add(Calendar.MONTH, -1);
@@ -1387,12 +1389,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth; principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth); todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime())); LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE); CLOSED_ON_DATE);
@@ -1484,7 +1486,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}", perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1); todaysDate.add(Calendar.MONTH, -1);
@@ -1495,12 +1497,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth; principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth); todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime())); LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE); CLOSED_ON_DATE);
@@ -1597,7 +1599,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1); todaysDate.add(Calendar.MONTH, -1);
@@ -1608,12 +1610,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth; principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth); todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime())); LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE); CLOSED_ON_DATE);
@@ -1713,7 +1715,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1); todaysDate.add(Calendar.MONTH, -1);
@@ -1724,12 +1726,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth; principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth); todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime())); LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE); CLOSED_ON_DATE);
@@ -1812,7 +1814,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE); todaysDate.getActualMaximum(Calendar.DATE);
@@ -1824,7 +1826,7 @@ public class FixedDepositTest {
decimalFormat.applyPattern("."); decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal)); principal = Float.valueOf(decimalFormat.format(principal));
maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount));
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount);
} }
@@ -1853,7 +1855,7 @@ public class FixedDepositTest {
dateFormat.format(todaysDate.getTime()); dateFormat.format(todaysDate.getTime());
monthDayFormat.format(todaysDate.getTime()); monthDayFormat.format(todaysDate.getTime());
System.out.println("Submitted Date:" + SUBMITTED_ON_DATE); LOG.info("Submitted Date: {}" , SUBMITTED_ON_DATE);
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assert.assertNotNull(clientId); Assert.assertNotNull(clientId);
@@ -1889,7 +1891,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE); todaysDate.getActualMaximum(Calendar.DATE);
@@ -1899,7 +1901,7 @@ public class FixedDepositTest {
principal = new BigDecimal(principal).setScale(0, RoundingMode.FLOOR).floatValue(); principal = new BigDecimal(principal).setScale(0, RoundingMode.FLOOR).floatValue();
maturityAmount = new BigDecimal(maturityAmount).setScale(0, RoundingMode.FLOOR).floatValue(); maturityAmount = new BigDecimal(maturityAmount).setScale(0, RoundingMode.FLOOR).floatValue();
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount);
} }
@@ -1925,7 +1927,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -1971,7 +1973,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2009,7 +2011,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2055,7 +2057,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2094,7 +2096,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2137,7 +2139,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2176,7 +2178,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2219,7 +2221,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" ,perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2258,7 +2260,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2301,7 +2303,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2339,7 +2341,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2382,7 +2384,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2400,7 +2402,7 @@ public class FixedDepositTest {
private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule, private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule,
Account... accounts) { Account... accounts) {
System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts); fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -2415,7 +2417,7 @@ public class FixedDepositTest {
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts); fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -2430,7 +2432,7 @@ public class FixedDepositTest {
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts); fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -2461,7 +2463,7 @@ public class FixedDepositTest {
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate, private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate,
final String penalInterestType) { final String penalInterestType) {
System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper return this.fixedDepositAccountHelper
@@ -2470,7 +2472,7 @@ public class FixedDepositTest {
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate, private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate,
final String penalInterestType, final String depositAmount, final String depositPeriod) { final String penalInterestType, final String depositAmount, final String depositPeriod) {
System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec)
// //
.withSubmittedOnDate(submittedOnDate).withDepositPeriod(depositPeriod).withDepositAmount(depositAmount) .withSubmittedOnDate(submittedOnDate).withDepositPeriod(depositPeriod).withDepositAmount(depositAmount)
@@ -2481,7 +2483,7 @@ public class FixedDepositTest {
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String minOpenningBalance, final String accountingRule, Account... accounts) { final String minOpenningBalance, final String accountingRule, Account... accounts) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
@@ -39,10 +39,12 @@ import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unused", "unchecked" }) @SuppressWarnings({ "rawtypes", "unused", "unchecked" })
public class FlexibleSavingsInterestPostingIntegrationTest { public class FlexibleSavingsInterestPostingIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class);
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -84,7 +86,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions"); ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2); HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
for (Entry<String, Object> entry : interestPostingTransaction.entrySet()) for (Entry<String, Object> entry : interestPostingTransaction.entrySet())
System.out.println(entry.getKey() + "-" + entry.getValue().toString()); LOG.info("{} - {}",entry.getKey(), entry.getValue().toString());
// 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily // 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily
// balance // balance
// 33.7016 obtained from formula in excel provided by Subramanya // 33.7016 obtained from formula in excel provided by Subramanya
@@ -37,13 +37,15 @@ import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Group Test for checking Group: Creation, Activation, Client Association, * Group Test for checking Group: Creation, Activation, Client Association,
* Updating & Deletion * Updating & Deletion
*/ */
public class GroupTest { public class GroupTest {
private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -107,11 +109,11 @@ public class GroupTest {
// create staff // create staff
Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec); Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
System.out.println("--------------creating first staff with id-------------" + createStaffId1); LOG.info("--------------creating first staff with id------------- {}" , createStaffId1);
Assert.assertNotNull(createStaffId1); Assert.assertNotNull(createStaffId1);
Integer createStaffId2 = StaffHelper.createStaff(this.requestSpec, this.responseSpec); Integer createStaffId2 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
System.out.println("--------------creating second staff with id-------------" + createStaffId2); LOG.info("--------------creating second staff with id------------- {}" , createStaffId2);
Assert.assertNotNull(createStaffId2); Assert.assertNotNull(createStaffId2);
// assign staff "createStaffId1" to group // assign staff "createStaffId1" to group
@@ -155,7 +157,7 @@ public class GroupTest {
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) // .withPrincipal(principal) //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -36,9 +36,11 @@ import org.apache.http.conn.HttpHostConnectException;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HookIntegrationTest { public class HookIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(HookIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -77,7 +79,7 @@ public class HookIntegrationTest {
final Integer notificationOfficeId = JsonPath.with(json).get("officeId"); final Integer notificationOfficeId = JsonPath.with(json).get("officeId");
Assert.assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID, Assert.assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID,
notificationOfficeId); notificationOfficeId);
System.out.println("Notification Office Id - " + notificationOfficeId); LOG.info("Notification Office Id - {}" , notificationOfficeId);
i = 6; i = 6;
} catch (Exception e) { } catch (Exception e) {
TimeUnit.SECONDS.sleep(3); TimeUnit.SECONDS.sleep(3);
@@ -102,13 +104,13 @@ public class HookIntegrationTest {
Long hookId = this.hookHelper.createHook(payloadURL).longValue(); Long hookId = this.hookHelper.createHook(payloadURL).longValue();
Assert.assertNotNull(hookId); Assert.assertNotNull(hookId);
this.hookHelper.verifyHookCreatedOnServer(hookId); this.hookHelper.verifyHookCreatedOnServer(hookId);
System.out.println("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK-------------------------"+hookId); LOG.info("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK------------------------- {}",hookId);
this.hookHelper.updateHook(updateURL, hookId); this.hookHelper.updateHook(updateURL, hookId);
this.hookHelper.verifyUpdateHook(updateURL, hookId); this.hookHelper.verifyUpdateHook(updateURL, hookId);
System.out.println("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK-------------------------"+hookId); LOG.info("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK------------------------- {}",hookId);
this.hookHelper.deleteHook(hookId); this.hookHelper.deleteHook(hookId);
this.hookHelper.verifyDeleteHook(hookId); this.hookHelper.verifyDeleteHook(hookId);
System.out.println("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK-------------------------"+hookId); LOG.info("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK------------------------- {}",hookId);
} }
} }
@@ -37,10 +37,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker;
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanApplicationApprovalTest { public class LoanApplicationApprovalTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403; private ResponseSpecification responseSpecForStatusCode403;
private ResponseSpecification responseSpecForStatusCode400; private ResponseSpecification responseSpecForStatusCode400;
@@ -128,14 +130,14 @@ public class LoanApplicationApprovalTest {
createTranches.add(createTrancheDetail("23 March 2014", "4000")); createTranches.add(createTrancheDetail("23 March 2014", "4000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
+ clientID); , clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.build(null)); .build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
+ loanProductID); , loanProductID);
this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches); this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches); this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
@@ -153,19 +155,18 @@ public class LoanApplicationApprovalTest {
approveTranches.add(createTrancheDetail("23 March 2014", "1000")); approveTranches.add(createTrancheDetail("23 March 2014", "1000"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
+ loanID); , loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches); loanID, approveTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out LOG.info("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
.println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
} }
@@ -200,13 +201,13 @@ public class LoanApplicationApprovalTest {
approveTranche4.add(createTrancheDetail("24 March 2014", "100")); approveTranche4.add(createTrancheDetail("24 March 2014", "100"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
+ loanID); , loanID);
HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode400); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode400);
/* Tranches with same expected disbursement date */ /* Tranches with same expected disbursement date */
@@ -256,7 +257,7 @@ public class LoanApplicationApprovalTest {
public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal, public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal,
List<HashMap> tranches) { List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(principal) .withPrincipal(principal)
@@ -35,10 +35,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanApplicationUndoLastTrancheTest { public class LoanApplicationUndoLastTrancheTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -65,15 +67,15 @@ public class LoanApplicationUndoLastTrancheTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
+ clientID); , clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT // CREATE LOAN MULTIDISBURSAL PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.build(null)); .build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
+ loanProductID); , loanProductID);
// CREATE TRANCHES // CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>(); List<HashMap> createTranches = new ArrayList<>();
@@ -87,14 +89,14 @@ public class LoanApplicationUndoLastTrancheTest {
// APPLY FOR LOAN WITH TRANCHES // APPLY FOR LOAN WITH TRANCHES
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
+ loanID); , loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches); loanID, approveTranches);
@@ -109,11 +111,11 @@ public class LoanApplicationUndoLastTrancheTest {
// VALIDATE THE LOAN IS ACTIVE STATUS // VALIDATE THE LOAN IS ACTIVE STATUS
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
System.out.println("-------------Make repayment 1-----------"); LOG.info("-------------Make repayment 1-----------");
this.loanTransactionHelper.makeRepayment("01 April 2014", Float.valueOf("420"), loanID); this.loanTransactionHelper.makeRepayment("01 April 2014", Float.valueOf("420"), loanID);
System.out.println("-------------Make repayment 2-----------"); LOG.info("-------------Make repayment 2-----------");
this.loanTransactionHelper.makeRepayment("01 May 2014", Float.valueOf("412"), loanID); this.loanTransactionHelper.makeRepayment("01 May 2014", Float.valueOf("412"), loanID);
System.out.println("-------------Make repayment 3-----------"); LOG.info("-------------Make repayment 3-----------");
this.loanTransactionHelper.makeRepayment("01 June 2014", Float.valueOf("204"), loanID); this.loanTransactionHelper.makeRepayment("01 June 2014", Float.valueOf("204"), loanID);
// DISBURSE A SECOND TRANCHE // DISBURSE A SECOND TRANCHE
this.loanTransactionHelper.disburseLoan("23 June 2014", loanID); this.loanTransactionHelper.disburseLoan("23 June 2014", loanID);
@@ -129,7 +131,7 @@ public class LoanApplicationUndoLastTrancheTest {
public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal, public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal,
List<HashMap> tranches) { List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(principal) .withPrincipal(principal)
@@ -35,10 +35,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanDisbursalDateValidationTest { public class LoanDisbursalDateValidationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -63,25 +65,25 @@ public class LoanDisbursalDateValidationTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
+ clientID); , clientID);
// CREATE LOAN PRODUCT // CREATE LOAN PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withSyncExpectedWithDisbursementDate(true).build(null)); .withSyncExpectedWithDisbursementDate(true).build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
+ loanProductID); , loanProductID);
// APPLY FOR LOAN // APPLY FOR LOAN
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
+ loanID); , loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(approveDate, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(approveDate, loanID);
// VALIDATE THE LOAN IS APPROVED // VALIDATE THE LOAN IS APPROVED
@@ -39,10 +39,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker;
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class LoanDisbursementDetailsIntegrationTest { public class LoanDisbursementDetailsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursementDetailsIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -73,21 +75,20 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000")); createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" LOG.info("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------{}"
+ clientID); , clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true) .withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
+ loanProductID); , loanProductID);
final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches, final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
installmentAmount); installmentAmount);
System.out LOG.info("-----------------------------------LOAN CREATED WITH EMI LOANID------------------------------------------------- {}"
.println("-----------------------------------LOAN CREATED WITH EMI LOANID-------------------------------------------------" , loanIDWithEmi);
+ loanIDWithEmi);
HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec,
loanIDWithEmi, "repaymentSchedule"); loanIDWithEmi, "repaymentSchedule");
@@ -100,13 +101,12 @@ public class LoanDisbursementDetailsIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithEmi); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithEmi);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000", loanIDWithEmi, loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000", loanIDWithEmi,
createTranches); createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
.println("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches, final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
withoutInstallmentAmount); withoutInstallmentAmount);
@@ -117,9 +117,8 @@ public class LoanDisbursementDetailsIntegrationTest {
ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods"); ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods");
assertEquals(periods1.size(), 15); assertEquals(periods1.size(), 15);
System.out LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}"
.println("-----------------------------------LOAN CREATED WITHOUT EMI LOANID-------------------------------------------------" , loanIDWithoutEmi);
+ loanIDWithoutEmi);
/* To be uncommented once issue MIFOSX-2006 is closed. */ /* To be uncommented once issue MIFOSX-2006 is closed. */
// this.validateRepaymentScheduleWithoutEMI(periods1); // this.validateRepaymentScheduleWithoutEMI(periods1);
@@ -127,13 +126,12 @@ public class LoanDisbursementDetailsIntegrationTest {
HashMap loanStatusMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithoutEmi); HashMap loanStatusMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithoutEmi);
LoanStatusChecker.verifyLoanIsPending(loanStatusMap); LoanStatusChecker.verifyLoanIsPending(loanStatusMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000", loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000",
loanIDWithoutEmi, createTranches); loanIDWithoutEmi, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
.println("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
} }
@@ -209,7 +207,7 @@ public class LoanDisbursementDetailsIntegrationTest {
assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate()); assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate());
assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding()); assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding());
System.out.println(period.get("totalOriginalDueForPeriod").toString()); LOG.info("{}",period.get("totalOriginalDueForPeriod").toString());
assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()), expectedRepaymentSchedule assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()), expectedRepaymentSchedule
.getTotalOriginalDueForPeriod().floatValue(), 0.0f); .getTotalOriginalDueForPeriod().floatValue(), 0.0f);
@@ -342,7 +340,7 @@ public class LoanDisbursementDetailsIntegrationTest {
private Integer applyForLoanApplicationWithEmiAmount(final Integer clientID, final Integer loanProductID, final String proposedAmount, private Integer applyForLoanApplicationWithEmiAmount(final Integer clientID, final Integer loanProductID, final String proposedAmount,
List<HashMap> tranches, final String installmentAmount) { List<HashMap> tranches, final String installmentAmount) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(proposedAmount) .withPrincipal(proposedAmount)
@@ -373,29 +371,28 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000")); createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
+ clientID); , clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.build(null)); .build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
+ loanProductID); , loanProductID);
this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
+ loanID); , loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, createTranches); loanID, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out LOG.info("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
.println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper.getLoanDetail(this.requestSpec, ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper.getLoanDetail(this.requestSpec,
this.responseSpec, this.loanID, "disbursementDetails"); this.responseSpec, this.loanID, "disbursementDetails");
this.disbursementId = (Integer) disbursementDetails.get(0).get("id"); this.disbursementId = (Integer) disbursementDetails.get(0).get("id");
@@ -474,7 +471,7 @@ public class LoanDisbursementDetailsIntegrationTest {
private Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal, private Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal,
List<HashMap> tranches) { List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(principal) .withPrincipal(principal)
@@ -40,10 +40,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker;
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanRepaymentRescheduleAtDisbursementTest { public class LoanRepaymentRescheduleAtDisbursementTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -73,8 +75,8 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
+ clientID); , clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION // CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION
final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY, final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY,
@@ -102,7 +104,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches); loanID, approveTranches);
@@ -167,7 +169,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
boolean isArrearsBasedOnOriginalSchedule, final Integer recalculationCompoundingFrequencyOnDayType, boolean isArrearsBasedOnOriginalSchedule, final Integer recalculationCompoundingFrequencyOnDayType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) { final Integer recalculationRestFrequencyDayOfWeekType) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() LoanProductTestBuilder builder = new LoanProductTestBuilder()
.withPrincipal("10000.00") .withPrincipal("10000.00")
.withNumberOfRepayments("12") .withNumberOfRepayments("12")
@@ -207,7 +209,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
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) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000.00") // .withPrincipal("10000.00") //
.withLoanTermFrequency("24") // .withLoanTermFrequency("24") //
@@ -36,12 +36,15 @@ import org.apache.fineract.integrationtests.common.loans.LoanRescheduleRequestTe
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* 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 {
private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -93,7 +96,7 @@ public class LoanRescheduleRequestTest {
* create a new loan product * create a new loan product
**/ **/
private void createLoanProductEntity() { private void createLoanProductEntity() {
System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() final String loanProductJSON = new LoanProductTestBuilder()
.withPrincipal(loanPrincipalAmount) .withPrincipal(loanPrincipalAmount)
@@ -103,14 +106,14 @@ public class LoanRescheduleRequestTest {
.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 + ")"); LOG.info("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------------------------------------------"); LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
.withPrincipal(loanPrincipalAmount) .withPrincipal(loanPrincipalAmount)
@@ -131,7 +134,7 @@ public class LoanRescheduleRequestTest {
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
System.out.println("Sucessfully created loan (ID: " + this.loanId + ")"); LOG.info("Sucessfully created loan (ID: {} )" , this.loanId);
this.approveLoanApplication(); this.approveLoanApplication();
this.disburseLoan(); this.disburseLoan();
@@ -144,7 +147,7 @@ public class LoanRescheduleRequestTest {
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 + ")"); LOG.info("Successfully approved loan (ID: {} )" , this.loanId);
} }
} }
@@ -155,7 +158,7 @@ public class LoanRescheduleRequestTest {
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 + ")"); LOG.info("Successfully disbursed loan (ID: {} )" , this.loanId);
} }
} }
@@ -163,14 +166,14 @@ public class LoanRescheduleRequestTest {
* create new loan reschedule request * create new loan reschedule request
**/ **/
private void createLoanRescheduleRequest() { private void createLoanRescheduleRequest() {
System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------"); LOG.info("---------------------------------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 + ")"); LOG.info("Successfully created loan reschedule request (ID: {} )" , this.loanRescheduleRequestId);
} }
@Test @Test
@@ -182,7 +185,7 @@ public class LoanRescheduleRequestTest {
public void testRejectLoanRescheduleRequest() { public void testRejectLoanRescheduleRequest() {
this.createLoanRescheduleRequest(); this.createLoanRescheduleRequest();
System.out.println("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------"); LOG.info("-----------------------------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);
@@ -190,14 +193,14 @@ public class LoanRescheduleRequestTest {
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean)response.get("rejected")); assertTrue((Boolean)response.get("rejected"));
System.out.println("Successfully rejected loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); LOG.info("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--------------------------"); LOG.info("-----------------------------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);
@@ -212,6 +215,6 @@ public class LoanRescheduleRequestTest {
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 + ")"); LOG.info("Successfully approved loan reschedule request (ID: {})" , this.loanRescheduleRequestId);
} }
} }
@@ -52,9 +52,11 @@ import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoanReschedulingWithinCenterTest { public class LoanReschedulingWithinCenterTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -133,7 +135,7 @@ public class LoanReschedulingWithinCenterTest {
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanId); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); LOG.info("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------");
Calendar todaysdate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar todaysdate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
todaysdate.add(Calendar.DAY_OF_MONTH, 14); todaysdate.add(Calendar.DAY_OF_MONTH, 14);
String oldMeetingDate = dateFormat.format(todaysdate.getTime()); String oldMeetingDate = dateFormat.format(todaysdate.getTime());
@@ -181,7 +183,7 @@ public class LoanReschedulingWithinCenterTest {
Integer calendarId = CalendarHelper.createMeetingForGroup(this.requestSpec, this.responseSpec, centerId, startDate, frequency, Integer calendarId = CalendarHelper.createMeetingForGroup(this.requestSpec, this.responseSpec, centerId, startDate, frequency,
interval, repeatsOnDay.toString()); interval, repeatsOnDay.toString());
System.out.println("calendarId " + calendarId); LOG.info("calendarId {}" , calendarId);
return calendarId; return calendarId;
} }
@@ -253,7 +255,7 @@ public class LoanReschedulingWithinCenterTest {
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches); loanID, approveTranches);
@@ -265,7 +267,7 @@ public class LoanReschedulingWithinCenterTest {
this.loanTransactionHelper.disburseLoan(disbursementDate, loanID); this.loanTransactionHelper.disburseLoan(disbursementDate, loanID);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); LOG.info("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------");
Calendar todaysdate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar todaysdate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
todaysdate.add(Calendar.DAY_OF_MONTH, 14); todaysdate.add(Calendar.DAY_OF_MONTH, 14);
String oldMeetingDate = dateFormat.format(todaysdate.getTime()); String oldMeetingDate = dateFormat.format(todaysdate.getTime());
@@ -312,7 +314,7 @@ public class LoanReschedulingWithinCenterTest {
final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyOnDayType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) { final Integer recalculationRestFrequencyDayOfWeekType) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() LoanProductTestBuilder builder = new LoanProductTestBuilder()
.withPrincipal("10000.00") .withPrincipal("10000.00")
.withNumberOfRepayments("12") .withNumberOfRepayments("12")
@@ -359,7 +361,7 @@ public class LoanReschedulingWithinCenterTest {
final Integer loanProductID, final String disbursementDate, final String restStartDate, final String compoundingStartDate, final Integer loanProductID, final String disbursementDate, final String restStartDate, final String compoundingStartDate,
final String repaymentStrategy, final List<HashMap> charges, final String graceOnInterestPayment, final String repaymentStrategy, final List<HashMap> charges, final String graceOnInterestPayment,
final String graceOnPrincipalPayment, List<HashMap> tranches) { final String graceOnPrincipalPayment, List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000.00") // .withPrincipal("10000.00") //
.withLoanTermFrequency("24") // .withLoanTermFrequency("24") //
@@ -33,6 +33,8 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Client Loan Integration Test for checking Loan Disbursement with Waive * Client Loan Integration Test for checking Loan Disbursement with Waive
@@ -40,7 +42,7 @@ import org.junit.Test;
*/ */
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public class LoanWithWaiveInterestAndWriteOffIntegrationTest { public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -74,7 +76,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -83,14 +85,14 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID); loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------RE-APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------RE-APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("1 October 2010", loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan("1 October 2010", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
// DISBURSE // DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
System.out.println("DISBURSE " + loanStatusHashMap); LOG.info("DISBURSE {}" , loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// PERFORM REPAYMENTS AND CHECK LOAN STATUS // PERFORM REPAYMENTS AND CHECK LOAN STATUS
@@ -103,7 +105,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DIBURSE AGAIN // DIBURSE AGAIN
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
System.out.println("DISBURSE " + loanStatusHashMap); LOG.info("DISBURSE {}" , loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS // MAKE REPAYMENTS
@@ -142,14 +144,14 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
// DISBURSE // DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
System.out.println("DISBURSE " + loanStatusHashMap); LOG.info("DISBURSE {}" , loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS // MAKE REPAYMENTS
@@ -179,7 +181,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
} }
private Integer createLoanProduct() { private Integer createLoanProduct() {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL).withRepaymentTypeAsMonth() final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL).withRepaymentTypeAsMonth()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
@@ -189,7 +191,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.PRINCIPAL) final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.PRINCIPAL)
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths() .withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths()
.withNumberOfRepayments(this.NUMBER_OF_REPAYMENTS).withRepaymentEveryAfter(this.REPAYMENT_PERIOD) .withNumberOfRepayments(this.NUMBER_OF_REPAYMENTS).withRepaymentEveryAfter(this.REPAYMENT_PERIOD)
@@ -29,9 +29,11 @@ import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NotificationApiTest { public class NotificationApiTest {
private final static Logger LOG = LoggerFactory.getLogger(NotificationApiTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -48,7 +50,7 @@ public class NotificationApiTest {
public void testNotificationRetrieval() { public void testNotificationRetrieval() {
HashMap<String, Object> response = (HashMap<String, Object>) NotificationHelper.getNotifications(this.requestSpec, HashMap<String, Object> response = (HashMap<String, Object>) NotificationHelper.getNotifications(this.requestSpec,
this.responseSpec, ""); this.responseSpec, "");
System.out.println("Response : " + response.toString()); LOG.info("Response : {}" , response.toString());
Assert.assertNotNull(response); Assert.assertNotNull(response);
} }
} }
@@ -32,10 +32,12 @@ import org.apache.fineract.integrationtests.common.PasswordPreferencesHelper;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class PasswordPreferencesIntegrationTest { public class PasswordPreferencesIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(PasswordPreferencesIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
@@ -60,7 +62,7 @@ public class PasswordPreferencesIntegrationTest {
private void validateIfThePasswordIsUpdated(String validationPolicyId){ private void validateIfThePasswordIsUpdated(String validationPolicyId){
Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec); Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec);
assertEquals(validationPolicyId, id.toString()); assertEquals(validationPolicyId, id.toString());
System.out.println("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------"); LOG.info("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------");
} }
@@ -62,10 +62,12 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
public class RecurringDepositTest { public class RecurringDepositTest {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private RecurringDepositProductHelper recurringDepositProductHelper; private RecurringDepositProductHelper recurringDepositProductHelper;
@@ -1420,7 +1422,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -1432,7 +1434,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern("."); decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal)); principal = Float.valueOf(decimalFormat.format(principal));
maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount));
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount);
} }
@@ -1505,7 +1507,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -1517,7 +1519,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern("."); decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal)); principal = Float.valueOf(decimalFormat.format(principal));
maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount));
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount);
} }
@@ -1588,7 +1590,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US)); DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
@@ -1601,7 +1603,7 @@ public class RecurringDepositTest {
principal += interestToBePosted; principal += interestToBePosted;
Float expectedBalanceAfter = Float.valueOf(decimalFormat.format(principal)); Float expectedBalanceAfter = Float.valueOf(decimalFormat.format(principal));
System.out.println(expectedBalanceAfter); LOG.info("{}",expectedBalanceAfter.toString());
Integer transactionIdForPostInterest = this.recurringDepositAccountHelper Integer transactionIdForPostInterest = this.recurringDepositAccountHelper
.postInterestForRecurringDeposit(recurringDepositAccountId); .postInterestForRecurringDeposit(recurringDepositAccountId);
@@ -1696,7 +1698,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@@ -1707,7 +1709,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount; principal += interestPerMonth + depositAmount;
calendar.add(Calendar.DATE, daysInMonth); calendar.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(calendar.getTime())); LOG.info("{}",monthDayFormat.format(calendar.getTime()));
EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime());
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -1716,9 +1718,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1; currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE); recurringDepositAccountId, CLOSED_ON_DATE);
@@ -1828,7 +1830,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@@ -1839,7 +1841,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount; principal += interestPerMonth + depositAmount;
calendar.add(Calendar.DATE, daysInMonth); calendar.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(calendar.getTime())); LOG.info("{}",monthDayFormat.format(calendar.getTime()));
EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime());
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -1848,9 +1850,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1; currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE); recurringDepositAccountId, CLOSED_ON_DATE);
@@ -1967,7 +1969,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@@ -1979,7 +1981,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount; principal += interestPerMonth + depositAmount;
calendar.add(Calendar.DATE, daysInMonth); calendar.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(calendar.getTime())); LOG.info("{}",monthDayFormat.format(calendar.getTime()));
EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime());
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -1988,9 +1990,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1; currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE); recurringDepositAccountId, CLOSED_ON_DATE);
@@ -2112,7 +2114,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate; interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@@ -2124,7 +2126,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount; principal += interestPerMonth + depositAmount;
calendar.add(Calendar.DATE, daysInMonth); calendar.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(calendar.getTime())); LOG.info("{}",monthDayFormat.format(calendar.getTime()));
EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime());
Integer newTransactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, Integer newTransactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -2133,9 +2135,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1; currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth); LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
System.out.println("principal = " + principal); LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE); recurringDepositAccountId, CLOSED_ON_DATE);
@@ -2227,7 +2229,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -2239,7 +2241,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern("."); decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal)); principal = Float.valueOf(decimalFormat.format(principal));
maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount));
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount);
} }
@@ -2312,7 +2314,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -2324,7 +2326,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern("."); decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal)); principal = Float.valueOf(decimalFormat.format(principal));
maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount));
System.out.println(principal); LOG.info("{}",principal.toString());
Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount);
} }
@@ -2355,7 +2357,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2403,7 +2405,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2446,7 +2448,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2494,7 +2496,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2536,7 +2538,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2585,7 +2587,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2627,7 +2629,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2676,7 +2678,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2719,7 +2721,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2767,7 +2769,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2810,7 +2812,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate; Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1)); todaysDate.add(Calendar.DATE, (daysLeft + 1));
daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
System.out.println(dateFormat.format(todaysDate.getTime())); LOG.info("{}",dateFormat.format(todaysDate.getTime()));
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String VALID_TO = null; final String VALID_TO = null;
@@ -2858,7 +2860,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100); double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear); double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay); LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay; double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -3040,7 +3042,7 @@ public class RecurringDepositTest {
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule,
Account... accounts) { Account... accounts) {
System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -3053,7 +3055,7 @@ public class RecurringDepositTest {
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -3068,7 +3070,7 @@ public class RecurringDepositTest {
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule,
final String chartToBePicked, Account... accounts) { final String chartToBePicked, Account... accounts) {
System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -3098,7 +3100,7 @@ public class RecurringDepositTest {
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom, private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate) { final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate) {
System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------");
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec)
.withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate)
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
@@ -3109,7 +3111,7 @@ public class RecurringDepositTest {
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom, private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate, final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate,
final String depositAmount, final String depositPeriod) { final String depositAmount, final String depositPeriod) {
System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------");
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec)
.withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate)
.withDepositPeriod(depositPeriod).withMandatoryDepositAmount(depositAmount).build(clientID, productID, penalInterestType); .withDepositPeriod(depositPeriod).withMandatoryDepositAmount(depositAmount).build(clientID, productID, penalInterestType);
@@ -3119,7 +3121,7 @@ public class RecurringDepositTest {
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String minOpenningBalance, final String accountingRule, Account... accounts) { final String minOpenningBalance, final String accountingRule, Account... accounts) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
if (accountingRule.equals(CASH_BASED)) { if (accountingRule.equals(CASH_BASED)) {
savingsProductHelper = savingsProductHelper.withAccountingRuleAsCashBased(accounts); savingsProductHelper = savingsProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -34,9 +34,11 @@ import org.apache.fineract.integrationtests.useradministration.users.UserHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RolesTest { public class RolesTest {
private final static Logger LOG = LoggerFactory.getLogger(RolesTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -52,11 +54,11 @@ public class RolesTest {
@Test @Test
public void testCreateRolesStatus() { public void testCreateRolesStatus() {
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------"); LOG.info("---------------------------------CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId); Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------"); LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId); assertEquals((Integer) role.get("id"), roleId);
@@ -66,15 +68,15 @@ public class RolesTest {
@Test @Test
public void testDisableRolesStatus() { public void testDisableRolesStatus() {
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------"); LOG.info("---------------------------------CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId); Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------"); LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId); assertEquals((Integer) role.get("id"), roleId);
System.out.println("--------------------------------- DISABLING ROLE -------------------------------"); LOG.info("--------------------------------- DISABLING ROLE -------------------------------");
final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId); final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId);
assertEquals(disableRoleId, roleId); assertEquals(disableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
@@ -87,22 +89,22 @@ public class RolesTest {
@Test @Test
public void testEnableRolesStatus() { public void testEnableRolesStatus() {
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------"); LOG.info("---------------------------------CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId); Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------"); LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId); assertEquals((Integer) role.get("id"), roleId);
System.out.println("--------------------------------- DISABLING ROLE -------------------------------"); LOG.info("--------------------------------- DISABLING ROLE -------------------------------");
final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId); final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId);
assertEquals(disableRoleId, roleId); assertEquals(disableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId); assertEquals((Integer) role.get("id"), roleId);
assertEquals((Boolean) role.get("disabled"), true); assertEquals((Boolean) role.get("disabled"), true);
System.out.println("--------------------------------- ENABLING ROLE -------------------------------"); LOG.info("--------------------------------- ENABLING ROLE -------------------------------");
final Integer enableRoleId = RolesHelper.enableRole(this.requestSpec, this.responseSpec, roleId); final Integer enableRoleId = RolesHelper.enableRole(this.requestSpec, this.responseSpec, roleId);
assertEquals(enableRoleId, roleId); assertEquals(enableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
@@ -115,15 +117,15 @@ public class RolesTest {
@Test @Test
public void testDeleteRoleStatus() { public void testDeleteRoleStatus() {
System.out.println("-------------------------------- CREATING A ROLE---------------------------------------------"); LOG.info("-------------------------------- CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId); Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------"); LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId); assertEquals((Integer) role.get("id"), roleId);
System.out.println("--------------------------------- DELETE ROLE -------------------------------"); LOG.info("--------------------------------- DELETE ROLE -------------------------------");
final Integer deleteRoleId = RolesHelper.deleteRole(this.requestSpec, this.responseSpec, roleId); final Integer deleteRoleId = RolesHelper.deleteRole(this.requestSpec, this.responseSpec, roleId);
assertEquals(deleteRoleId, roleId); assertEquals(deleteRoleId, roleId);
} }
@@ -51,10 +51,13 @@ public class SchedulerJobsTest {
@Test // FINERACT-926 @Test // FINERACT-926
public void testDateFormat() { public void testDateFormat() {
// must start scheduler and make job active to have nextRunTime (which is a java.util.Date) // must start scheduler and make job active to have nextRunTime (which is a
// java.util.Date)
schedulerJobHelper.updateSchedulerStatus(true); schedulerJobHelper.updateSchedulerStatus(true);
schedulerJobHelper.updateSchedulerJob(1, "true"); schedulerJobHelper.updateSchedulerJob(1, "true");
String nextRunTimeText = await().until(() -> (String)schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"), nextRunTime -> nextRunTime != null); String nextRunTimeText = await().until(
() -> (String) schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"),
nextRunTime -> nextRunTime != null);
DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText); DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText);
} }
@@ -77,7 +80,8 @@ public class SchedulerJobsTest {
@Test @Test
public void testFlippingJobsActiveStatus() throws InterruptedException { public void testFlippingJobsActiveStatus() throws InterruptedException {
// Stop the Scheduler while we test flapping jobs' active on/off, to avoid side effects // Stop the Scheduler while we test flapping jobs' active on/off, to avoid side
// effects
schedulerJobHelper.updateSchedulerStatus(false); schedulerJobHelper.updateSchedulerStatus(false);
// For each retrieved scheduled job (by ID)... // For each retrieved scheduled job (by ID)...
@@ -119,13 +123,13 @@ public class SchedulerJobsTest {
Thread.sleep(500); Thread.sleep(500);
schedulerJob = schedulerJobHelper.getSchedulerJobById(jobId); schedulerJob = schedulerJobHelper.getSchedulerJobById(jobId);
assertNotNull(schedulerJob); assertNotNull(schedulerJob);
System.out.println("Job " + jobId +" is Still Running");
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
List<Map> jobHistoryData = schedulerJobHelper.getSchedulerJobHistory(jobId); List<Map> jobHistoryData = schedulerJobHelper.getSchedulerJobHistory(jobId);
// Verifying the Status of the Recently executed Scheduler Job // Verifying the Status of the Recently executed Scheduler Job
assertFalse("Job History is empty :( Was it too slow? Failures in background job?", jobHistoryData.isEmpty()); assertFalse("Job History is empty :( Was it too slow? Failures in background job?",
jobHistoryData.isEmpty());
assertEquals("Verifying Last Scheduler Job Status", "success", assertEquals("Verifying Last Scheduler Job Status", "success",
jobHistoryData.get(jobHistoryData.size() - 1).get("status")); jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
} }
@@ -40,10 +40,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" }) @SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" })
public class SkipRepaymentOnMonthFirstTest { public class SkipRepaymentOnMonthFirstTest {
private final static Logger LOG = LoggerFactory.getLogger(SkipRepaymentOnMonthFirstTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private GlobalConfigurationHelper globalConfigurationHelper; private GlobalConfigurationHelper globalConfigurationHelper;
@@ -102,10 +104,10 @@ public class SkipRepaymentOnMonthFirstTest {
final String interval = "1"; //Every One Moth final String interval = "1"; //Every One Moth
Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency, Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency,
interval, null); interval, null);
System.out.println("caladerId --------------------" + calendarID); LOG.info("caladerId -------------------- {}" , calendarID);
final Integer loanProductID = createLoanProduct(); final Integer loanProductID = createLoanProduct();
final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID); final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID);
System.out.println("loanID----" + loanID); LOG.info("loanID---- {}" , loanID);
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
this.responseSpec, loanID); this.responseSpec, loanID);
verifyLoanRepaymentSchedule(loanSchedule); verifyLoanRepaymentSchedule(loanSchedule);
@@ -113,7 +115,7 @@ public class SkipRepaymentOnMonthFirstTest {
} }
private Integer createLoanProduct() { private Integer createLoanProduct() {
System.out.println( LOG.info(
"------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); "------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
@@ -130,7 +132,7 @@ public class SkipRepaymentOnMonthFirstTest {
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID, private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID,
Integer clientID) { Integer clientID) {
System.out.println( LOG.info(
"--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); "--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
@@ -147,27 +149,27 @@ public class SkipRepaymentOnMonthFirstTest {
.withCalendarID(calendarID.toString()) // .withCalendarID(calendarID.toString()) //
.withSubmittedOnDate("01 October 2011") // .withSubmittedOnDate("01 October 2011") //
.withLoanType("jlg").build(clientID.toString(), groupID.toString(), loanProductID.toString(), null); .withLoanType("jlg").build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
System.out.println(loanApplicationJSON); LOG.info(loanApplicationJSON);
return this.loanTransactionHelper.getLoanId(loanApplicationJSON); return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
} }
private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) { private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
System.out.println("--------------------VERIFYING THE REPAYMENT DATE--------------------------"); LOG.info("--------------------VERIFYING THE REPAYMENT DATE--------------------------");
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")); LOG.info("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")); LOG.info("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")); LOG.info("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")); LOG.info("Repayment Date for 4th Month-- {}" , loanSchedule.get(4).get("dueDate"));
} }
} }
@@ -36,10 +36,11 @@ import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UserAdministrationTest { public class UserAdministrationTest {
private final static Logger LOG = LoggerFactory.getLogger(UserAdministrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private List<Integer> transientUsers = new ArrayList<>(); private List<Integer> transientUsers = new ArrayList<>();
@@ -79,8 +80,8 @@ public class UserAdministrationTest {
final List errors = (List) UserHelper.createUser(this.requestSpec, expectStatusCode(403), roleId, staffId, "alphabet", "errors"); final List errors = (List) UserHelper.createUser(this.requestSpec, expectStatusCode(403), roleId, staffId, "alphabet", "errors");
Map reason = (Map) errors.get(0); Map reason = (Map) errors.get(0);
System.out.println("Reason: " + reason.get("defaultUserMessage")); LOG.info("Reason: {}" , reason.get("defaultUserMessage"));
System.out.println("Code: " + reason.get("userMessageGlobalisationCode")); LOG.info("Code: {}" , reason.get("userMessageGlobalisationCode"));
Assert.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage")); Assert.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage"));
Assert.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode")); Assert.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode"));
} }
@@ -31,10 +31,12 @@ import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.xbrl.XBRLIntegrationTestHelper; import org.apache.fineract.integrationtests.common.xbrl.XBRLIntegrationTestHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class XBRLIntegrationTest { public class XBRLIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(XBRLIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -57,7 +59,7 @@ public class XBRLIntegrationTest {
} }
private void verifyTaxonomyList(final ArrayList<HashMap> taxonomyList) { private void verifyTaxonomyList(final ArrayList<HashMap> taxonomyList) {
System.out.println("--------------------VERIFYING TAXONOMY LIST--------------------------"); LOG.info("--------------------VERIFYING TAXONOMY LIST--------------------------");
assertEquals("Checking for the 1st taxonomy", "AdministrativeExpense", taxonomyList.get(0).get("name")); assertEquals("Checking for the 1st taxonomy", "AdministrativeExpense", taxonomyList.get(0).get("name"));
} }
@@ -28,6 +28,8 @@ import java.util.Map;
import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchRequest;
import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.domain.BatchResponse;
import org.junit.Assert; import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It * Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It
@@ -39,7 +41,7 @@ import org.junit.Assert;
* @see org.apache.fineract.integrationtests.BatchApiTest * @see org.apache.fineract.integrationtests.BatchApiTest
*/ */
public class BatchHelper { public class BatchHelper {
private final static Logger LOG = LoggerFactory.getLogger(BatchHelper.class);
private static final String BATCH_API_URL = "/fineract-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER; private static final String BATCH_API_URL = "/fineract-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER;
private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true"; private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true";
@@ -422,7 +424,7 @@ public class BatchHelper {
*/ */
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String externalId) { final String externalId) {
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String CLIENT_URL = "/fineract-provider/api/v1/clients?externalId=" + externalId + "&" + Utils.TENANT_IDENTIFIER; final String CLIENT_URL = "/fineract-provider/api/v1/clients?externalId=" + externalId + "&" + Utils.TENANT_IDENTIFIER;
final Integer responseRecords = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "totalFilteredRecords"); final Integer responseRecords = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "totalFilteredRecords");
Assert.assertEquals("No records found with given externalId", (long) responseRecords, (long) 0); Assert.assertEquals("No records found with given externalId", (long) responseRecords, (long) 0);
@@ -25,9 +25,11 @@ import com.google.gson.Gson;
import io.restassured.specification.RequestSpecification; import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CalendarHelper { public class CalendarHelper {
private final static Logger LOG = LoggerFactory.getLogger(CalendarHelper.class);
private static final String BASE_URL = "/fineract-provider/api/v1/"; private static final String BASE_URL = "/fineract-provider/api/v1/";
private static final String PARENT_ENTITY_NAME = "groups/"; private static final String PARENT_ENTITY_NAME = "groups/";
private static final String ENITY_NAME = "/calendars"; private static final String ENITY_NAME = "/calendars";
@@ -37,11 +39,11 @@ public class CalendarHelper {
public static Integer createMeetingCalendarForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createMeetingCalendarForGroup(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) {
System.out.println("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------"); LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER; final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
System.out.println(CALENDAR_RESOURCE_URL); LOG.info("{}",CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -51,11 +53,11 @@ public class CalendarHelper {
final Integer groupId, String calendarID, final String startDate, final String frequency, final String interval, final Integer groupId, String calendarID, final String startDate, final String frequency, final String interval,
final String repeatsOnDay) { final String repeatsOnDay) {
System.out.println("---------------------------------UPDATING A MEETING CALENDAR FOR THE GROUP------------------------------"); LOG.info("---------------------------------UPDATING A MEETING CALENDAR FOR THE GROUP------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "/" + calendarID; final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "/" + calendarID;
System.out.println(CALENDAR_RESOURCE_URL); LOG.info("{}",CALENDAR_RESOURCE_URL);
// TODO: check that resource id indeed exists in calendar update put. // TODO: check that resource id indeed exists in calendar update put.
return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -74,13 +76,13 @@ public class CalendarHelper {
map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4)); map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4));
map.put("typeId", "1"); map.put("typeId", "1");
map.put("startDate", startDate); map.put("startDate", startDate);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifyCalendarCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyCalendarCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedGroupId, final Integer generatedCalendarId) { final Integer generatedGroupId, final Integer generatedCalendarId) {
System.out.println("------------------------------CHECK CALENDAR DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CALENDAR DETAILS------------------------------------\n");
final String CLIENT_URL = "/fineract-provider/api/v1/groups/" + generatedGroupId + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String CLIENT_URL = "/fineract-provider/api/v1/groups/" + generatedGroupId + "?associations=all&" + Utils.TENANT_IDENTIFIER;
final String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, final String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL,
"collectionMeetingCalendar"); "collectionMeetingCalendar");
@@ -91,11 +93,11 @@ public class CalendarHelper {
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) {
System.out.println("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------"); LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + Center_Entity + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER; final String CALENDAR_RESOURCE_URL = BASE_URL + Center_Entity + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
System.out.println(CALENDAR_RESOURCE_URL); LOG.info("{}",CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -104,12 +106,12 @@ public class CalendarHelper {
public static Integer updateMeetingCalendarForCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer updateMeetingCalendarForCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer centerId, String calendarID, String oldDate, String startDate) { Integer centerId, String calendarID, String oldDate, String startDate) {
System.out.println("---------------------------------UPADATING A MEETING CALENDAR FOR THE CENTER------------------------------"); LOG.info("---------------------------------UPADATING A MEETING CALENDAR FOR THE CENTER------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + Center_Entity + centerId + ENITY_NAME + "/" + calendarID + "?" final String CALENDAR_RESOURCE_URL = BASE_URL + Center_Entity + centerId + ENITY_NAME + "/" + calendarID + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
System.out.println(CALENDAR_RESOURCE_URL); LOG.info("{}",CALENDAR_RESOURCE_URL);
return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarMeetingAsJSON(oldDate, startDate), return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarMeetingAsJSON(oldDate, startDate),
"resourceId"); "resourceId");
@@ -123,7 +125,7 @@ public class CalendarHelper {
map.put("newMeetingDate", startDate); map.put("newMeetingDate", startDate);
map.put("presentMeetingDate", oldDate); map.put("presentMeetingDate", oldDate);
map.put("reschedulebasedOnMeetingDates", "true"); map.put("reschedulebasedOnMeetingDates", "true");
System.out.println("map : " + map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
} }
@@ -22,9 +22,11 @@ import com.google.gson.Gson;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CenterDomain implements Comparable<CenterDomain> { public class CenterDomain implements Comparable<CenterDomain> {
private final static Logger LOG = LoggerFactory.getLogger(CenterDomain.class);
public static class Builder { public static class Builder {
private Integer id; private Integer id;
@@ -147,7 +149,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
} }
if (externalId != null) map.put("externalId", externalId); if (externalId != null) map.put("externalId", externalId);
if (groupMembers != null) map.put("groupMembers", groupMembers); if (groupMembers != null) map.put("groupMembers", groupMembers);
System.out.println(map); LOG.info("{}",map.toString());
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -27,10 +27,12 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class CenterHelper { public class CenterHelper {
private final static Logger LOG = LoggerFactory.getLogger(CenterHelper.class);
private static final String CENTERS_URL = "/fineract-provider/api/v1/centers"; private static final String CENTERS_URL = "/fineract-provider/api/v1/centers";
public static final String CREATED_DATE = "29 December 2014"; public static final String CREATED_DATE = "29 December 2014";
@@ -38,7 +40,7 @@ public class CenterHelper {
public static CenterDomain retrieveByID(int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static CenterDomain retrieveByID(int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String GET_CENTER_BY_ID_URL = CENTERS_URL + "/" + id + "?associations=groupMembers&" + Utils.TENANT_IDENTIFIER; final String GET_CENTER_BY_ID_URL = CENTERS_URL + "/" + id + "?associations=groupMembers&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING CENTER AT " + id + "-------------------------"); LOG.info("------------------------ RETRIEVING CENTER AT {}-------------------------",id);
Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER_BY_ID_URL, ""); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER_BY_ID_URL, "");
final String jsonData = new Gson().toJson(get); final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<CenterDomain>() {}.getType()); return new Gson().fromJson(jsonData, new TypeToken<CenterDomain>() {}.getType());
@@ -47,7 +49,7 @@ public class CenterHelper {
public static ArrayList<CenterDomain> paginatedListCenters(final RequestSpecification requestSpec, public static ArrayList<CenterDomain> paginatedListCenters(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String GET_CENTER = CENTERS_URL + "?paged=true&limit=-1&" + Utils.TENANT_IDENTIFIER; final String GET_CENTER = CENTERS_URL + "?paged=true&limit=-1&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING CENTERS-------------------------"); LOG.info("------------------------ RETRIEVING CENTERS-------------------------");
Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, "pageItems"); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, "pageItems");
final String jsonData = new Gson().toJson(get); final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CenterDomain>>() {}.getType()); return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CenterDomain>>() {}.getType());
@@ -55,7 +57,7 @@ public class CenterHelper {
public static ArrayList<CenterDomain> listCenters(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList<CenterDomain> listCenters(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String GET_CENTER = CENTERS_URL + "?limit=-1&" + Utils.TENANT_IDENTIFIER; final String GET_CENTER = CENTERS_URL + "?limit=-1&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING CENTERS-------------------------"); LOG.info("------------------------ RETRIEVING CENTERS-------------------------");
Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, ""); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, "");
final String jsonData = new Gson().toJson(get); final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CenterDomain>>() {}.getType()); return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CenterDomain>>() {}.getType());
@@ -101,14 +103,14 @@ public class CenterHelper {
hm.put("activationDate", activationDate); hm.put("activationDate", activationDate);
} }
System.out.println("------------------------CREATING CENTER-------------------------"); LOG.info("------------------------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");
} }
public static HashMap<String, String> updateCenter(final int id, HashMap request, final RequestSpecification requestSpec, public static HashMap<String, String> updateCenter(final int id, HashMap request, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String UPDATE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE CENTER AT " + id + "---------------------------------------------"); LOG.info("---------------------------------UPDATE CENTER AT {}---------------------------------------------",id);
HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_CENTER_URL, new Gson().toJson(request), HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_CENTER_URL, new Gson().toJson(request),
"changes"); "changes");
return hash; return hash;
@@ -119,10 +121,10 @@ public class CenterHelper {
final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&" + Utils.TENANT_IDENTIFIER; final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&" + Utils.TENANT_IDENTIFIER;
HashMap groupMemberHashMap = new HashMap(); HashMap groupMemberHashMap = new HashMap();
groupMemberHashMap.put("groupMembers", groupMembers); groupMemberHashMap.put("groupMembers", groupMembers);
System.out.println("---------------------------------ASSOCIATING GROUPS AT " + id + "--------------------------------------------"); LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------",id);
HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL, HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL,
new Gson().toJson(groupMemberHashMap), "changes"); new Gson().toJson(groupMemberHashMap), "changes");
System.out.println(hash); LOG.info("{}",hash.toString());
ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers"); ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers");
int[] ret = new int[arr.size()]; int[] ret = new int[arr.size()];
for (int i = 0; i < ret.length; i++) { for (int i = 0; i < ret.length; i++) {
@@ -133,38 +135,38 @@ public class CenterHelper {
public static void deleteCenter(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static void deleteCenter(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String DELETE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String DELETE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------DELETING CENTER AT " + id + "--------------------------------------------"); LOG.info("---------------------------------DELETING CENTER AT {}--------------------------------------------",id);
Utils.performServerDelete(requestSpec, responseSpec, DELETE_CENTER_URL, ""); Utils.performServerDelete(requestSpec, responseSpec, DELETE_CENTER_URL, "");
} }
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@SuppressWarnings("unused") final boolean active) { @SuppressWarnings("unused") final boolean active) {
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); LOG.info("---------------------------------CREATING A CENTER---------------------------------------------");
return createCenter(requestSpec, responseSpec, "CREATED_DATE"); return createCenter(requestSpec, responseSpec, "CREATED_DATE");
} }
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate) { final String activationDate) {
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); LOG.info("---------------------------------CREATING A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, activationDate), "groupId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, activationDate), "groupId");
} }
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); LOG.info("---------------------------------CREATING A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, CenterHelper.CREATED_DATE), return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, CenterHelper.CREATED_DATE),
"groupId"); "groupId");
} }
public static int createCenterWithStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static int createCenterWithStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer staffId) { final Integer staffId) {
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); LOG.info("---------------------------------CREATING A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL,
getTestCenterWithStaffAsJSON(true, CenterHelper.CREATED_DATE, staffId), "groupId"); getTestCenterWithStaffAsJSON(true, CenterHelper.CREATED_DATE, staffId), "groupId");
} }
public static void verifyCenterCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyCenterCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCenterID) { final Integer generatedCenterID) {
System.out.println("------------------------------CHECK CENTER DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CENTER DETAILS------------------------------------\n");
final String CENTER_URL = "/fineract-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER; final String CENTER_URL = "/fineract-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER;
final Integer responseCenterID = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "id"); final Integer responseCenterID = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "id");
assertEquals("ERROR IN CREATING THE CENTER", generatedCenterID, responseCenterID); assertEquals("ERROR IN CREATING THE CENTER", generatedCenterID, responseCenterID);
@@ -172,7 +174,7 @@ public class CenterHelper {
public static void verifyCenterActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyCenterActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCenterID, final boolean generatedCenterStatus) { final Integer generatedCenterID, final boolean generatedCenterStatus) {
System.out.println("------------------------------CHECK CENTER STATUS------------------------------------\n"); LOG.info("------------------------------CHECK CENTER STATUS------------------------------------\n");
final String CENTER_URL = "/fineract-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER; final String CENTER_URL = "/fineract-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER;
final Boolean responseCenterStatus = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "active"); final Boolean responseCenterStatus = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "active");
assertEquals("ERROR IN ACTIVATING THE CENTER", generatedCenterStatus, responseCenterStatus); assertEquals("ERROR IN ACTIVATING THE CENTER", generatedCenterStatus, responseCenterStatus);
@@ -181,7 +183,7 @@ public class CenterHelper {
public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String centerId) { final String centerId) {
final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&" + Utils.TENANT_IDENTIFIER; final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------ACTIVATE A CENTER---------------------------------------------"); LOG.info("---------------------------------ACTIVATE A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId"); return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId");
} }
@@ -226,14 +228,14 @@ public class CenterHelper {
public static String assignStaffAsJSON(final Long staffId) { public static String assignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String unassignStaffAsJSON(final Long staffId) { public static String unassignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -245,9 +247,9 @@ public class CenterHelper {
map.put("activationDate", activationDate); map.put("activationDate", activationDate);
} else { } else {
map.put("activationDate", "CREATED_DATE"); map.put("activationDate", "CREATED_DATE");
System.out.println("defaulting to fixed date: CREATED_DATE"); LOG.info("defaulting to fixed date: CREATED_DATE");
} }
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -259,7 +261,7 @@ public class CenterHelper {
final String groupId, final Long staffId) { final String groupId, final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff"; + "&command=assignStaff";
System.out.println("---------------------------------Assign Staff---------------------------------------------"); LOG.info("---------------------------------Assign Staff---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, assignStaffAsJSON(staffId), "changes"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, assignStaffAsJSON(staffId), "changes");
} }
@@ -267,7 +269,7 @@ public class CenterHelper {
final String groupId, final Long staffId) { final String groupId, final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=unassignStaff"; + "&command=unassignStaff";
System.out.println("---------------------------------Unassign Staff---------------------------------------------"); LOG.info("---------------------------------Unassign Staff---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, unassignStaffAsJSON(staffId), "changes"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, unassignStaffAsJSON(staffId), "changes");
} }
@@ -36,9 +36,11 @@ import org.apache.fineract.infrastructure.bulkimport.data.GlobalEntityType;
import org.apache.fineract.integrationtests.common.system.CodeHelper; import org.apache.fineract.integrationtests.common.system.CodeHelper;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ClientHelper { public class ClientHelper {
private final static Logger LOG = LoggerFactory.getLogger(ClientHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -67,7 +69,8 @@ public class ClientHelper {
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer createClient(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
return createClient(requestSpec, responseSpec, "04 March 2011"); return createClient(requestSpec, responseSpec, "04 March 2011");
} }
@@ -78,100 +81,110 @@ public class ClientHelper {
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) { final String activationDate, final String officeId) {
System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------"); LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(activationDate, officeId), return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
"clientId"); getTestClientAsJSON(activationDate, officeId), "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");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientPending(final RequestSpecification requestSpec,
final String submittedOnDate) { final ResponseSpecification responseSpec, final String submittedOnDate) {
return createClientPending(requestSpec, responseSpec, submittedOnDate, "1"); return createClientPending(requestSpec, responseSpec, submittedOnDate, "1");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientPending(final RequestSpecification requestSpec,
final String submittedOnDate, final String officeId) { final ResponseSpecification responseSpec, final String submittedOnDate, final String officeId) {
System.out.println("---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------"); LOG.info(
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSONPending(submittedOnDate, officeId), "---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------");
"clientId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestClientAsJSONPending(submittedOnDate, officeId), "clientId");
} }
public Object createClientPendingWithError(final String jsonAttributeToGetBack) { public Object createClientPendingWithError(final String jsonAttributeToGetBack) {
System.out.println("---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------"); LOG.info(
"---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------");
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL,
getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack); getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack);
} }
public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec, public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String registeredTableName) { final ResponseSpecification responseSpec, final String registeredTableName) {
System.out.println("-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------"); LOG.info(
"-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId"); getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer createClientAsPerson(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
return createClientAsPerson(requestSpec, responseSpec, "04 March 2011"); return createClientAsPerson(requestSpec, responseSpec, "04 March 2011");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec,
final String activationDate) { final ResponseSpecification responseSpec, final String activationDate) {
return createClientAsPerson(requestSpec, responseSpec, activationDate, "1"); return createClientAsPerson(requestSpec, responseSpec, activationDate, "1");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec,
final String activationDate, final String officeId) { final ResponseSpecification responseSpec, final String activationDate, final String officeId) {
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); LOG.info(
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId), "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
"clientId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestPersonClientAsJSON(activationDate, officeId), "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");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec,
final String activationDate) { final ResponseSpecification responseSpec, final String activationDate) {
return createClientAsEntity(requestSpec, responseSpec, activationDate, "1"); return createClientAsEntity(requestSpec, responseSpec, activationDate, "1");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec,
final String activationDate, final String officeId) { final ResponseSpecification responseSpec, final String activationDate, final String officeId) {
Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id"); Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution")
Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id"); .get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper
.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); LOG.info(
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
"clientId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "clientId");
} }
public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClientForAccountPreference(final RequestSpecification requestSpec,
final Integer clientType, String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final Integer clientType, String jsonAttributeToGetBack) {
final String activationDate = "04 March 2011"; final String activationDate = "04 March 2011";
final String officeId = "1"; final String officeId = "1";
System.out.println( LOG.info(
"---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------"); "---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), jsonAttributeToGetBack); getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()),
jsonAttributeToGetBack);
} }
public static Object assignStaffToClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object assignStaffToClient(final RequestSpecification requestSpec,
final String clientId, final String staffId) { final ResponseSpecification responseSpec, final String clientId, final String staffId) {
final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?"
+ "&command=assignStaff"; + Utils.TENANT_IDENTIFIER + "&command=assignStaff";
System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------"); LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes"); return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL,
assignStaffToClientAsJson(staffId), "changes");
} }
public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer getClientsStaffId(final RequestSpecification requestSpec,
final String clientId) { final ResponseSpecification responseSpec, final String clientId) {
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId"); return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
} }
@@ -185,7 +198,7 @@ public class ClientHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", dateOfJoining); map.put("activationDate", dateOfJoining);
System.out.println("map : " + map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -199,7 +212,7 @@ public class ClientHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("active", "false"); map.put("active", "false");
map.put("submittedOnDate", submittedOnDate); map.put("submittedOnDate", submittedOnDate);
System.out.println("map : " + map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -214,7 +227,7 @@ public class ClientHelper {
map.put("active", "false"); map.put("active", "false");
map.put("submittedOnDate", "04 March 2014"); map.put("submittedOnDate", "04 March 2014");
String requestJson = getTestDatatableAsJson(map, registeredTableName); String requestJson = getTestDatatableAsJson(map, registeredTableName);
System.out.println("map : " + requestJson); LOG.info("map : {}", requestJson);
return requestJson; return requestJson;
} }
@@ -246,11 +259,12 @@ public class ClientHelper {
map.put("activationDate", dateOfJoining); map.put("activationDate", dateOfJoining);
map.put("legalFormId", 1); map.put("legalFormId", 1);
System.out.println("map : " + map); LOG.info("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);
map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5)); map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
@@ -265,11 +279,12 @@ public class ClientHelper {
clientNonPersonMap.put("constitutionId", soleProprietorCodeValueId); clientNonPersonMap.put("constitutionId", soleProprietorCodeValueId);
map.put("clientNonPersonDetails", clientNonPersonMap); map.put("clientNonPersonDetails", clientNonPersonMap);
System.out.println("map : " + map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, final String clientType) { public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId,
final String clientType) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("officeId", officeId); map.put("officeId", officeId);
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5)); map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
@@ -280,37 +295,38 @@ public class ClientHelper {
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", dateOfJoining); map.put("activationDate", dateOfJoining);
map.put("clientTypeId", clientType); map.put("clientTypeId", clientType);
System.out.println("map : " + map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String assignStaffToClientAsJson(final String staffId) { public static String assignStaffToClientAsJson(final String staffId) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
System.out.println("map : " + map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec,
final Integer generatedClientID) { final ResponseSpecification responseSpec, final Integer generatedClientID) {
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER; final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?"
+ Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id"); final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID); assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
} }
public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId, public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String jsonReturn) { final String clientId, final String jsonReturn) {
final String GET_CLIENT_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER; final String GET_CLIENT_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------GET A CLIENT---------------------------------------------"); LOG.info("---------------------------------GET A CLIENT---------------------------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn); return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn);
} }
/* Client status is a map.So adding SuppressWarnings */ /* Client status is a map.So adding SuppressWarnings */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec,
final String clientId) { final ResponseSpecification responseSpec, final String clientId) {
return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status"); return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status");
} }
@@ -327,7 +343,8 @@ public class ClientHelper {
Integer clientClosureCodeId = (Integer) code.get("id"); Integer clientClosureCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientClosureReason" */ /* Retrieve/Create Code Values for the Code "ClientClosureReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, this.responseSpec); HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec,
this.responseSpec);
Integer closureReasonId = (Integer) codeValue.get("id"); Integer closureReasonId = (Integer) codeValue.get("id");
map.put("closureReasonId", closureReasonId.toString()); map.put("closureReasonId", closureReasonId.toString());
@@ -336,7 +353,7 @@ public class ClientHelper {
map.put("closureDate", CREATED_DATE_PLUS_ONE); map.put("closureDate", CREATED_DATE_PLUS_ONE);
String clientJson = new Gson().toJson(map); String clientJson = new Gson().toJson(map);
System.out.println(clientJson); LOG.info(clientJson);
return clientJson; return clientJson;
} }
@@ -347,7 +364,7 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("reactivationDate", CREATED_DATE_PLUS_ONE); map.put("reactivationDate", CREATED_DATE_PLUS_ONE);
String clientJson = new Gson().toJson(map); String clientJson = new Gson().toJson(map);
System.out.println(clientJson); LOG.info(clientJson);
return clientJson; return clientJson;
} }
@@ -358,7 +375,7 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("reopenedDate", date); map.put("reopenedDate", date);
String clientJson = new Gson().toJson(map); String clientJson = new Gson().toJson(map);
System.out.println(clientJson); LOG.info(clientJson);
return clientJson; return clientJson;
} }
@@ -369,7 +386,7 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("reopenedDate", date); map.put("reopenedDate", date);
String clientJson = new Gson().toJson(map); String clientJson = new Gson().toJson(map);
System.out.println(clientJson); LOG.info(clientJson);
return clientJson; return clientJson;
} }
@@ -391,7 +408,7 @@ public class ClientHelper {
map.put("rejectionDate", CREATED_DATE_PLUS_ONE); map.put("rejectionDate", CREATED_DATE_PLUS_ONE);
map.put("rejectionReasonId", rejectionReasonId.toString()); map.put("rejectionReasonId", rejectionReasonId.toString());
String clientJson = new Gson().toJson(map); String clientJson = new Gson().toJson(map);
System.out.println(clientJson); LOG.info(clientJson);
return clientJson; return clientJson;
} }
@@ -402,12 +419,10 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("activationDate", date); map.put("activationDate", date);
String clientJson = new Gson().toJson(map); String clientJson = new Gson().toJson(map);
System.out.println(clientJson); LOG.info(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<>();
/* Retrieve Code id for the Code "ClientWithdrawReason" */ /* Retrieve Code id for the Code "ClientWithdrawReason" */
@@ -416,8 +431,8 @@ public class ClientHelper {
Integer clientWithdrawReasonCodeId = (Integer) code.get("id"); Integer clientWithdrawReasonCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */ /* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, this.requestSpec, HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId,
this.responseSpec); this.requestSpec, this.responseSpec);
Integer withdrawalReasonId = (Integer) codeValue.get("id"); Integer withdrawalReasonId = (Integer) codeValue.get("id");
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
@@ -425,7 +440,7 @@ public class ClientHelper {
map.put("withdrawalDate", CREATED_DATE_PLUS_ONE); map.put("withdrawalDate", CREATED_DATE_PLUS_ONE);
map.put("withdrawalReasonId", withdrawalReasonId.toString()); map.put("withdrawalReasonId", withdrawalReasonId.toString());
String clientJson = new Gson().toJson(map); String clientJson = new Gson().toJson(map);
System.out.println(clientJson); LOG.info(clientJson);
return clientJson; return clientJson;
} }
@@ -448,7 +463,7 @@ public class ClientHelper {
map.put("transactionDate", date); map.put("transactionDate", date);
map.put("amount", amount); map.put("amount", amount);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -458,33 +473,38 @@ public class ClientHelper {
map.put("amount", amount); map.put("amount", amount);
map.put("clientChargeId", clientChargeId); map.put("clientChargeId", clientChargeId);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
public HashMap<String, Object> closeClient(final Integer clientId) { public HashMap<String, Object> closeClient(final Integer clientId) {
System.out.println("--------------------------------- CLOSE CLIENT -------------------------------"); LOG.info("--------------------------------- CLOSE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId); return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(),
clientId);
} }
public HashMap<String, Object> reactivateClient(final Integer clientId) { public HashMap<String, Object> reactivateClient(final Integer clientId) {
System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId); return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId),
getReactivateClientAsJSON(), clientId);
} }
public HashMap<String, Object> rejectClient(final Integer clientId) { public HashMap<String, Object> rejectClient(final Integer clientId) {
System.out.println("--------------------------------- REJECT CLIENT -------------------------------"); LOG.info("--------------------------------- REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId); return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(),
clientId);
} }
public HashMap<String, Object> activateClient(final Integer clientId) { public HashMap<String, Object> activateClient(final Integer clientId) {
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), clientId); return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), clientId);
} }
public HashMap<String, Object> withdrawClient(final Integer clientId) { public HashMap<String, Object> withdrawClient(final Integer clientId) {
System.out.println("--------------------------------- WITHDRAWN CLIENT -------------------------------"); LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId); return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId),
getWithdrawClientAsJSON(), clientId);
} }
private String createClientOperationURL(final String command, final Integer clientId) { private String createClientOperationURL(final String command, final Integer clientId) {
@@ -492,41 +512,42 @@ public class ClientHelper {
} }
public HashMap<String, Object> undoReject(final Integer clientId) { public HashMap<String, Object> undoReject(final Integer clientId) {
System.out.println("--------------------------------- UNDO REJECT CLIENT -------------------------------"); LOG.info("--------------------------------- UNDO REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId),
getUndoRejectClientAsJSON(CREATED_DATE_PLUS_TWO), clientId); getUndoRejectClientAsJSON(CREATED_DATE_PLUS_TWO), clientId);
} }
public HashMap<String, Object> undoWithdrawn(final Integer clientId) { public HashMap<String, Object> undoWithdrawn(final Integer clientId) {
System.out.println("--------------------------------- UNDO WITHDRAWN CLIENT -------------------------------"); LOG.info("--------------------------------- UNDO WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId); getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId);
} }
public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId, final String jsonAttributeToGetBack, public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId,
final String rejectedDate) { final String jsonAttributeToGetBack, final String rejectedDate) {
System.out.println("----------------------------------UNDO REJECT CLIENT ----------------------------------"); LOG.info("----------------------------------UNDO REJECT CLIENT ----------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId), return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId),
getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack); getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack);
} }
public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId, final String jsonAttributeToGetBack, public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId,
final String rejectedDate) { final String jsonAttributeToGetBack, final String rejectedDate) {
System.out.println("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------"); LOG.info("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------");
return performClientActionsWithValidationErrors( return performClientActionsWithValidationErrors(
createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId), createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack); getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack);
} }
public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId, final String jsonAttributeToGetBack) { public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId,
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------"); final String jsonAttributeToGetBack) {
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack); getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack);
} }
public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId, public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId,
final String activationDate) { final String activationDate) {
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(activationDate), clientId); getActivateClientAsJSON(activationDate), clientId);
} }
@@ -537,88 +558,97 @@ public class ClientHelper {
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,
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS); final Integer clientId) {
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId)); Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent,
CommonConstants.RESPONSE_STATUS);
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
return response; return response;
} }
public static Integer addChargesForClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer addChargesForClient(final RequestSpecification requestSpec,
final Integer clientId, final String request) { final ResponseSpecification responseSpec, final Integer clientId, final String request) {
System.out.println("--------------------------------- ADD CHARGES FOR Client --------------------------------"); LOG.info("--------------------------------- ADD CHARGES FOR Client --------------------------------");
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" + Utils.TENANT_IDENTIFIER; final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?"
+ Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public static String payChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static String payChargesForClients(final RequestSpecification requestSpec,
final Integer clientId, final Integer clientChargeId, final String json) { final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId,
System.out.println("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------"); final String json) {
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=paycharge&" LOG.info("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------");
+ Utils.TENANT_IDENTIFIER; final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId
+ "?command=paycharge&" + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return response.get("transactionId") != null ? response.get("transactionId").toString() : null; return response.get("transactionId") != null ? response.get("transactionId").toString() : null;
} }
public static String waiveChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static String waiveChargesForClients(final RequestSpecification requestSpec,
final Integer clientId, final Integer clientChargeId, final String json) { final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId,
System.out.println("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------"); final String json) {
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=waive&" LOG.info("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------");
+ Utils.TENANT_IDENTIFIER; final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId
+ "?command=waive&" + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return response.get("transactionId").toString(); return response.get("transactionId").toString();
} }
public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec,
final String clientId, String clientChargeId) { final ResponseSpecification responseSpec, final String clientId, String clientChargeId) {
System.out.println("---------------------------------UNDO TRANSACTION---------------------------------------------"); LOG.info("---------------------------------UNDO TRANSACTION---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId + "?command=undo&" final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId
+ Utils.TENANT_IDENTIFIER; + "?command=undo&" + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public static Object getClientCharge(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object getClientCharge(final RequestSpecification requestSpec,
final String clientId, final String clientChargeId) { final ResponseSpecification responseSpec, final String clientId, final String clientChargeId) {
System.out.println("---------------------------------GET CLIENT CHARGE---------------------------------------------"); LOG.info("---------------------------------GET CLIENT CHARGE---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?" final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding"); return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding");
} }
public static Boolean getClientTransactions(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Boolean getClientTransactions(final RequestSpecification requestSpec,
final String clientId, final String transactionId) { final ResponseSpecification responseSpec, final String clientId, final String transactionId) {
System.out.println("---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------"); LOG.info(
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + "?" "---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------");
+ Utils.TENANT_IDENTIFIER; final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId
+ "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed"); return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed");
} }
public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException { public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel"); requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte [] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,CLIENT_URL+"/downloadtemplate"+"?"+ byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate"
Utils.TENANT_IDENTIFIER+"&legalFormType="+clientsEntity+"&dateFormat="+dateFormat); + "?" + Utils.TENANT_IDENTIFIER + "&legalFormType=" + clientsEntity + "&dateFormat=" + dateFormat);
InputStream inputStream= new ByteArrayInputStream(byteArray); InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook=new HSSFWorkbook(inputStream); Workbook workbook = new HSSFWorkbook(inputStream);
return workbook; return workbook;
} }
public String getOutputTemplateLocation(final String importDocumentId){ public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_PLAIN); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?" return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
+Utils.TENANT_IDENTIFIER,importDocumentId); "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER,
importDocumentId);
} }
public String importClientEntityTemplate(File file){ public String importClientEntityTemplate(File file) {
String locale="en"; String locale = "en";
String dateFormat="dd MMMM yyyy"; String dateFormat = "dd MMMM yyyy";
String legalFormType=GlobalEntityType.CLIENTS_ENTTTY.toString(); String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString();
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec,responseSpec,CLIENT_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER, return Utils.performServerTemplatePost(requestSpec, responseSpec,
legalFormType,file,locale,dateFormat); CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale,
dateFormat);
} }
} }
@@ -24,16 +24,18 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class CurrenciesHelper { public class CurrenciesHelper {
private final static Logger LOG = LoggerFactory.getLogger(CurrenciesHelper.class);
private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies"; private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies";
public static ArrayList<CurrencyDomain> getAllCurrencies(final RequestSpecification requestSpec, public static ArrayList<CurrencyDomain> getAllCurrencies(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String GET_ALL_CURRENCIES_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER; final String GET_ALL_CURRENCIES_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING ALL CURRENCIES -------------------------"); LOG.info("------------------------ RETRIEVING ALL CURRENCIES -------------------------");
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_CURRENCIES_URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_CURRENCIES_URL, "");
ArrayList<HashMap> selectedCurrencyOptions = (ArrayList<HashMap>) response.get("selectedCurrencyOptions"); ArrayList<HashMap> selectedCurrencyOptions = (ArrayList<HashMap>) response.get("selectedCurrencyOptions");
ArrayList<HashMap> currencyOptions = (ArrayList<HashMap>) response.get("currencyOptions"); ArrayList<HashMap> currencyOptions = (ArrayList<HashMap>) response.get("currencyOptions");
@@ -45,7 +47,7 @@ public class CurrenciesHelper {
public static ArrayList<CurrencyDomain> getSelectedCurrencies(final RequestSpecification requestSpec, public static ArrayList<CurrencyDomain> getSelectedCurrencies(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String GET_ALL_SELECTED_CURRENCIES_URL = CURRENCIES_URL + "?fields=selectedCurrencyOptions" + "&" + Utils.TENANT_IDENTIFIER; final String GET_ALL_SELECTED_CURRENCIES_URL = CURRENCIES_URL + "?fields=selectedCurrencyOptions" + "&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING ALL SELECTED CURRENCIES -------------------------"); LOG.info("------------------------ RETRIEVING ALL SELECTED CURRENCIES -------------------------");
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_SELECTED_CURRENCIES_URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_SELECTED_CURRENCIES_URL, "");
final String jsonData = new Gson().toJson(response.get("selectedCurrencyOptions")); final String jsonData = new Gson().toJson(response.get("selectedCurrencyOptions"));
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CurrencyDomain>>() {}.getType()); return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CurrencyDomain>>() {}.getType());
@@ -63,7 +65,7 @@ public class CurrenciesHelper {
public static ArrayList<String> updateSelectedCurrencies(final RequestSpecification requestSpec, public static ArrayList<String> updateSelectedCurrencies(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final ArrayList<String> currencies) { final ResponseSpecification responseSpec, final ArrayList<String> currencies) {
final String CURRENCIES_UPDATE_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER; final String CURRENCIES_UPDATE_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE SELECTED CURRENCIES LIST---------------------------------------------"); LOG.info("---------------------------------UPDATE SELECTED CURRENCIES LIST---------------------------------------------");
HashMap hash = Utils.performServerPut(requestSpec, responseSpec, CURRENCIES_UPDATE_URL, currenciesToJSON(currencies), "changes"); HashMap hash = Utils.performServerPut(requestSpec, responseSpec, CURRENCIES_UPDATE_URL, currenciesToJSON(currencies), "changes");
return (ArrayList<String>) hash.get("currencies"); return (ArrayList<String>) hash.get("currencies");
} }
@@ -71,7 +73,7 @@ public class CurrenciesHelper {
private static String currenciesToJSON(final ArrayList<String> currencies) { private static String currenciesToJSON(final ArrayList<String> currencies) {
HashMap map = new HashMap<>(); HashMap map = new HashMap<>();
map.put("currencies", currencies); map.put("currencies", currencies);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
} }
@@ -29,24 +29,28 @@ public class ExternalServicesConfigurationHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(final RequestSpecification requestSpec, public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(
final ResponseSpecification responseSpec, final String serviceName) { final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?" final String serviceName) {
+ Utils.TENANT_IDENTIFIER; final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/"
System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------"); + serviceName + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION
// BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, "");
} }
public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec, public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) { final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) {
final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?" final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName
+ Utils.TENANT_IDENTIFIER; + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); // system.out.println("---------------------------------UPDATE VALUE FOR GLOBAL
// CONFIG---------------------------------------------");
HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL, HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL,
updateExternalServicesConfigUpdateValueAsJSON(name, value), ""); updateExternalServicesConfigUpdateValueAsJSON(name, value), "");
@@ -56,7 +60,7 @@ public class ExternalServicesConfigurationHelper {
public static String updateExternalServicesConfigUpdateValueAsJSON(final String name, final String value) { public static String updateExternalServicesConfigUpdateValueAsJSON(final String name, final String value) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put(name, value); map.put(name, value);
System.out.println("map : " + map); // system.out.println("map : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -24,10 +24,12 @@ import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.junit.Assert; import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class GlobalConfigurationHelper { public class GlobalConfigurationHelper {
private final static Logger LOG = LoggerFactory.getLogger(GlobalConfigurationHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -38,7 +40,7 @@ public class GlobalConfigurationHelper {
public static ArrayList<HashMap> getAllGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList<HashMap> getAllGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER; final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------"); LOG.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------");
final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, ""); final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, "");
return (ArrayList<HashMap>) response.get("globalConfiguration"); return (ArrayList<HashMap>) response.get("globalConfiguration");
} }
@@ -46,7 +48,7 @@ public class GlobalConfigurationHelper {
public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String configId) { final String configId) {
final String GET_GLOBAL_CONFIG_BY_ID_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; final String GET_GLOBAL_CONFIG_BY_ID_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------"); LOG.info("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, "");
} }
@@ -338,7 +340,7 @@ public class GlobalConfigurationHelper {
public static Integer updateValueForGlobalConfiguration(final RequestSpecification requestSpec, public static Integer updateValueForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String configId, final String value) { final ResponseSpecification responseSpec, final String configId, final String value) {
final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); LOG.info("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, updateGlobalConfigUpdateValueAsJSON(value), return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, updateGlobalConfigUpdateValueAsJSON(value),
"resourceId"); "resourceId");
} }
@@ -346,8 +348,7 @@ public class GlobalConfigurationHelper {
public static Integer updateEnabledFlagForGlobalConfiguration(final RequestSpecification requestSpec, public static Integer updateEnabledFlagForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String configId, final Boolean enabled) { final ResponseSpecification responseSpec, final String configId, final Boolean enabled) {
final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
System.out LOG.info("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------");
.println("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL,
updateGlobalConfigUpdateEnabledFlagAsJSON(enabled), "resourceId"); updateGlobalConfigUpdateEnabledFlagAsJSON(enabled), "resourceId");
} }
@@ -355,7 +356,7 @@ public class GlobalConfigurationHelper {
public static ArrayList getGlobalConfigurationIsCacheEnabled(final RequestSpecification requestSpec, public static ArrayList getGlobalConfigurationIsCacheEnabled(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String GET_IS_CACHE_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER; final String GET_IS_CACHE_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING IS CACHE ENABLED GLOBAL CONFIGURATION -------------------------"); LOG.info("------------------------ RETRIEVING IS CACHE ENABLED GLOBAL CONFIGURATION -------------------------");
final ArrayList<HashMap> response = Utils.performServerGet(requestSpec, responseSpec, GET_IS_CACHE_GLOBAL_CONFIG_URL, ""); final ArrayList<HashMap> response = Utils.performServerGet(requestSpec, responseSpec, GET_IS_CACHE_GLOBAL_CONFIG_URL, "");
return response; return response;
} }
@@ -363,7 +364,7 @@ public class GlobalConfigurationHelper {
public static HashMap updateIsCacheEnabledForGlobalConfiguration(final RequestSpecification requestSpec, public static HashMap updateIsCacheEnabledForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String cacheType) { final ResponseSpecification responseSpec, final String cacheType) {
final String IS_CACHE_GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER; final String IS_CACHE_GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------UPDATE GLOBAL CONFIG FOR IS CACHE ENABLED----------------------"); LOG.info("------------------UPDATE GLOBAL CONFIG FOR IS CACHE ENABLED----------------------");
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");
} }
@@ -371,7 +372,7 @@ public class GlobalConfigurationHelper {
public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec, public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) {
final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------"); LOG.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL,
updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack); updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack);
} }
@@ -379,7 +380,7 @@ public class GlobalConfigurationHelper {
public static String updateGlobalConfigUpdateValueAsJSON(final String value) { public static String updateGlobalConfigUpdateValueAsJSON(final String value) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("value", value); map.put("value", value);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -389,21 +390,21 @@ public class GlobalConfigurationHelper {
map.put("value", value); map.put("value", value);
} }
map.put("enabled", enabled); map.put("enabled", enabled);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) { public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) {
final HashMap<String, Boolean> map = new HashMap<String, Boolean>(); final HashMap<String, Boolean> map = new HashMap<String, Boolean>();
map.put("enabled", enabled); map.put("enabled", enabled);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) { public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("cacheType", cacheType); map.put("cacheType", cacheType);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -24,10 +24,12 @@ import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class HolidayHelper { public class HolidayHelper {
private final static Logger LOG = LoggerFactory.getLogger(HolidayHelper.class);
private static final String HOLIDAYS_URL = "/fineract-provider/api/v1/holidays"; private static final String HOLIDAYS_URL = "/fineract-provider/api/v1/holidays";
private static final String CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
@@ -57,14 +59,14 @@ public class HolidayHelper {
map.put("repaymentsRescheduledTo", "08 April 2013"); map.put("repaymentsRescheduledTo", "08 April 2013");
map.put("reschedulingType", 2); map.put("reschedulingType", 2);
String HolidayCreateJson = new Gson().toJson(map); String HolidayCreateJson = new Gson().toJson(map);
System.out.println(HolidayCreateJson); LOG.info("{}",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);
System.out.println(activateHoliday); LOG.info("{}",activateHoliday);
return activateHoliday; return activateHoliday;
} }
@@ -80,7 +82,7 @@ public class HolidayHelper {
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;
System.out.println("------------------------ RETRIEVING HOLIDAY BY ID -------------------------"); LOG.info("------------------------ RETRIEVING HOLIDAY BY ID -------------------------");
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_HOLIDAY_BY_ID_URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_HOLIDAY_BY_ID_URL, "");
return response; return response;
} }
@@ -26,9 +26,11 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HookHelper { public class HookHelper {
private final static Logger LOG = LoggerFactory.getLogger(HookHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -40,7 +42,7 @@ public class HookHelper {
} }
public Integer createHook(final String payloadURL) { public Integer createHook(final String payloadURL) {
System.out.println("---------------------------------CREATING A HOOK---------------------------------------------"); LOG.info("---------------------------------CREATING A HOOK---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL),
"resourceId"); "resourceId");
} }
@@ -60,31 +62,31 @@ public class HookHelper {
createOfficeEvent.put("entityName", "OFFICE"); createOfficeEvent.put("entityName", "OFFICE");
events.add(createOfficeEvent); events.add(createOfficeEvent);
map.put("events", events); map.put("events", events);
System.out.println("map : " + map); LOG.info("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---------------------------------------------"); LOG.info("---------------------------------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;
return Utils.performServerPut(this.requestSpec, this.responseSpec, UPDATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId"); return Utils.performServerPut(this.requestSpec, this.responseSpec, UPDATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId");
} }
public Integer deleteHook(final Long hookId) { public Integer deleteHook(final Long hookId) {
System.out.println("---------------------------------DELETING HOOK---------------------------------------------"); LOG.info("---------------------------------DELETING HOOK---------------------------------------------");
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"); LOG.info("------------------------------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"); LOG.info("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
ArrayList<HashMap<String, String>> map = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, this.responseSpec, GET_URL, "config"); ArrayList<HashMap<String, String>> map = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, this.responseSpec, GET_URL, "config");
HashMap<String, String> hash = (HashMap<String, String>) map.get(1); HashMap<String, String> hash = (HashMap<String, String>) map.get(1);
@@ -92,7 +94,7 @@ public class HookHelper {
} }
public void verifyDeleteHook(final Long hookId) { public void verifyDeleteHook(final Long hookId) {
System.out.println("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build(); ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build();
ArrayList<HashMap<String, String>> array = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, responseSpec404, GET_URL, "errors"); ArrayList<HashMap<String, String>> array = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, responseSpec404, GET_URL, "errors");
@@ -21,29 +21,31 @@ package org.apache.fineract.integrationtests.common;
import io.restassured.specification.RequestSpecification; import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ImageHelper { public class ImageHelper {
private final static Logger LOG = LoggerFactory.getLogger(ImageHelper.class);
private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/"; private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/";
private static final String IMAGES_URI = "/images"; private static final String IMAGES_URI = "/images";
public static Integer createImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer staffId) { Integer staffId) {
System.out.println("---------------------------------CREATING AN IMAGE FOR STAFF---------------------------------------------"); LOG.info("---------------------------------CREATING AN IMAGE FOR STAFF---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId");
} }
public static Integer updateImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer updateImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer staffId) { Integer staffId) {
System.out.println("---------------------------------UPDATING AN IMAGE FOR STAFF---------------------------------------------"); LOG.info("---------------------------------UPDATING AN IMAGE FOR STAFF---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPut(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId"); return Utils.performServerPut(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId");
} }
public static String getStaffImageAsText(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static String getStaffImageAsText(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer staffId) { Integer staffId) {
System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
requestSpec.header(HttpHeaders.ACCEPT, "text/plain"); requestSpec.header(HttpHeaders.ACCEPT, "text/plain");
return Utils.performGetTextResponse(requestSpec, responseSpec, URL); return Utils.performGetTextResponse(requestSpec, responseSpec, URL);
@@ -51,14 +53,14 @@ public class ImageHelper {
public static byte[] getStaffImageAsBinary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static byte[] getStaffImageAsBinary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer staffId) { Integer staffId) {
System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
requestSpec.header(HttpHeaders.ACCEPT, "application/octet-stream"); requestSpec.header(HttpHeaders.ACCEPT, "application/octet-stream");
return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL); return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL);
} }
public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) {
System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId");
} }
@@ -20,9 +20,11 @@ package org.apache.fineract.integrationtests.common;
import io.restassured.specification.RequestSpecification; import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NotificationHelper { public class NotificationHelper {
private final static Logger LOG = LoggerFactory.getLogger(NotificationHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -36,7 +38,7 @@ public class NotificationHelper {
public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String jsonReturn) { final String jsonReturn) {
final String GET_NOTIFICATIONS_URL = NOTIFICATION_API_URL; final String GET_NOTIFICATIONS_URL = NOTIFICATION_API_URL;
System.out.println("-----------------------------GET NOTIFICATIONS-----------------------------------"); LOG.info("-----------------------------GET NOTIFICATIONS-----------------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_NOTIFICATIONS_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_NOTIFICATIONS_URL, "");
} }
} }
@@ -31,9 +31,11 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OfficeHelper { public class OfficeHelper {
private final static Logger LOG = LoggerFactory.getLogger(OfficeHelper.class);
private static final String OFFICE_URL = "/fineract-provider/api/v1/offices"; private static final String OFFICE_URL = "/fineract-provider/api/v1/offices";
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -67,7 +69,7 @@ public class OfficeHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("openingDate", openingDate); map.put("openingDate", openingDate);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL
+ "/" + id + "?" + Utils.TENANT_IDENTIFIER, + "/" + id + "?" + Utils.TENANT_IDENTIFIER,
@@ -81,7 +83,7 @@ public class OfficeHelper {
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en"); map.put("locale", "en");
map.put("openingDate", openingDate); map.put("openingDate", openingDate);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -27,18 +27,20 @@ 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,
String validationPolicyId) { final ResponseSpecification responseSpec, 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
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesAsJson(validationPolicyId), ""); // PREFERENCE---------------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL,
updatePreferencesAsJson(validationPolicyId), "");
} }
public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec, public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,String invalidValidationPolicyId, String jsonAttributeToGetback) { final ResponseSpecification responseSpec,String invalidValidationPolicyId, String jsonAttributeToGetback) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out //system.out
.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------"); //.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId), return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId),
jsonAttributeToGetback); jsonAttributeToGetback);
} }
@@ -55,14 +57,17 @@ public class PasswordPreferencesHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static int getActivePasswordPreference(final RequestSpecification requestSpec,
public static int getActivePasswordPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id"); return Utils.performServerGet(requestSpec, responseSpec,
PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id");
} }
public static HashMap<String, Object> getAllPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static HashMap<String, Object> getAllPreferences(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER, ""); return Utils.performServerGet(requestSpec, responseSpec,
PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER, "");
} }
@@ -29,58 +29,72 @@ import java.util.HashMap;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class PaymentTypeHelper { public class PaymentTypeHelper {
private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?"
+ Utils.TENANT_IDENTIFIER;
private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes"; private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes";
public static Integer createPaymentType(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createPaymentType(final RequestSpecification requestSpec,
final String name, final String description, final Boolean isCashPayment, final Integer position) { final ResponseSpecification responseSpec, final String name, final String description,
System.out.println("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------"); final Boolean isCashPayment, final Integer position) {
// system.out.println("---------------------------------CREATING A PAYMENT
// TYPE---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL,
getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId"); getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId");
} }
public static String getJsonToCreatePaymentType(final String name, final String description, final Boolean isCashPayment, public static String getJsonToCreatePaymentType(final String name, final String description,
final Integer position) { final Boolean isCashPayment, final Integer position) {
HashMap hm = new HashMap(); HashMap hm = new HashMap();
hm.put("name", name); hm.put("name", name);
if (description != null) hm.put("description", description); if (description != null)
hm.put("description", description);
hm.put("isCashPayment", isCashPayment); hm.put("isCashPayment", isCashPayment);
if (position != null) hm.put("position", position); if (position != null)
hm.put("position", position);
System.out.println("------------------------CREATING PAYMENT TYPE-------------------------" + hm); // system.out.println("------------------------CREATING PAYMENT
// TYPE-------------------------" + hm);
return new Gson().toJson(hm); return new Gson().toJson(hm);
} }
public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec,
final Integer generatedPaymentTypeID) { final ResponseSpecification responseSpec, final Integer generatedPaymentTypeID) {
System.out.println("------------------------------CHECK PAYMENT DETAILS------------------------------------\n"); // system.out.println("------------------------------CHECK PAYMENT
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER; // DETAILS------------------------------------\n");
final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id"); final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?"
+ Utils.TENANT_IDENTIFIER;
final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL,
"id");
assertEquals("ERROR IN CREATING THE PAYMENT TYPE", generatedPaymentTypeID, responsePaymentTypeID); assertEquals("ERROR IN CREATING THE PAYMENT TYPE", generatedPaymentTypeID, responsePaymentTypeID);
} }
public static PaymentTypeDomain retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec, public static PaymentTypeDomain retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec,
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());
} }
public static HashMap<String, String> updatePaymentType(final int id, HashMap request, final RequestSpecification requestSpec, public static HashMap<String, String> updatePaymentType(final int id, HashMap request,
final ResponseSpecification responseSpec) { final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE PAYMENT TYPE " + id + "---------------------------------------------"); // system.out.println("---------------------------------UPDATE PAYMENT TYPE " +
// id + "---------------------------------------------");
HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL, HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL,
new Gson().toJson(request), "changes"); new Gson().toJson(request), "changes");
return hash; return hash;
} }
public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------DELETING PAYMENT TYPE " + id + "--------------------------------------------"); // system.out.println("---------------------------------DELETING PAYMENT TYPE "
// + id + "--------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId");
} }
@@ -44,10 +44,12 @@ import org.junit.Assert;
import org.junit.Assume; import org.junit.Assume;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class ProvisioningIntegrationTest { public class ProvisioningIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ProvisioningIntegrationTest.class);
private static final String NONE = "1"; private static final String NONE = "1";
private final static int LOANPRODUCTS_SIZE = 10; private final static int LOANPRODUCTS_SIZE = 10;
@@ -84,7 +86,7 @@ public class ProvisioningIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loans.add(loanID); loans.add(loanID);
@@ -181,7 +183,7 @@ public class ProvisioningIntegrationTest {
} }
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() // LoanProductTestBuilder builder = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") // .withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -203,7 +205,7 @@ public class ProvisioningIntegrationTest {
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges, private Integer 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--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) // .withPrincipal(principal) //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -31,10 +31,12 @@ import java.util.Map;
import java.util.function.ToIntFunction; import java.util.function.ToIntFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.junit.Assert; import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class SchedulerJobHelper { public class SchedulerJobHelper {
private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification response200Spec; private final ResponseSpecification response200Spec;
private final ResponseSpecification response202Spec; private final ResponseSpecification response202Spec;
@@ -53,7 +55,7 @@ public class SchedulerJobHelper {
private List getAllSchedulerJobs() { private List getAllSchedulerJobs() {
final String GET_ALL_SCHEDULER_JOBS_URL = "/fineract-provider/api/v1/jobs?" + Utils.TENANT_IDENTIFIER; final String GET_ALL_SCHEDULER_JOBS_URL = "/fineract-provider/api/v1/jobs?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING ALL SCHEDULER JOBS -------------------------"); LOG.info("------------------------ RETRIEVING ALL SCHEDULER JOBS -------------------------");
final ArrayList response = Utils.performServerGet(requestSpec, response200Spec, GET_ALL_SCHEDULER_JOBS_URL, ""); final ArrayList response = Utils.performServerGet(requestSpec, response200Spec, GET_ALL_SCHEDULER_JOBS_URL, "");
return response; return response;
} }
@@ -65,16 +67,16 @@ public class SchedulerJobHelper {
public Map<String, Object> getSchedulerJobById(int jobId) { public Map<String, Object> getSchedulerJobById(int jobId) {
final String GET_SCHEDULER_JOB_BY_ID_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER; final String GET_SCHEDULER_JOB_BY_ID_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------"); LOG.info("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------");
final Map<String, Object> response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_JOB_BY_ID_URL, ""); final Map<String, Object> response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_JOB_BY_ID_URL, "");
System.out.println(response); LOG.info("{}",response.toString());
assertNotNull(response); assertNotNull(response);
return response; return response;
} }
public Boolean getSchedulerStatus() { public Boolean getSchedulerStatus() {
final String GET_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/scheduler?" + Utils.TENANT_IDENTIFIER; final String GET_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/scheduler?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING SCHEDULER STATUS -------------------------"); LOG.info("------------------------ RETRIEVING SCHEDULER STATUS -------------------------");
final Map<String, Object> response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_STATUS_URL, ""); final Map<String, Object> response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_STATUS_URL, "");
return (Boolean) response.get("active"); return (Boolean) response.get("active");
} }
@@ -82,13 +84,13 @@ public class SchedulerJobHelper {
public void updateSchedulerStatus(final boolean on) { public void updateSchedulerStatus(final boolean on) {
String command = on ? "start" : "stop"; String command = on ? "start" : "stop";
final String UPDATE_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/scheduler?command=" + command + "&" + Utils.TENANT_IDENTIFIER; final String UPDATE_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/scheduler?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ UPDATING SCHEDULER STATUS -------------------------"); LOG.info("------------------------ UPDATING SCHEDULER STATUS -------------------------");
Utils.performServerPost(requestSpec, response202Spec, UPDATE_SCHEDULER_STATUS_URL, runSchedulerJobAsJSON(), null); Utils.performServerPost(requestSpec, response202Spec, UPDATE_SCHEDULER_STATUS_URL, runSchedulerJobAsJSON(), null);
} }
public Map<String, Object> updateSchedulerJob(int jobId, final String active) { public Map<String, Object> updateSchedulerJob(int jobId, final String active) {
final String UPDATE_SCHEDULER_JOB_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_SCHEDULER_JOB_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ UPDATING SCHEDULER JOB -------------------------"); LOG.info("------------------------ UPDATING SCHEDULER JOB -------------------------");
final Map<String, Object> response = Utils.performServerPut(requestSpec, response200Spec, UPDATE_SCHEDULER_JOB_URL, final Map<String, Object> response = Utils.performServerPut(requestSpec, response200Spec, UPDATE_SCHEDULER_JOB_URL,
updateSchedulerJobAsJSON(active), "changes"); updateSchedulerJobAsJSON(active), "changes");
return response; return response;
@@ -97,13 +99,13 @@ public class SchedulerJobHelper {
private static String updateSchedulerJobAsJSON(final String active) { private static String updateSchedulerJobAsJSON(final String active) {
final Map<String, String> map = new HashMap<>(); final Map<String, String> map = new HashMap<>();
map.put("active", active); map.put("active", active);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public List getSchedulerJobHistory(int jobId) { public List getSchedulerJobHistory(int jobId) {
final String GET_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/jobs/" + jobId + "/runhistory?" + Utils.TENANT_IDENTIFIER; final String GET_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/jobs/" + jobId + "/runhistory?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING SCHEDULER JOB HISTORY -------------------------"); LOG.info("------------------------ RETRIEVING SCHEDULER JOB HISTORY -------------------------");
final Map response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_STATUS_URL, ""); final Map response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_STATUS_URL, "");
return (ArrayList) response.get("pageItems"); return (ArrayList) response.get("pageItems");
} }
@@ -111,14 +113,14 @@ public class SchedulerJobHelper {
public static void runSchedulerJob(final RequestSpecification requestSpec, final String jobId) { public static void runSchedulerJob(final RequestSpecification requestSpec, final String jobId) {
final ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(202).build(); final ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(202).build();
final String RUN_SCHEDULER_JOB_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?command=executeJob&" + Utils.TENANT_IDENTIFIER; final String RUN_SCHEDULER_JOB_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?command=executeJob&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RUN SCHEDULER JOB -------------------------"); LOG.info("------------------------ RUN SCHEDULER JOB -------------------------");
Utils.performServerPost(requestSpec, responseSpec, RUN_SCHEDULER_JOB_URL, runSchedulerJobAsJSON(), null); Utils.performServerPost(requestSpec, responseSpec, RUN_SCHEDULER_JOB_URL, runSchedulerJobAsJSON(), null);
} }
private static String runSchedulerJobAsJSON() { private static String runSchedulerJobAsJSON() {
final Map<String, String> map = new HashMap<>(); final Map<String, String> map = new HashMap<>();
String runSchedulerJob = new Gson().toJson(map); String runSchedulerJob = new Gson().toJson(map);
System.out.println(runSchedulerJob); LOG.info(runSchedulerJob);
return runSchedulerJob; return runSchedulerJob;
} }
@@ -142,7 +144,7 @@ public class SchedulerJobHelper {
Thread.sleep(15000); Thread.sleep(15000);
schedulerJob = getSchedulerJobById(jobId); schedulerJob = getSchedulerJobById(jobId);
Assert.assertNotNull(schedulerJob); Assert.assertNotNull(schedulerJob);
System.out.println("Job is Still Running"); LOG.info("Job is Still Running");
} }
List<Map> jobHistoryData = getSchedulerJobHistory(jobId); List<Map> jobHistoryData = getSchedulerJobHistory(jobId);
@@ -150,10 +152,10 @@ public class SchedulerJobHelper {
Assert.assertFalse("Job History is empty :( Was it too slow? Failures in background job?", jobHistoryData.isEmpty()); Assert.assertFalse("Job History is empty :( Was it too slow? Failures in background job?", jobHistoryData.isEmpty());
// print error associated with recent job failure (if any) // print error associated with recent job failure (if any)
System.out.println("Job run error message (printed only if the job fails: " LOG.info("Job run error message (printed only if the job fails: {}"
+ jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorMessage")); , jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorMessage"));
System.out.println("Job failure error log (printed only if the job fails: " LOG.info("Job failure error log (printed only if the job fails: {}"
+ jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorLog")); , jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorLog"));
// Verifying the Status of the Recently executed Scheduler Job // Verifying the Status of the Recently executed Scheduler Job
Assert.assertEquals("Verifying Last Scheduler Job Status", "success", Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
@@ -23,10 +23,12 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"unused", "rawtypes", "unchecked" }) @SuppressWarnings({"unused", "rawtypes", "unchecked" })
public class StandingInstructionsHelper { public class StandingInstructionsHelper {
private final static Logger LOG = LoggerFactory.getLogger(StandingInstructionsHelper.class);
private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions"; private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions";
private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory"; private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory";
private static final String LOCALE = "en_GB"; private static final String LOCALE = "en_GB";
@@ -88,13 +90,13 @@ public class StandingInstructionsHelper {
map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS); map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS);
map.put("recurrenceOnMonthDay", monthDay); map.put("recurrenceOnMonthDay", monthDay);
String savingsApplicationJSON = new Gson().toJson(map); String savingsApplicationJSON = new Gson().toJson(map);
System.out.println(savingsApplicationJSON); LOG.info("{}",savingsApplicationJSON);
return savingsApplicationJSON; return savingsApplicationJSON;
} }
public Integer createStandingInstruction(final String clientId, final String fromAccountId, final String toAccountId, public Integer createStandingInstruction(final String clientId, final String fromAccountId, final String toAccountId,
final String fromAccountType, final String toAccountType, final String validFrom, final String validTo, final String monthDay) { final String fromAccountType, final String toAccountType, final String validFrom, final String validTo, final String monthDay) {
System.out.println("-------------------------------- CREATE STANDING INSTRUCTIONS --------------------------------"); LOG.info("-------------------------------- CREATE STANDING INSTRUCTIONS --------------------------------");
final String standingInstructionAsJSON = new StandingInstructionsHelper(this.requestSpec, this.responseSpec) // final String standingInstructionAsJSON = new StandingInstructionsHelper(this.requestSpec, this.responseSpec) //
.build(clientId.toString(), fromAccountId.toString(), toAccountId.toString(), fromAccountType, toAccountType, validFrom, .build(clientId.toString(), fromAccountId.toString(), toAccountId.toString(), fromAccountType, toAccountType, validFrom,
validTo, monthDay); validTo, monthDay);
@@ -104,7 +106,7 @@ public class StandingInstructionsHelper {
public HashMap getStandingInstructionById(final String standingInstructionId) { public HashMap getStandingInstructionById(final String standingInstructionId) {
System.out.println("----------------------------- RETRIEVING STANDING INSTRUCTION BY ID---------------------------"); LOG.info("----------------------------- RETRIEVING STANDING INSTRUCTION BY ID---------------------------");
final String GET_STANDING_INSTRUCTION_BY_ID_URL = STANDING_INSTRUCTIONS_URL + "/" + standingInstructionId + "?" final String GET_STANDING_INSTRUCTION_BY_ID_URL = STANDING_INSTRUCTIONS_URL + "/" + standingInstructionId + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_STANDING_INSTRUCTION_BY_ID_URL, ""); final HashMap response = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_STANDING_INSTRUCTION_BY_ID_URL, "");
@@ -115,7 +117,7 @@ public class StandingInstructionsHelper {
final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId
+ "&transferType=" + transferType; + "&transferType=" + transferType;
System.out.println("STANDING_INSTRUCTIONS_HISTORY_URL="+STANDING_INSTRUCTIONS_HISTORY_URL); LOG.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}",STANDING_INSTRUCTIONS_HISTORY_URL);
final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec, final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec,
STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems"); STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems");
return response; return response;
@@ -24,9 +24,11 @@ import com.google.gson.Gson;
import io.restassured.specification.RequestSpecification; import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SurveyHelper { public class SurveyHelper {
private final static Logger LOG = LoggerFactory.getLogger(SurveyHelper.class);
private static final String FULFIL_SURVEY_URL = "/fineract-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER; private static final String FULFIL_SURVEY_URL = "/fineract-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER;
public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
@@ -35,7 +37,7 @@ public class SurveyHelper {
public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate) { final String activationDate) {
System.out.println("---------------------------------FULFIL PPI ---------------------------------------------"); LOG.info("---------------------------------FULFIL PPI ---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec,FULFIL_SURVEY_URL, getTestPPIAsJSON(), "clientId"); return Utils.performServerPost(requestSpec, responseSpec,FULFIL_SURVEY_URL, getTestPPIAsJSON(), "clientId");
} }
@@ -57,13 +59,13 @@ public class SurveyHelper {
map.put("ppi_towels_cd_q9_towels", "134"); map.put("ppi_towels_cd_q9_towels", "134");
map.put("ppi_fryingpans_cd_q10_fryingpans", "138"); map.put("ppi_fryingpans_cd_q10_fryingpans", "138");
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedClientID) { final Integer generatedClientID) {
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER; final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id"); final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id");
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID); assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
@@ -23,14 +23,16 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.Account;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TaxComponentHelper { public class TaxComponentHelper {
private final static Logger LOG = LoggerFactory.getLogger(TaxComponentHelper.class);
private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/component?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/component?" + Utils.TENANT_IDENTIFIER;
public static Integer createTaxComponent(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createTaxComponent(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String percentage, final Integer liabilityAccountId) { final String percentage, final Integer liabilityAccountId) {
System.out.println("---------------------------------CREATING A TAX COMPONENT---------------------------------------------"); LOG.info("---------------------------------CREATING A TAX COMPONENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL,
getTaxComponentAsJSON(percentage, liabilityAccountId), "resourceId"); getTaxComponentAsJSON(percentage, liabilityAccountId), "resourceId");
} }
@@ -41,7 +43,7 @@ public class TaxComponentHelper {
map.put("creditAccountType", Account.AccountType.LIABILITY.toString()); map.put("creditAccountType", Account.AccountType.LIABILITY.toString());
map.put("creditAcountId", String.valueOf(creditAccountId)); map.put("creditAcountId", String.valueOf(creditAccountId));
} }
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -25,14 +25,16 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TaxGroupHelper { public class TaxGroupHelper {
private final static Logger LOG = LoggerFactory.getLogger(TaxGroupHelper.class);
private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/group?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/group?" + Utils.TENANT_IDENTIFIER;
public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Collection<Integer> taxComponentIds) { final Collection<Integer> taxComponentIds) {
System.out.println("---------------------------------CREATING A TAX GROUP---------------------------------------------"); LOG.info("---------------------------------CREATING A TAX GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds), "resourceId");
} }
@@ -61,7 +61,7 @@ public class Utils {
public static final String TENANT_TIME_ZONE = "Asia/Kolkata"; public static final String TENANT_TIME_ZONE = "Asia/Kolkata";
private static final String HEALTH_URL = "/fineract-provider/actuator/health"; private static final String HEALTH_URL = "/fineract-provider/actuator/health";
private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER; private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER;
public static void initializeRESTAssured() { public static void initializeRESTAssured() {
RestAssured.baseURI = "https://localhost"; RestAssured.baseURI = "https://localhost";
@@ -83,11 +83,13 @@ public class Utils {
logger.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL); logger.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL);
return; return;
} else { } else {
logger.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, healthHttpStatus, attempt++); logger.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL,
healthHttpStatus, attempt++);
sleep(3); sleep(3);
} }
} catch (Exception e) { } catch (Exception e) {
logger.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), attempt++); logger.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(),
attempt++);
lastException = e; lastException = e;
sleep(3); sleep(3);
} }
@@ -97,7 +99,8 @@ public class Utils {
logger.error("{} still not reachable, giving up", HEALTH_URL, lastException); logger.error("{} still not reachable, giving up", HEALTH_URL, lastException);
throw new AssertionError(HEALTH_URL + " not reachable", lastException); throw new AssertionError(HEALTH_URL + " not reachable", lastException);
} else { } else {
logger.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, response.prettyPrint()); logger.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL,
response.prettyPrint());
fail(HEALTH_URL + " returned " + response.prettyPrint()); fail(HEALTH_URL + " returned " + response.prettyPrint());
} }
} }
@@ -115,10 +118,10 @@ public class Utils {
awaitSpringBootActuatorHealthyUp(); awaitSpringBootActuatorHealthyUp();
try { try {
logger.info("Logging in, for integration test..."); logger.info("Logging in, for integration test...");
System.out.println("-----------------------------------LOGIN-----------------------------------------"); // system.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.given().contentType(ContentType.JSON) String json = RestAssured.given().contentType(ContentType.JSON)
.body("{\"username\":\"mifos\", \"password\":\"password\"}") .body("{\"username\":\"mifos\", \"password\":\"password\"}").expect().log().ifError().when()
.expect().log().ifError().when().post(LOGIN_URL).asString(); .post(LOGIN_URL).asString();
assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false)); assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false));
String key = JsonPath.with(json).get("base64EncodedAuthenticationKey"); String key = JsonPath.with(json).get("base64EncodedAuthenticationKey");
assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false)); assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false));
@@ -133,49 +136,59 @@ public class Utils {
} }
} }
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static <T> T performServerGet(final RequestSpecification requestSpec,
final String getURL, final String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final String getURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString(); final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL)
if (jsonAttributeToGetBack == null) { return (T) json; }
return (T) from(json).get(jsonAttributeToGetBack);
}
public static String performGetTextResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String getURL){
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
}
public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String getURL){
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asByteArray();
}
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
.andReturn().asString(); .andReturn().asString();
if (jsonAttributeToGetBack == null) { return (T) json; } if (jsonAttributeToGetBack == null) {
return (T) json;
}
return (T) from(json).get(jsonAttributeToGetBack); return (T) from(json).get(jsonAttributeToGetBack);
} }
public static <T> T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static String performGetTextResponse(final RequestSpecification requestSpec,
final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final String getURL) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().put(putURL) return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn()
.andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String deleteURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().delete(deleteURL).andReturn()
.asString(); .asString();
}
public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String getURL) {
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn()
.asByteArray();
}
public static <T> T performServerPost(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String postURL, final String jsonBodyToSend,
final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().post(postURL).andReturn().asString();
if (jsonAttributeToGetBack == null) {
return (T) json;
}
return (T) from(json).get(jsonAttributeToGetBack); return (T) from(json).get(jsonAttributeToGetBack);
} }
public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static <T> T performServerPut(final RequestSpecification requestSpec,
final String deleteURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final String putURL, final String jsonBodyToSend,
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when() final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().put(putURL).andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String deleteURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when()
.delete(deleteURL).andReturn().asString(); .delete(deleteURL).andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String deleteURL, final String jsonBodyToSend,
final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().delete(deleteURL).andReturn().asString();
return (T) (jsonAttributeToGetBack == null ? json : from(json).get(jsonAttributeToGetBack)); return (T) (jsonAttributeToGetBack == null ? json : from(json).get(jsonAttributeToGetBack));
} }
@@ -208,11 +221,12 @@ public class Utils {
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) { public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
return randomStringGenerator(prefix, lenOfRandomSuffix); return randomStringGenerator(prefix, lenOfRandomSuffix);
} }
public static Long randomNumberGenerator(final int expectedLength){
final String source="1234567890"; public static Long randomNumberGenerator(final int expectedLength) {
final int lengthofSource=source.length(); final String source = "1234567890";
final Random random=new Random(); final int lengthofSource = source.length();
StringBuilder stringBuilder=new StringBuilder(expectedLength); final Random random = new Random();
StringBuilder stringBuilder = new StringBuilder(expectedLength);
for (int i = 0; i < expectedLength; i++) { for (int i = 0; i < expectedLength; i++) {
stringBuilder.append(source.charAt(random.nextInt(lengthofSource))); stringBuilder.append(source.charAt(random.nextInt(lengthofSource)));
} }
@@ -238,28 +252,20 @@ public class Utils {
return TimeZone.getTimeZone(TENANT_TIME_ZONE); return TimeZone.getTimeZone(TENANT_TIME_ZONE);
} }
public static String performServerTemplatePost(final RequestSpecification requestSpec,final ResponseSpecification responseSpec, public static String performServerTemplatePost(final RequestSpecification requestSpec,
final String postURL,final String legalFormType,final File file,final String locale,final String dateFormat) { final ResponseSpecification responseSpec, final String postURL, final String legalFormType, final File file,
final String locale, final String dateFormat) {
final String importDocumentId=given().spec(requestSpec) final String importDocumentId = given().spec(requestSpec).queryParam("legalFormType", legalFormType)
.queryParam("legalFormType",legalFormType) .multiPart("file", file).formParam("locale", locale).formParam("dateFormat", dateFormat).expect()
.multiPart("file",file) .spec(responseSpec).log().ifError().when().post(postURL).andReturn().asString();
.formParam("locale",locale)
.formParam("dateFormat",dateFormat)
.expect().spec(responseSpec).
log().ifError().when().post(postURL)
.andReturn().asString();
return importDocumentId; return importDocumentId;
} }
public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec,final ResponseSpecification responseSpec, public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec,
final String getURL,final String importDocumentId){ final ResponseSpecification responseSpec, final String getURL, final String importDocumentId) {
final String templateLocation=given().spec(requestSpec). final String templateLocation = given().spec(requestSpec).queryParam("importDocumentId", importDocumentId)
queryParam("importDocumentId",importDocumentId) .expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
.expect().spec(responseSpec) return templateLocation.substring(1, templateLocation.length() - 1);
.log().ifError().when().get(getURL)
.andReturn().asString();
return templateLocation.substring(1,templateLocation.length()-1);
} }
} }
@@ -23,22 +23,23 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import java.util.Random; import java.util.Random;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WorkingDaysHelper { public class WorkingDaysHelper {
private final static Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class);
private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays"; private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays";
public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE WORKINGDAY---------------------------------------------"); LOG.info("---------------------------------UPDATE WORKINGDAY---------------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDaysAsJson(), ""); return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDaysAsJson(), "");
} }
public static Object updateWorkingDaysWithWrongRecurrence(final RequestSpecification requestSpec, public static Object updateWorkingDaysWithWrongRecurrence(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, String jsonAttributeToGetback) { final ResponseSpecification responseSpec, String jsonAttributeToGetback) {
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out LOG.info("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
.println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(), return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(),
jsonAttributeToGetback); jsonAttributeToGetback);
} }
@@ -49,7 +50,7 @@ public class WorkingDaysHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false); map.put("extendTermForDailyRepayments", false);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -59,7 +60,7 @@ public class WorkingDaysHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false); map.put("extendTermForDailyRepayments", false);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -26,10 +26,12 @@ import java.util.HashMap;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType; import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class ChargesHelper { public class ChargesHelper {
private final static Logger LOG = LoggerFactory.getLogger(ChargesHelper.class);
private static final String CHARGES_URL = "/fineract-provider/api/v1/charges"; private static final String CHARGES_URL = "/fineract-provider/api/v1/charges";
private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER;
@@ -48,9 +50,9 @@ public class ChargesHelper {
private static final Integer CHARGE_OVERDUE_INSTALLMENT_FEE = 9; private static final Integer CHARGE_OVERDUE_INSTALLMENT_FEE = 9;
private static final Integer CHARGE_OVERDRAFT_FEE = 10; private static final Integer CHARGE_OVERDRAFT_FEE = 10;
private static final Integer WEEKLY_FEE = 11; private static final Integer WEEKLY_FEE = 11;
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;
@@ -81,7 +83,7 @@ public class ChargesHelper {
map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE); map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -101,7 +103,7 @@ public class ChargesHelper {
final HashMap<String, Object> map = populateDefaultsForSavings(amount.toString(), currencyCode); final HashMap<String, Object> map = populateDefaultsForSavings(amount.toString(), currencyCode);
map.put("chargeTimeType", timeType.getValue()); map.put("chargeTimeType", timeType.getValue());
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -110,7 +112,7 @@ public class ChargesHelper {
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay); map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay);
map.put("chargeTimeType", CHARGE_ANNUAL_FEE); map.put("chargeTimeType", CHARGE_ANNUAL_FEE);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -120,7 +122,7 @@ public class ChargesHelper {
map.put("chargeTimeType", CHARGE_MONTHLY_FEE); map.put("chargeTimeType", CHARGE_MONTHLY_FEE);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -129,7 +131,7 @@ public class ChargesHelper {
map.put("chargeTimeType", WEEKLY_FEE); map.put("chargeTimeType", WEEKLY_FEE);
map.put("feeInterval", 1); map.put("feeInterval", 1);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -137,7 +139,7 @@ public class ChargesHelper {
final HashMap<String, Object> map = populateDefaultsForSavings(); final HashMap<String, Object> map = populateDefaultsForSavings();
map.put("chargeTimeType", CHARGE_OVERDRAFT_FEE); map.put("chargeTimeType", CHARGE_OVERDRAFT_FEE);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -166,31 +168,37 @@ public class ChargesHelper {
return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, final String amount) { public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType,
return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); final String amount) {
return getLoanDisbursementJSON(chargeCalculationType, amount,
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount, final Integer paymentmode) { public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount,
final Integer paymentmode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE); map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE);
map.put("chargePaymentMode", paymentmode); map.put("chargePaymentMode", paymentmode);
map.put("amount", amount); map.put("amount", amount);
map.put("chargeCalculationType", chargeCalculationType); map.put("chargeCalculationType", chargeCalculationType);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanSpecifiedDueDateJSON() { public static String getLoanSpecifiedDueDateJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, ChargesHelper.penalty); return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount,
ChargesHelper.penalty);
} }
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, boolean penalty) { public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount,
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); boolean penalty) {
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, final boolean penalty, public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount,
final Integer paymentMode) { final boolean penalty, final Integer paymentMode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE); map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE);
map.put("chargePaymentMode", paymentMode); map.put("chargePaymentMode", paymentMode);
@@ -199,26 +207,29 @@ public class ChargesHelper {
map.put("chargeCalculationType", chargeCalculationType); map.put("chargeCalculationType", chargeCalculationType);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, final String amount, public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType,
boolean penalty) { final String amount, boolean penalty) {
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty,
}
public static String getLoanSpecifiedDueDateWithAccountTransferJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, ChargesHelper.penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, boolean penalty) { public static String getLoanSpecifiedDueDateWithAccountTransferJSON() {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount,
ChargesHelper.penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, final boolean penalty, public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount,
final Integer paymentMode) { boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
}
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount,
final boolean penalty, final Integer paymentMode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE); map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE);
map.put("chargePaymentMode", paymentMode); map.put("chargePaymentMode", paymentMode);
@@ -227,36 +238,39 @@ public class ChargesHelper {
map.put("chargeCalculationType", chargeCalculationType); map.put("chargeCalculationType", chargeCalculationType);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, final String amount, boolean penalty) { public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType,
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); final String amount, boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanInstallmentFeeJSON() { public static String getLoanInstallmentFeeJSON() {
return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, ChargesHelper.penalty); return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount,
ChargesHelper.penalty);
} }
public static String getShareAccountActivationChargeJson() { public static String getShareAccountActivationChargeJson() {
HashMap<String, Object> map = populateDefaultsShareActivationCharge() ; HashMap<String, Object> map = populateDefaultsShareActivationCharge();
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", 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); LOG.info("{}", 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); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -269,7 +283,7 @@ public class ChargesHelper {
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay); map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -281,7 +295,7 @@ public class ChargesHelper {
map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE); map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson); LOG.info("{}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
@@ -304,7 +318,7 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_CLIENT); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_CLIENT);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType",ChargesHelper.CHARGE_SPECIFIED_DUE_DATE); map.put("chargeTimeType", ChargesHelper.CHARGE_SPECIFIED_DUE_DATE);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.currencyCode);
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
map.put("monthDayFormat", ChargesHelper.monthDayFormat); map.put("monthDayFormat", ChargesHelper.monthDayFormat);
@@ -318,7 +332,7 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType",ChargesHelper.SHAREACCOUNT_ACTIVATION); map.put("chargeTimeType", ChargesHelper.SHAREACCOUNT_ACTIVATION);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.currencyCode);
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8));
@@ -331,7 +345,7 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType",ChargesHelper.SHARE_PURCHASE); map.put("chargeTimeType", ChargesHelper.SHARE_PURCHASE);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.currencyCode);
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8));
@@ -344,43 +358,47 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType",ChargesHelper.SHARE_REDEEM); map.put("chargeTimeType", ChargesHelper.SHARE_REDEEM);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.currencyCode);
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
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 String request) { final ResponseSpecification responseSpec, final String request) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
} }
public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec,
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, ""); final ResponseSpecification responseSpec) {
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec,
CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
} }
public static HashMap getChargeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getChargeById(final RequestSpecification requestSpec,
final Integer chargeId) { final ResponseSpecification responseSpec, final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, ""); return Utils.performServerGet(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
} }
public static HashMap getChargeChanges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getChargeChanges(final RequestSpecification requestSpec,
final Integer chargeId) { final ResponseSpecification responseSpec, final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, return Utils.performServerGet(requestSpec, responseSpec,
CommonConstants.RESPONSE_CHANGES); CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_CHANGES);
} }
public static HashMap updateCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap updateCharges(final RequestSpecification requestSpec,
final Integer chargeId, final String request) { final ResponseSpecification responseSpec, final Integer chargeId, final String request) {
return Utils.performServerPut(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request, return Utils.performServerPut(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec, public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec,
final Integer chargeId) { final Integer chargeId) {
return Utils.performServerDelete(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, return Utils.performServerDelete(requestSpec, responseSpec,
CommonConstants.RESPONSE_RESOURCE_ID); CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static String getModifyChargeJSON() { public static String getModifyChargeJSON() {
@@ -388,7 +406,7 @@ public class ChargesHelper {
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
map.put("amount", "200.0"); map.put("amount", "200.0");
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -397,7 +415,7 @@ public class ChargesHelper {
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT); map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -407,7 +425,7 @@ public class ChargesHelper {
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT); map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -417,7 +435,7 @@ public class ChargesHelper {
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST); map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -427,7 +445,7 @@ public class ChargesHelper {
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST); map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST);
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -437,7 +455,7 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_DAYS); map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_DAYS);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -447,7 +465,7 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_WEEKS); map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_WEEKS);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -457,7 +475,7 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS); map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -467,19 +485,21 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_YEARS); map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_YEARS);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", 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);
System.out.println("chargesCreateJson:"+chargesCreateJson); LOG.info("chargesCreateJson: {}", chargesCreateJson);
return chargesCreateJson; return chargesCreateJson;
} }
public static String applyCharge(RequestSpecification requestSpec,ResponseSpecification responseSpec, String chargeId,String json) { public static String applyCharge(RequestSpecification requestSpec, ResponseSpecification responseSpec,
return Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json,"status"); String chargeId, String json) {
return Utils.performServerPost(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json, "status");
} }
} }
@@ -26,10 +26,12 @@ import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositAccountHelper { public class FixedDepositAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -39,7 +41,8 @@ public class FixedDepositAccountHelper {
} }
private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts"; private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts";
private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?"
+ Utils.TENANT_IDENTIFIER;
private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve"; private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve";
private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval"; private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval";
private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject"; private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject";
@@ -126,21 +129,22 @@ public class FixedDepositAccountHelper {
map.put("transferInterestToSavings", transferInterest); map.put("transferInterestToSavings", transferInterest);
String fixedDepositAccountJson = new Gson().toJson(map); String fixedDepositAccountJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountJson); LOG.info("{}", fixedDepositAccountJson);
return fixedDepositAccountJson; return fixedDepositAccountJson;
} }
public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, final RequestSpecification requestSpec, public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson,
final ResponseSpecification responseSpec) { final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
System.out.println("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------"); LOG.info("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, fixedDepositAccountAsJson, return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL,
CommonConstants.RESPONSE_RESOURCE_ID); fixedDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec,
final Integer accountID) { final ResponseSpecification responseSpec, final Integer accountID) {
final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER; final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
System.out.println("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------"); + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, "");
} }
@@ -173,8 +177,8 @@ public class FixedDepositAccountHelper {
return annualInterestRate; return annualInterestRate;
} }
public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Integer depositPeriod, public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal,
double interestPerDay, Integer compoundingInterval, Integer postingInterval) { Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval) {
Float totalInterest = 0.0f; Float totalInterest = 0.0f;
Float interestEarned = 0.0f; Float interestEarned = 0.0f;
@@ -194,7 +198,7 @@ public class FixedDepositAccountHelper {
principal += totalInterest; principal += totalInterest;
} }
totalInterest = 0.0f; totalInterest = 0.0f;
System.out.println(principal); LOG.info("{}", principal.toString());
} }
currentDate.add(Calendar.MONTH, 1); currentDate.add(Calendar.MONTH, 1);
@@ -203,21 +207,23 @@ public class FixedDepositAccountHelper {
return principal; return principal;
} }
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom, public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID,
final String validTo, final String penalInterestType, final String submittedOnDate) { final String validFrom, final String validTo, final String penalInterestType,
final String submittedOnDate) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) // .withSubmittedOnDate(submittedOnDate) //
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" return Utils.performServerPut(this.requestSpec, this.responseSpec,
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
} }
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID, public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID,
final String submittedOnDate, final String validFrom, final String validTo, final String numberOfDaysPerYear, final String accountID, final String submittedOnDate, final String validFrom, final String validTo,
final String penalInterestType, final String interestCalculationType, final String interestCompoundingPeriodType, final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType,
final String interestPostingPeriodType) { final String interestCompoundingPeriodType, final String interestPostingPeriodType) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) // .withSubmittedOnDate(submittedOnDate) //
@@ -227,75 +233,91 @@ public class FixedDepositAccountHelper {
.withInterestPostingPeriodType(interestPostingPeriodType) // .withInterestPostingPeriodType(interestPostingPeriodType) //
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" return Utils.performServerPut(this.requestSpec, this.responseSpec,
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
} }
public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) { public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) {
System.out.println("--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------"); LOG.info(
return performFixedDepositApplicationActions(createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), "--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------");
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getApproveFixedDepositAccountAsJSON(approvedOnDate)); getApproveFixedDepositAccountAsJSON(approvedOnDate));
} }
public HashMap undoApproval(final Integer fixedDepositAccountID) { public HashMap undoApproval(final Integer fixedDepositAccountID) {
System.out.println("--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------"); LOG.info(
"--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
final String undoBodyJson = "{'note':'UNDO APPROVAL'}"; final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(
createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), undoBodyJson); createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
undoBodyJson);
} }
public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) { public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) {
System.out.println("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------"); LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions(createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), return performFixedDepositApplicationActions(
createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getRejectedFixedDepositAsJSON(rejectedOnDate)); getRejectedFixedDepositAsJSON(rejectedOnDate));
} }
public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) { public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) {
System.out.println("--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------"); LOG.info(
"--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(
createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate)); getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate));
} }
public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) { public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) {
System.out.println("---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------"); LOG.info(
return performFixedDepositApplicationActions(createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), "---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------");
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getActivatedFixedDepositAccountAsJSON(activationDate)); getActivatedFixedDepositAccountAsJSON(activationDate));
} }
public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, final String jsonAttributeToGetBack) { public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID,
System.out.println("---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------"); final String jsonAttributeToGetBack) {
return Utils.performServerDelete(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" LOG.info(
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack); "---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER,
jsonAttributeToGetBack);
} }
public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) { public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) {
System.out.println("--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------"); LOG.info(
"--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
return (Integer) performFixedDepositActions( return (Integer) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId), createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public Integer postInterestForFixedDeposit(final Integer fixedDepositAccountId) { public Integer postInterestForFixedDeposit(final Integer fixedDepositAccountId) {
System.out.println("--------------------------------- POST INTEREST FOR FIXED DEPOSIT --------------------------------"); LOG.info("--------------------------------- POST INTEREST FOR FIXED DEPOSIT --------------------------------");
return (Integer) performFixedDepositActions( return (Integer) performFixedDepositActions(
createFixedDepositCalculateInterestURL(POST_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId), createFixedDepositCalculateInterestURL(POST_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate) { public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId,
System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------"); final String closedOnDate) {
LOG.info("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------");
return (HashMap) performFixedDepositActions( return (HashMap) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId), createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId),
getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), ""); getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), "");
} }
public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, final String closureType, public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate,
final Integer toSavingsId, final String jsonAttributeToGetBack) { final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) {
System.out.println("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------"); LOG.info("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------");
return performFixedDepositActions(createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId), return performFixedDepositActions(
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack); createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId),
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId),
jsonAttributeToGetBack);
} }
private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) { private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) {
@@ -305,7 +327,7 @@ public class FixedDepositAccountHelper {
map.put("approvedOnDate", approvedOnDate); map.put("approvedOnDate", approvedOnDate);
map.put("note", "Approval NOTE"); map.put("note", "Approval NOTE");
String fixedDepositAccountApproveJson = new Gson().toJson(map); String fixedDepositAccountApproveJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountApproveJson); LOG.info(fixedDepositAccountApproveJson);
return fixedDepositAccountApproveJson; return fixedDepositAccountApproveJson;
} }
@@ -316,7 +338,7 @@ public class FixedDepositAccountHelper {
map.put("rejectedOnDate", rejectedOnDate); map.put("rejectedOnDate", rejectedOnDate);
map.put("note", "Rejected NOTE"); map.put("note", "Rejected NOTE");
String fixedDepositAccountJson = new Gson().toJson(map); String fixedDepositAccountJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountJson); LOG.info("{}", fixedDepositAccountJson);
return fixedDepositAccountJson; return fixedDepositAccountJson;
} }
@@ -327,7 +349,7 @@ public class FixedDepositAccountHelper {
map.put("withdrawnOnDate", withdrawnApplicationOnDate); map.put("withdrawnOnDate", withdrawnApplicationOnDate);
map.put("note", "Withdraw NOTE"); map.put("note", "Withdraw NOTE");
String fixedDepositAccountJson = new Gson().toJson(map); String fixedDepositAccountJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountJson); LOG.info("{}", fixedDepositAccountJson);
return fixedDepositAccountJson; return fixedDepositAccountJson;
} }
@@ -337,14 +359,14 @@ public class FixedDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("activatedOnDate", activationDate); map.put("activatedOnDate", activationDate);
String fixedDepositAccountActivateJson = new Gson().toJson(map); String fixedDepositAccountActivateJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountActivateJson); LOG.info("{}", fixedDepositAccountActivateJson);
return fixedDepositAccountActivateJson; return fixedDepositAccountActivateJson;
} }
private String getCalculatedInterestForFixedDepositApplicationAsJSON() { private String getCalculatedInterestForFixedDepositApplicationAsJSON() {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
String fixedDepositAccountCalculatedInterestJson = new Gson().toJson(map); String fixedDepositAccountCalculatedInterestJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountCalculatedInterestJson); LOG.info(fixedDepositAccountCalculatedInterestJson);
return fixedDepositAccountCalculatedInterestJson; return fixedDepositAccountCalculatedInterestJson;
} }
@@ -354,7 +376,7 @@ public class FixedDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("closedOnDate", closedOnDate); map.put("closedOnDate", closedOnDate);
String fixedDepositAccountPrematureClosureJson = new Gson().toJson(map); String fixedDepositAccountPrematureClosureJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountPrematureClosureJson); LOG.info(fixedDepositAccountPrematureClosureJson);
return fixedDepositAccountPrematureClosureJson; return fixedDepositAccountPrematureClosureJson;
} }
@@ -370,23 +392,26 @@ public class FixedDepositAccountHelper {
map.put("transferDescription", "Transferring To Savings Account"); map.put("transferDescription", "Transferring To Savings Account");
} }
String fixedDepositAccountPrematureCloseJson = new Gson().toJson(map); String fixedDepositAccountPrematureCloseJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountPrematureCloseJson); LOG.info(fixedDepositAccountPrematureCloseJson);
return fixedDepositAccountPrematureCloseJson; return fixedDepositAccountPrematureCloseJson;
} }
private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) { private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) {
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
} }
private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent, private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent,
final String jsonAttributeToGetBack) { final String jsonAttributeToGetBack) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, jsonAttributeToGetBack); return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent,
jsonAttributeToGetBack);
} }
private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, final String jsonToBeSent) { private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction,
final String jsonToBeSent) {
HashMap status = null; HashMap status = null;
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDepositAction, jsonToBeSent, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec,
CommonConstants.RESPONSE_CHANGES); postURLForFixedDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES);
if (response != null) { if (response != null) {
status = (HashMap) response.get("status"); status = (HashMap) response.get("status");
} }
@@ -394,13 +419,15 @@ public class FixedDepositAccountHelper {
} }
private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) { private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) {
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
} }
public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec,
System.out.println("-------------------- RETRIEVING ALL FIXED DEPOSIT ACCOUNTS ---------------------"); final ResponseSpecification responseSpec) {
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "?" LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT ACCOUNTS ---------------------");
+ Utils.TENANT_IDENTIFIER, ""); final ArrayList response = Utils.performServerGet(requestSpec, responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER, "");
return response; return response;
} }
@@ -439,7 +466,8 @@ public class FixedDepositAccountHelper {
return this; return this;
} }
public FixedDepositAccountHelper withLockinPeriodFrequency(final String lockingPeriodFrequencyType, final String lockinPeriodFrequency) { public FixedDepositAccountHelper withLockinPeriodFrequency(final String lockingPeriodFrequencyType,
final String lockinPeriodFrequency) {
this.lockingPeriodFrequencyType = lockingPeriodFrequencyType; this.lockingPeriodFrequencyType = lockingPeriodFrequencyType;
this.lockinPeriodFrequency = lockinPeriodFrequency; this.lockinPeriodFrequency = lockinPeriodFrequency;
return this; return this;
@@ -456,7 +484,9 @@ public class FixedDepositAccountHelper {
} }
private String getDepositAmount() { private String getDepositAmount() {
if (this.newDepositAmount == null) { return depositAmount; } if (this.newDepositAmount == null) {
return depositAmount;
}
return this.newDepositAmount; return this.newDepositAmount;
} }
} }
@@ -25,71 +25,78 @@ import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Assert; import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class FixedDepositAccountStatusChecker { public class FixedDepositAccountStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountStatusChecker.class);
private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts"; private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts";
public static void verifyFixedDepositIsApproved(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsApproved(final HashMap fixedDepositStatusHashMap) {
System.out.println("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS APPROVED --------------------"); LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS APPROVED --------------------");
assertTrue("Error in Approving Fixed deposit application", getStatus(fixedDepositStatusHashMap, "approved")); assertTrue("Error in Approving Fixed deposit application", getStatus(fixedDepositStatusHashMap, "approved"));
System.out.println(fixedDepositStatusHashMap); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) {
System.out.println("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------"); LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue("FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE", getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval")); assertTrue("FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE",
System.out.println(fixedDepositStatusHashMap); getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositIsActive(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsActive(final HashMap fixedDepositStatusHashMap) {
System.out.println("----------------- VERIFYING FIXED DEPOSIT APPLICATION IS ACTIVE -----------------"); LOG.info("----------------- VERIFYING FIXED DEPOSIT APPLICATION IS ACTIVE -----------------");
assertTrue("ERROR IN ACTIVATING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "active")); assertTrue("ERROR IN ACTIVATING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "active"));
System.out.println(fixedDepositStatusHashMap); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) {
System.out.println("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------"); LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue("ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "rejected")); assertTrue("ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION",
System.out.println(fixedDepositStatusHashMap); getStatus(fixedDepositStatusHashMap, "rejected"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) {
System.out.println("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------"); LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------");
assertTrue("ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant")); assertTrue("ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION",
System.out.println(fixedDepositStatusHashMap); getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositAccountIsClosed(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsClosed(final HashMap fixedDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue("ERROR IN CLOSING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "closed")); assertTrue("ERROR IN CLOSING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "closed"));
System.out.println(fixedDepositStatusHashMap); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositAccountIsNotActive(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsNotActive(final HashMap fixedDepositStatusHashMap) {
System.out.println("------------------ VERIFYING FIXED DEPOSIT APPLICATION IS INACTIVE --------------------"); LOG.info("------------------ VERIFYING FIXED DEPOSIT APPLICATION IS INACTIVE --------------------");
Assert.assertFalse(getStatus(fixedDepositStatusHashMap, "active")); Assert.assertFalse(getStatus(fixedDepositStatusHashMap, "active"));
System.out.println(fixedDepositStatusHashMap); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec,
final String fixedDepositAccountID) { final ResponseSpecification responseSpec, final String fixedDepositAccountID) {
final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID
+ Utils.TENANT_IDENTIFIER; + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status"); return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status");
} }
public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "prematureClosed")); assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT",
System.out.println(fixedDepositStatusHashMap); getStatus(fixedDepositStatusHashMap, "prematureClosed"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------"); LOG.info("--------------------- 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",
System.out.println(fixedDepositStatusHashMap); getStatus(fixedDepositStatusHashMap, "matured"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) { private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) {
@@ -28,10 +28,12 @@ import java.util.Map;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.Account;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositProductHelper { public class FixedDepositProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositProductHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -147,7 +149,7 @@ public class FixedDepositProductHelper {
} }
String FixedDepositProductCreateJson = new Gson().toJson(map); String FixedDepositProductCreateJson = new Gson().toJson(map);
System.out.println(FixedDepositProductCreateJson); LOG.info("{}",FixedDepositProductCreateJson);
return FixedDepositProductCreateJson; return FixedDepositProductCreateJson;
} }
@@ -421,13 +423,13 @@ public class FixedDepositProductHelper {
public static Integer createFixedDepositProduct(final String fixedDepositProductCreateJson, final RequestSpecification requestSpec, public static Integer createFixedDepositProduct(final String fixedDepositProductCreateJson, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
System.out.println("--------------------- CREATING FIXED DEPOSIT PRODUCT ------------------------"); LOG.info("--------------------- CREATING FIXED DEPOSIT PRODUCT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_FIXED_DEPOSIT_PRODUCT_URL, fixedDepositProductCreateJson, return Utils.performServerPost(requestSpec, responseSpec, CREATE_FIXED_DEPOSIT_PRODUCT_URL, fixedDepositProductCreateJson,
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
System.out.println("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------"); LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_PRODUCT_URL + "?" final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_PRODUCT_URL + "?"
+ Utils.TENANT_IDENTIFIER, ""); + Utils.TENANT_IDENTIFIER, "");
return response; return response;
@@ -435,7 +437,7 @@ public class FixedDepositProductHelper {
public static HashMap retrieveFixedDepositProductById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap retrieveFixedDepositProductById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String productId) { final String productId) {
System.out.println("------------------------ RETRIEVING FIXED DEPOSIT PRODUCT BY ID ------------------------"); LOG.info("------------------------ RETRIEVING FIXED DEPOSIT PRODUCT BY ID ------------------------");
final String GET_FD_PRODUCT_BY_ID_URL = FIXED_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER; final String GET_FD_PRODUCT_BY_ID_URL = FIXED_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_FD_PRODUCT_BY_ID_URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_FD_PRODUCT_BY_ID_URL, "");
return response; return response;
@@ -443,7 +445,7 @@ public class FixedDepositProductHelper {
public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec, public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer productId) { final ResponseSpecification responseSpec, final Integer productId) {
System.out.println("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------"); LOG.info("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId, final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId,
"chartSlabs"); "chartSlabs");
return response; return response;
@@ -49,9 +49,10 @@ public class LoanTransactionHelper {
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
private final static Logger LOG = LoggerFactory.getLogger(LoanTransactionHelper.class); private final static Logger LOG = LoggerFactory.getLogger(LoanTransactionHelper.class);
private static final String CREATE_LOAN_PRODUCT_URL = "/fineract-provider/api/v1/loanproducts?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_LOAN_PRODUCT_URL = "/fineract-provider/api/v1/loanproducts?"
+ Utils.TENANT_IDENTIFIER;
private static final String APPLY_LOAN_URL = "/fineract-provider/api/v1/loans?" + Utils.TENANT_IDENTIFIER; private static final String APPLY_LOAN_URL = "/fineract-provider/api/v1/loans?" + Utils.TENANT_IDENTIFIER;
private static final String LOAN_ACCOUNT_URL="/fineract-provider/api/v1/loans"; private static final String LOAN_ACCOUNT_URL = "/fineract-provider/api/v1/loans";
private static final String APPROVE_LOAN_COMMAND = "approve"; private static final String APPROVE_LOAN_COMMAND = "approve";
private static final String UNDO_APPROVAL_LOAN_COMMAND = "undoApproval"; private static final String UNDO_APPROVAL_LOAN_COMMAND = "undoApproval";
private static final String DISBURSE_LOAN_COMMAND = "disburse"; private static final String DISBURSE_LOAN_COMMAND = "disburse";
@@ -75,25 +76,29 @@ public class LoanTransactionHelper {
} }
public Integer getLoanProductId(final String loanProductJSON) { public Integer getLoanProductId(final String loanProductJSON) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, "resourceId"); return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON,
"resourceId");
} }
public Integer getLoanId(final String loanApplicationJSON) { public Integer getLoanId(final String loanApplicationJSON) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId"); return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON,
"loanId");
} }
public HashMap<String,Integer> getGlimId(final String loanApplicationJSON) { public HashMap<String, Integer> getGlimId(final String loanApplicationJSON) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, ""); return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "");
} }
public Object getGlimLoanId(final String glimId) { public Object getGlimLoanId(final String glimId) {
final String GET_LOAN_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" + Utils.TENANT_IDENTIFIER; final String GET_LOAN_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_LOAN_URL, "childLoanId"); return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_LOAN_URL, "childLoanId");
} }
public Object getLoanError(final String loanApplicationJSON, final String responseAttribute) { public Object getLoanError(final String loanApplicationJSON, final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute); return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON,
responseAttribute);
} }
public Integer getLoanOfficerId(final String loanId) { public Integer getLoanOfficerId(final String loanId) {
@@ -102,66 +107,74 @@ public class LoanTransactionHelper {
} }
public Object createLoanAccount(final String loanApplicationJSON, final String responseAttribute) { public Object createLoanAccount(final String loanApplicationJSON, final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute); return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON,
responseAttribute);
} }
public Integer updateLoan(final Integer id, final String loanApplicationJSON) { public Integer updateLoan(final Integer id, final String loanApplicationJSON) {
return Utils.performServerPut(this.requestSpec, this.responseSpec, "/fineract-provider/api/v1/loans/" + id + "?" return Utils.performServerPut(this.requestSpec, this.responseSpec,
+ Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId"); "/fineract-provider/api/v1/loans/" + id + "?" + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId");
} }
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec,
final Integer loanID) { final ResponseSpecification responseSpec, final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&"
+ Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
return (ArrayList) response.get("periods"); return (ArrayList) response.get("periods");
} }
public ArrayList getLoanCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public ArrayList getLoanCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) { final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&"
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges"); + Utils.TENANT_IDENTIFIER;
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges");
} }
public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec,
final Integer loanID) { final ResponseSpecification responseSpec, final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule,futureSchedule&" final String URL = "/fineract-provider/api/v1/loans/" + loanID
+ Utils.TENANT_IDENTIFIER; + "?associations=repaymentSchedule,futureSchedule&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
return (ArrayList) response.get("futurePeriods"); return (ArrayList) response.get("futurePeriods");
} }
public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) { public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
return response; return response;
} }
public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID, public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String param) { final Integer loanID, final String param) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, param); return Utils.performServerGet(requestSpec, responseSpec, URL, param);
} }
public String getLoanDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) { public String getLoanDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, null); return Utils.performServerGet(requestSpec, responseSpec, URL, null);
} }
public Object getLoanProductDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Object getLoanProductDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanProductId, final String jsonAttributeToGetBack) { final Integer loanProductId, final String jsonAttributeToGetBack) {
final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttributeToGetBack); return Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttributeToGetBack);
} }
public String getLoanProductDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public String getLoanProductDetails(final RequestSpecification requestSpec,
final Integer loanProductId) { final ResponseSpecification responseSpec, final Integer loanProductId) {
final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, null); return Utils.performServerGet(requestSpec, responseSpec, URL, null);
} }
public ArrayList getLoanCharges(final Integer loanId) { public ArrayList getLoanCharges(final Integer loanId) {
final String GET_LOAN_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER; final String GET_LOAN_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, GET_LOAN_CHARGES_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_LOAN_CHARGES_URL, "");
} }
@@ -179,13 +192,17 @@ public class LoanTransactionHelper {
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches)); getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches));
} }
public List<HashMap<String, Object>> approveLoanForTranches(final String approvalDate, final String expectedDisbursementDate, public List<HashMap<String, Object>> approveLoanForTranches(final String approvalDate,
final String approvalAmount, final Integer loanID, List<HashMap> tranches, final String responseAttribute) { final String expectedDisbursementDate, final String approvalAmount, final Integer loanID,
return (List<HashMap<String, Object>>) performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), List<HashMap> tranches, final String responseAttribute) {
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches), responseAttribute); return (List<HashMap<String, Object>>) performLoanTransaction(
createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches),
responseAttribute);
} }
public Object approveLoan(final String approvalDate, final String approvalAmount, final Integer loanID, final String responseAttribute) { public Object approveLoan(final String approvalDate, final String approvalAmount, final Integer loanID,
final String responseAttribute) {
final String approvalURL = createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID); final String approvalURL = createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID);
final String approvalJSONData = getApproveLoanAsJSON(approvalDate, null, approvalAmount, null); final String approvalJSONData = getApproveLoanAsJSON(approvalDate, null, approvalAmount, null);
@@ -199,24 +216,29 @@ 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,
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanWithRepaymentRescheduleAsJSON(date, String adjustRepaymentDate) {
null, adjustRepaymentDate)); return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanWithRepaymentRescheduleAsJSON(date, null, adjustRepaymentDate));
} }
public HashMap disburseLoan(final String date, final Integer loanID, final String disburseAmt) { public HashMap disburseLoan(final String date, final Integer loanID, final String disburseAmt) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, disburseAmt)); return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanAsJSON(date, disburseAmt));
} }
public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError) { public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), 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));
} }
public HashMap undoDisbursal(final Integer loanID) { public HashMap undoDisbursal(final Integer loanID) {
@@ -231,14 +253,15 @@ public class LoanTransactionHelper {
final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}"; final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}";
final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID); final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID);
LOG.info("IN UNDO LAST DISBURSE LOAN URL : {} ", url); LOG.info("IN UNDO LAST DISBURSE LOAN URL : {} ", url);
return performUndoLastLoanDisbursementTransaction(createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID), undoLastDisburseJson); return performUndoLastLoanDisbursementTransaction(
createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID), undoLastDisburseJson);
} }
//glimtesting
// glimtesting
public HashMap approveGlimAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public HashMap approveGlimAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final List<Map<String, Object>> approvalFormData, final Integer glimID) { final List<Map<String, Object>> approvalFormData, final Integer glimID) {
String approvalForm = new LoanApplicationTestBuilder() // String approvalForm = new LoanApplicationTestBuilder() //
.withApprovalFormData(approvalFormData) .withApprovalFormData(approvalFormData).build();
.build();
final String approvalURL = createGlimAccountURL(APPROVE_LOAN_COMMAND, glimID); final String approvalURL = createGlimAccountURL(APPROVE_LOAN_COMMAND, glimID);
return performLoanTransaction(approvalURL, approvalForm); return performLoanTransaction(approvalURL, approvalForm);
@@ -262,8 +285,8 @@ public class LoanTransactionHelper {
} }
public HashMap rejectGlimAccount(final String date, final Integer glimID) { public HashMap rejectGlimAccount(final String date, final Integer glimID) {
LOG.info("--------------------------------- REJECT GLIM APPLICATION -------------------------------"); LOG.info("--------------------------------- REJECT GLIM APPLICATION -------------------------------");
return performLoanTransaction(createGlimAccountURL(REJECT_LOAN_COMMAND, glimID), getRejectAsJSON(date)); return performLoanTransaction(createGlimAccountURL(REJECT_LOAN_COMMAND, glimID), getRejectAsJSON(date));
} }
public void recoverFromGuarantor(final Integer loanID) { public void recoverFromGuarantor(final Integer loanID) {
@@ -271,16 +294,20 @@ public class LoanTransactionHelper {
} }
public HashMap writeOffLoan(final String date, final Integer loanID) { public HashMap writeOffLoan(final String date, final Integer loanID) {
return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), getWriteOffBodyAsJSON(date)); return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID),
getWriteOffBodyAsJSON(date));
} }
public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) { public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) {
return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived)); return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID),
getWaiveBodyAsJSON(date, amountToBeWaived));
} }
public Integer waiveInterestAndReturnTransactionId(final String date, final String amountToBeWaived, final Integer loanID) { public Integer waiveInterestAndReturnTransactionId(final String date, final String amountToBeWaived,
final Integer loanID) {
Integer resourceId = Utils.performServerPost(this.requestSpec, this.responseSpec, Integer resourceId = Utils.performServerPost(this.requestSpec, this.responseSpec,
createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived), "resourceId"); createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived),
"resourceId");
return resourceId; return resourceId;
} }
@@ -301,13 +328,16 @@ public class LoanTransactionHelper {
public Integer addChargesForLoan(final Integer loanId, final String request) { public Integer addChargesForLoan(final Integer loanId, final String request) {
LOG.info("--------------------------------- ADD CHARGES FOR LOAN --------------------------------"); LOG.info("--------------------------------- ADD CHARGES FOR LOAN --------------------------------");
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER; final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?"
+ Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, ""); final HashMap response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request, final ResponseSpecification responseSpecification) { public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request,
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER; final ResponseSpecification responseSpecification) {
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, "");
} }
@@ -329,16 +359,16 @@ public class LoanTransactionHelper {
public Integer waiveChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) { public Integer waiveChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------"); LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=waive&" final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
+ Utils.TENANT_IDENTIFIER; + "?command=waive&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public Integer payChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) { public Integer payChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------"); LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=pay&" final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
+ Utils.TENANT_IDENTIFIER; + "?command=pay&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
@@ -356,7 +386,8 @@ public class LoanTransactionHelper {
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");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -374,8 +405,8 @@ public class LoanTransactionHelper {
return getApproveLoanAsJSON(approvalDate, null, null, null); return getApproveLoanAsJSON(approvalDate, null, null, null);
} }
private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate, final String approvalAmount, private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate,
List<HashMap> tranches) { final String approvalAmount, List<HashMap> tranches) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -426,7 +457,7 @@ public class LoanTransactionHelper {
map.put("transactionDate", transactionDate); map.put("transactionDate", transactionDate);
map.put("note", "Foreclosure Made!!!"); map.put("note", "Foreclosure Made!!!");
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info(json); LOG.info("{}", json);
return json; return json;
} }
@@ -463,7 +494,8 @@ public class LoanTransactionHelper {
return getSpecifiedDueDateChargesForLoanAsJSON(chargeId, "12 January 2013", "100"); return getSpecifiedDueDateChargesForLoanAsJSON(chargeId, "12 January 2013", "100");
} }
public static String getSpecifiedDueDateChargesForLoanAsJSON(final String chargeId, final String dueDate, final String amount) { public static String getSpecifiedDueDateChargesForLoanAsJSON(final String chargeId, final String dueDate,
final String amount) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en_GB"); map.put("locale", "en_GB");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -471,7 +503,7 @@ public class LoanTransactionHelper {
map.put("dueDate", dueDate); map.put("dueDate", dueDate);
map.put("chargeId", chargeId); map.put("chargeId", chargeId);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
@@ -486,7 +518,7 @@ public class LoanTransactionHelper {
map.put("amount", amount); map.put("amount", amount);
map.put("chargeId", chargeId); map.put("chargeId", chargeId);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
@@ -497,7 +529,7 @@ public class LoanTransactionHelper {
map.put("amount", amount); map.put("amount", amount);
map.put("chargeId", chargeId); map.put("chargeId", chargeId);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
@@ -507,7 +539,7 @@ public class LoanTransactionHelper {
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
map.put("amount", amount); map.put("amount", amount);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
@@ -520,7 +552,7 @@ public class LoanTransactionHelper {
map.put("installmentNumber", installmentNumber); map.put("installmentNumber", installmentNumber);
} }
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
@@ -529,7 +561,7 @@ public class LoanTransactionHelper {
map.put("locale", "en_GB"); map.put("locale", "en_GB");
map.put("installmentNumber", installmentNumber); map.put("installmentNumber", installmentNumber);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
@@ -559,44 +591,53 @@ public class LoanTransactionHelper {
} }
private String createLoanTransactionURL(final String command, final Integer loanID) { private String createLoanTransactionURL(final String command, final Integer loanID) {
return "/fineract-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&" + Utils.TENANT_IDENTIFIER; return "/fineract-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
} }
private String createGlimAccountURL(final String command, final Integer glimID) { private String createGlimAccountURL(final String command, final Integer glimID) {
return "/fineract-provider/api/v1/loans/glimAccount/" + glimID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; return "/fineract-provider/api/v1/loans/glimAccount/" + glimID + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
} }
private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) { private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) {
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction,
"changes"); jsonToBeSent, "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,
"changes"); jsonToBeSent, "changes");
return (Float) response.get("disbursedAmount"); return (Float) response.get("disbursedAmount");
} }
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, final String responseAttribute) { private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent,
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, responseAttribute); final String 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,
final String transactionAmount, final String responseAttribute) { final String transactionAmount, final String responseAttribute) {
return adjustLoanTransaction(loanId, transactionId, getAdjustTransactionJSON(date, transactionAmount), responseAttribute); return adjustLoanTransaction(loanId, transactionId, getAdjustTransactionJSON(date, transactionAmount),
responseAttribute);
} }
private Object adjustLoanTransaction(final Integer loanId, final Integer tansactionId, final String jsonToBeSent, private Object adjustLoanTransaction(final Integer loanId, final Integer tansactionId, final String jsonToBeSent,
final String responseAttribute) { final String responseAttribute) {
final String URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/" + tansactionId + "?" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/" + tansactionId + "?"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, jsonToBeSent, responseAttribute); return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, jsonToBeSent, responseAttribute);
} }
@@ -607,11 +648,12 @@ public class LoanTransactionHelper {
map.put("transactionDate", date); map.put("transactionDate", date);
map.put("transactionAmount", transactionAmount); map.put("transactionAmount", transactionAmount);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info(json); LOG.info("{}", json);
return json; return json;
} }
public HashMap getPrepayAmount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) { public HashMap getPrepayAmount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "/transactions/template?command=prepayLoan&" final String URL = "/fineract-provider/api/v1/loans/" + loanID + "/transactions/template?command=prepayLoan&"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "");
@@ -622,17 +664,20 @@ public class LoanTransactionHelper {
return "/fineract-provider/api/v1/accounttransfers/refundByTransfer?tenantIdentifier=default"; return "/fineract-provider/api/v1/accounttransfers/refundByTransfer?tenantIdentifier=default";
} }
public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) { public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding,
final Integer loanID) {
LOG.info("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------"); LOG.info("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------");
final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding, repaymentPeriods.get(repaymentNumber) loanID);
.get("principalLoanBalanceOutstanding")); assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding,
repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding"));
} }
public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion, final Float feePortion, public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion,
final Float penaltyPortion, final Integer loanID) { final Float feePortion, final Float penaltyPortion, final Integer loanID) {
ArrayList<HashMap> transactions = (ArrayList<HashMap>) getLoanDetail(this.requestSpec, this.responseSpec, loanID, "transactions"); ArrayList<HashMap> transactions = (ArrayList<HashMap>) getLoanDetail(this.requestSpec, this.responseSpec,
loanID, "transactions");
boolean isTransactionFound = false; boolean isTransactionFound = false;
for (int i = 0; i < transactions.size(); i++) { for (int i = 0; i < transactions.size(); i++) {
HashMap transactionType = (HashMap) transactions.get(i).get("type"); HashMap transactionType = (HashMap) transactions.get(i).get("type");
@@ -640,8 +685,8 @@ public class LoanTransactionHelper {
if (isAccrualTransaction) { if (isAccrualTransaction) {
ArrayList<Integer> accrualEntryDateAsArray = (ArrayList<Integer>) transactions.get(i).get("date"); ArrayList<Integer> accrualEntryDateAsArray = (ArrayList<Integer>) transactions.get(i).get("date");
LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1), LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0),
accrualEntryDateAsArray.get(2)); accrualEntryDateAsArray.get(1), accrualEntryDateAsArray.get(2));
if (transactionDate.equals(accrualEntryDate)) { if (transactionDate.equals(accrualEntryDate)) {
isTransactionFound = true; isTransactionFound = true;
@@ -664,10 +709,10 @@ public class LoanTransactionHelper {
getRefundByCashBodyAsJSON(date, amountToBeRefunded)); getRefundByCashBodyAsJSON(date, amountToBeRefunded));
} }
public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId, public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId,
final Integer fromClientId, final String date, final Float amountToBeRefunded) { final Integer toAccountId, final Integer fromClientId, final String date, final Float amountToBeRefunded) {
return performLoanTransaction(createLoanRefundTransferURL(), return performLoanTransaction(createLoanRefundTransferURL(), getRefundByTransferBodyAsJSON(fromAccountId,
getRefundByTransferBodyAsJSON(fromAccountId, toClientId, toAccountId, fromClientId, date, amountToBeRefunded)); toClientId, toAccountId, fromClientId, date, amountToBeRefunded));
} }
private String getRefundByCashBodyAsJSON(final String transactionDate, final Float transactionAmount) { private String getRefundByCashBodyAsJSON(final String transactionDate, final Float transactionAmount) {
@@ -680,8 +725,9 @@ public class LoanTransactionHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId, private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId,
final Integer fromClientId, final String transactionDate, final Float transactionAmount) { final Integer toAccountId, final Integer fromClientId, final String transactionDate,
final Float transactionAmount) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("fromAccountId", fromAccountId.toString()); map.put("fromAccountId", fromAccountId.toString());
map.put("fromAccountType", "1"); map.put("fromAccountType", "1");
@@ -701,7 +747,7 @@ public class LoanTransactionHelper {
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) {
detail.put("id", id); detail.put("id", id);
} }
detail.put("expectedDisbursementDate", date); detail.put("expectedDisbursementDate", date);
@@ -710,26 +756,34 @@ 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 updatedExpectedDisbursementDate, final String updatedPrincipal, final String jsonAttributeToGetBack) { final String approvalAmount, final String expectedDisbursementDate,
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,
updatedExpectedDisbursementDate, updatedPrincipal), jsonAttributeToGetBack); createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount,
expectedDisbursementDate, updatedExpectedDisbursementDate, updatedPrincipal),
jsonAttributeToGetBack);
} }
public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, final String expectedDisbursementDate public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount,
, List<HashMap> disbursementData, final String jsonAttributeToGetBack) { final String expectedDisbursementDate, 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,
@@ -742,12 +796,12 @@ public class LoanTransactionHelper {
map.put("updatedExpectedDisbursementDate", updatedExpectedDisbursementDate); map.put("updatedExpectedDisbursementDate", updatedExpectedDisbursementDate);
map.put("updatedPrincipal", updatedPrincipal); map.put("updatedPrincipal", updatedPrincipal);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate, public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount,
final List<HashMap> disbursementData) { final String expectedDisbursementDate, final List<HashMap> disbursementData) {
final HashMap map = new HashMap<>(); final HashMap map = new HashMap<>();
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -755,7 +809,7 @@ public class LoanTransactionHelper {
map.put("expectedDisbursementDate", expectedDisbursementDate); map.put("expectedDisbursementDate", expectedDisbursementDate);
map.put("disbursementData", disbursementData); map.put("disbursementData", disbursementData);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
LOG.info("{}",json); LOG.info("{}", json);
return json; return json;
} }
@@ -776,27 +830,29 @@ public class LoanTransactionHelper {
} }
public Workbook getLoanWorkbook(String dateFormat) throws IOException { public Workbook getLoanWorkbook(String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel"); requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte[] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,LOAN_ACCOUNT_URL+"/downloadtemplate"+"?"+ byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec,
Utils.TENANT_IDENTIFIER+"&dateFormat="+dateFormat); LOAN_ACCOUNT_URL + "/downloadtemplate" + "?" + Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
InputStream inputStream= new ByteArrayInputStream(byteArray); InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook=new HSSFWorkbook(inputStream); Workbook workbook = new HSSFWorkbook(inputStream);
return workbook; return workbook;
} }
public String importLoanTemplate(File file) { public String importLoanTemplate(File file) {
String locale="en"; String locale = "en";
String dateFormat="dd MMMM yyyy"; String dateFormat = "dd MMMM yyyy";
String legalFormType= null; String legalFormType = null;
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec,responseSpec,LOAN_ACCOUNT_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER, return Utils.performServerTemplatePost(requestSpec, responseSpec,
legalFormType,file,locale,dateFormat); LOAN_ACCOUNT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale,
dateFormat);
} }
public String getOutputTemplateLocation(final String importDocumentId){ public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_PLAIN); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?" return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
+Utils.TENANT_IDENTIFIER,importDocumentId); "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER,
importDocumentId);
} }
} }
@@ -33,10 +33,12 @@ import java.util.List;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.report.ReportData; import org.apache.fineract.integrationtests.common.report.ReportData;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert; import org.springframework.util.Assert;
public class CampaignsHelper { public class CampaignsHelper {
private final static Logger LOG = LoggerFactory.getLogger(CampaignsHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -52,51 +54,58 @@ public class CampaignsHelper {
} }
public Integer createCampaign(String reportName, Integer triggerType) { public Integer createCampaign(String reportName, Integer triggerType) {
System.out.println("---------------------------------CREATING A CAMPAIGN---------------------------------------------"); LOG.info("---------------------------------CREATING A CAMPAIGN---------------------------------------------");
final String CREATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "?" + Utils.TENANT_IDENTIFIER; final String CREATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL, getCreateCampaignJSON(reportName, triggerType), return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL,
"resourceId"); getCreateCampaignJSON(reportName, triggerType), "resourceId");
} }
public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec,
final Integer generatedCampaignId) { final ResponseSpecification responseSpec, final Integer generatedCampaignId) {
System.out.println("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n");
final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER; final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?"
final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL, "id"); + Utils.TENANT_IDENTIFIER;
final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL,
"id");
assertEquals("ERROR IN CREATING THE CAMPAIGN", generatedCampaignId, responseCampaignId); assertEquals("ERROR IN CREATING THE CAMPAIGN", generatedCampaignId, responseCampaignId);
} }
public Integer updateCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Integer updateCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId, String reportName, Integer triggerType) { final Integer generatedCampaignId, String reportName, Integer triggerType) {
System.out.println("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n"); LOG.info("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n");
final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?"
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL, getUpdateCampaignJSON(reportName, triggerType), + Utils.TENANT_IDENTIFIER;
"resourceId"); return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL,
getUpdateCampaignJSON(reportName, triggerType), "resourceId");
} }
public Integer deleteCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Integer deleteCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId) { final Integer generatedCampaignId) {
System.out.println("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n"); LOG.info("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n");
final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER; final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_SMS_CAMPAIGNS_URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, DELETE_SMS_CAMPAIGNS_URL, "resourceId");
} }
public Integer performActionsOnCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public Integer performActionsOnCampaign(final RequestSpecification requestSpec,
final Integer generatedCampaignId, String command) { final ResponseSpecification responseSpec, final Integer generatedCampaignId, String command) {
System.out.println("------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n"); LOG.info(
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&" "------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n");
+ Utils.TENANT_IDENTIFIER; final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command
+ "&" + Utils.TENANT_IDENTIFIER;
String actionDate = Utils.getLocalDateOfTenant().toString(DATE_FORMAT); String actionDate = Utils.getLocalDateOfTenant().toString(DATE_FORMAT);
return Utils return Utils.performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL,
.performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL, getJSONForCampaignAction(command, actionDate), "resourceId"); getJSONForCampaignAction(command, actionDate), "resourceId");
} }
public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command, String actionDate, String responseJsonAttribute) { public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command,
System.out.println("--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n"); String actionDate, String responseJsonAttribute) {
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&" LOG.info(
+ Utils.TENANT_IDENTIFIER; "--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n");
return Utils.performServerPost(this.requestSpec, this.responseSpec, SMS_CAMPAIGNS_ACTION_URL, getJSONForCampaignAction(command, actionDate), final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command
responseJsonAttribute); + "&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, this.responseSpec, SMS_CAMPAIGNS_ACTION_URL,
getJSONForCampaignAction(command, actionDate), responseJsonAttribute);
} }
public String getCreateCampaignJSON(String reportName, Integer triggerType) { public String getCreateCampaignJSON(String reportName, Integer triggerType) {
@@ -122,7 +131,7 @@ public class CampaignsHelper {
paramValueMap.put("reportName", reportName); paramValueMap.put("reportName", reportName);
map.put("paramValue", paramValueMap); map.put("paramValue", paramValueMap);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -147,7 +156,7 @@ public class CampaignsHelper {
paramValueMap.put("reportName", reportName); paramValueMap.put("reportName", reportName);
map.put("paramValue", paramValueMap); map.put("paramValue", paramValueMap);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -158,7 +167,7 @@ public class CampaignsHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", DATE_FORMAT); map.put("dateFormat", DATE_FORMAT);
String json = new Gson().toJson(map); String json = new Gson().toJson(map);
System.out.println(json); LOG.info("{}", json);
return json; return json;
} }
@@ -167,17 +176,18 @@ public class CampaignsHelper {
} }
private ArrayList<ReportData> getReports(String jsonAttributeToGetBack) { private ArrayList<ReportData> getReports(String jsonAttributeToGetBack) {
System.out.println("--------------------------------- GET REPORTS OPTIONS -------------------------------"); LOG.info("--------------------------------- GET REPORTS OPTIONS -------------------------------");
Assert.notNull(jsonAttributeToGetBack, "jsonAttributeToGetBack may not be null"); Assert.notNull(jsonAttributeToGetBack, "jsonAttributeToGetBack may not be null");
final String templateUrl = SMS_CAMPAIGNS_URL + "/template?" + Utils.TENANT_IDENTIFIER; final String templateUrl = SMS_CAMPAIGNS_URL + "/template?" + Utils.TENANT_IDENTIFIER;
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(templateUrl).andReturn() final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when()
.asString(); .get(templateUrl).andReturn().asString();
Assert.notNull(json, "json"); Assert.notNull(json, "json");
ArrayList<ReportData> reportsList = new ArrayList<>(); ArrayList<ReportData> reportsList = new ArrayList<>();
String reportsString = new Gson().toJson(from(json).get(jsonAttributeToGetBack)); String reportsString = new Gson().toJson(from(json).get(jsonAttributeToGetBack));
Assert.notNull(reportsString, "reportsString"); Assert.notNull(reportsString, "reportsString");
final Gson gson = new Gson(); final Gson gson = new Gson();
final Type typeOfHashMap = new TypeToken<List<ReportData>>() {}.getType(); final Type typeOfHashMap = new TypeToken<List<ReportData>>() {
}.getType();
reportsList = gson.fromJson(reportsString, typeOfHashMap); reportsList = gson.fromJson(reportsString, typeOfHashMap);
return reportsList; return reportsList;
} }
@@ -187,7 +197,9 @@ public class CampaignsHelper {
if (reports != null && !reports.isEmpty()) { if (reports != null && !reports.isEmpty()) {
for (ReportData reportData : reports) { for (ReportData reportData : reports) {
if (reportName.equals(reportData.getReportName())) { return reportData.getReportId(); } if (reportName.equals(reportData.getReportName())) {
return reportData.getReportId();
}
} }
} }
Assert.notNull(null, "null"); Assert.notNull(null, "null");
@@ -31,10 +31,12 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert; import org.springframework.util.Assert;
public class CurrencyHelper { public class CurrencyHelper {
private final static Logger LOG = LoggerFactory.getLogger(CurrencyHelper.class);
private static final String CURRENCY_URL = "/fineract-provider/api/v1/currencies?" + Utils.TENANT_IDENTIFIER; private static final String CURRENCY_URL = "/fineract-provider/api/v1/currencies?" + Utils.TENANT_IDENTIFIER;
private static final String CURRENCY_URL_SELECTED = CURRENCY_URL + "&fields=selectedCurrencyOptions"; private static final String CURRENCY_URL_SELECTED = CURRENCY_URL + "&fields=selectedCurrencyOptions";
@@ -59,19 +61,19 @@ public class CurrencyHelper {
return getCurrencies(CURRENCY_URL_SELECTED, permittedCurrencyArraySelected); return getCurrencies(CURRENCY_URL_SELECTED, permittedCurrencyArraySelected);
} }
private ArrayList<Currency> getCurrencies(final String getUrl, final List<String> permittedCurrencyArrays) { private ArrayList<Currency> getCurrencies(final String getUrl, final List<String> permittedCurrencyArrays) {
System.out.println("--------------------------------- GET CURRENCY OPTIONS -------------------------------"); LOG.info("--------------------------------- GET CURRENCY OPTIONS -------------------------------");
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when() final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getUrl)
.get(getUrl).andReturn().asString(); .andReturn().asString();
final Gson gson = new Gson(); final Gson gson = new Gson();
Assert.notNull(json, "json"); Assert.notNull(json, "json");
final ArrayList<Currency> currencyList = new ArrayList<Currency>(); final ArrayList<Currency> currencyList = new ArrayList<Currency>();
final Type typeOfHashMap = new TypeToken<Map<String, List<Currency>>>() { }.getType(); final Type typeOfHashMap = new TypeToken<Map<String, List<Currency>>>() {
}.getType();
final Map<String, List<Currency>> responseMap = gson.fromJson(json, typeOfHashMap); final Map<String, List<Currency>> responseMap = gson.fromJson(json, typeOfHashMap);
for(Map.Entry<String, List<Currency>> entry : responseMap.entrySet()) { for (Map.Entry<String, List<Currency>> entry : responseMap.entrySet()) {
Assert.isTrue(permittedCurrencyArrays.contains(entry.getKey()), "permittedCurrencyArrays"); Assert.isTrue(permittedCurrencyArrays.contains(entry.getKey()), "permittedCurrencyArrays");
for(Currency currency : entry.getValue()) { for (Currency currency : entry.getValue()) {
currencyList.add(currency); currencyList.add(currency);
} }
} }
@@ -79,13 +81,14 @@ public class CurrencyHelper {
} }
public List<String> updateCurrencies(final List<String> currencies) { public List<String> updateCurrencies(final List<String> currencies) {
System.out.println("--------------------------------- UPDATE CURRENCY OPTIONS -------------------------------"); LOG.info("--------------------------------- UPDATE CURRENCY OPTIONS -------------------------------");
final String json = given().spec(requestSpec).body(getUpdateJSON(currencies)).expect().spec(responseSpec).log().ifError().when() final String json = given().spec(requestSpec).body(getUpdateJSON(currencies)).expect().spec(responseSpec).log()
.put(CURRENCY_URL).andReturn().asString(); .ifError().when().put(CURRENCY_URL).andReturn().asString();
final Gson gson = new Gson(); final Gson gson = new Gson();
Assert.notNull(json, "json"); Assert.notNull(json, "json");
final Type typeOfHashMap = new TypeToken<Map<String,Map<String, List<String>>>>() { }.getType(); final Type typeOfHashMap = new TypeToken<Map<String, Map<String, List<String>>>>() {
final Map<String,Map<String, List<String>>> responseMap = gson.fromJson(json, typeOfHashMap); }.getType();
final Map<String, Map<String, List<String>>> responseMap = gson.fromJson(json, typeOfHashMap);
return responseMap.get("changes").get("currencies"); return responseMap.get("changes").get("currencies");
} }
@@ -23,9 +23,11 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EntityDatatableChecksHelper { public class EntityDatatableChecksHelper {
private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -59,7 +61,7 @@ public class EntityDatatableChecksHelper {
map.put("productId", productId); map.put("productId", productId);
} }
String requestJsonString = new Gson().toJson(map); String requestJsonString = new Gson().toJson(map);
System.out.println("map : " + requestJsonString); LOG.info("map : {}" , requestJsonString);
return requestJsonString; return requestJsonString;
} }
@@ -42,6 +42,8 @@ import org.apache.fineract.integrationtests.common.system.DatatableHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Entity Datatable Checks Integration Test for checking Creation, Deletion and * Entity Datatable Checks Integration Test for checking Creation, Deletion and
@@ -49,7 +51,7 @@ import org.junit.Test;
*/ */
public class EntityDatatableChecksIntegrationTest { public class EntityDatatableChecksIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private EntityDatatableChecksHelper entityDatatableChecksHelper; private EntityDatatableChecksHelper entityDatatableChecksHelper;
@@ -407,7 +409,7 @@ public class EntityDatatableChecksIntegrationTest {
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) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
if (allowOverdraft) { if (allowOverdraft) {
final String overDraftLimit = "2000.0"; final String overDraftLimit = "2000.0";
@@ -433,7 +435,7 @@ public class EntityDatatableChecksIntegrationTest {
} }
private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, final String repaymentStrategy) { private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, final String repaymentStrategy) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("10000000.00") // .withPrincipal("10000000.00") //
.withNumberOfRepayments("24") // .withNumberOfRepayments("24") //
@@ -450,7 +452,7 @@ public class EntityDatatableChecksIntegrationTest {
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment, private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment,
final String registeredTableName) { final String registeredTableName) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000000.00") // .withPrincipal("10000000.00") //
.withLoanTermFrequency("24") // .withLoanTermFrequency("24") //
@@ -471,7 +473,7 @@ public class EntityDatatableChecksIntegrationTest {
private Object applyForLoanApplicationWithError(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment, private Object applyForLoanApplicationWithError(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment,
final String responseAttribute) { final String responseAttribute) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000000.00") // .withPrincipal("10000000.00") //
.withLoanTermFrequency("24") // .withLoanTermFrequency("24") //
@@ -26,9 +26,11 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class StaffHelper { public class StaffHelper {
private final static Logger LOG = LoggerFactory.getLogger(StaffHelper.class);
private static final String TRANSFER_STAFF_URL = "/fineract-provider/api/v1/groups"; private static final String TRANSFER_STAFF_URL = "/fineract-provider/api/v1/groups";
private static final String CREATE_STAFF_URL = "/fineract-provider/api/v1/staff"; private static final String CREATE_STAFF_URL = "/fineract-provider/api/v1/staff";
@@ -46,7 +48,7 @@ public class StaffHelper {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffToTransferId); map.put("staffId", staffToTransferId);
map.put("note", note); map.put("note", note);
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -97,7 +99,7 @@ public class StaffHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
map.put("joiningDate", "20 September 2011") ; map.put("joiningDate", "20 September 2011") ;
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -119,7 +121,7 @@ public class StaffHelper {
if(fieldList.contains("mobileNo")) { if(fieldList.contains("mobileNo")) {
map.put("mobileNo", "+123515198"); map.put("mobileNo", "+123515198");
} }
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
} }
@@ -29,20 +29,24 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class RecurringDepositAccountHelper { public class RecurringDepositAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositAccountHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public RecurringDepositAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public RecurringDepositAccountHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/recurringdepositaccounts"; private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/recurringdepositaccounts";
private static final String APPLY_RECURRING_DEPOSIT_ACCOUNT_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String APPLY_RECURRING_DEPOSIT_ACCOUNT_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "?"
+ Utils.TENANT_IDENTIFIER;
private static final String APPROVE_RECURRING_DEPOSIT_COMMAND = "approve"; private static final String APPROVE_RECURRING_DEPOSIT_COMMAND = "approve";
private static final String UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND = "undoapproval"; private static final String UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND = "undoapproval";
private static final String REJECT_RECURRING_DEPOSIT_COMMAND = "reject"; private static final String REJECT_RECURRING_DEPOSIT_COMMAND = "reject";
@@ -140,21 +144,22 @@ public class RecurringDepositAccountHelper {
map.put("isCalendarInherited", this.isCalendarInherited); map.put("isCalendarInherited", this.isCalendarInherited);
String recurringDepositAccountJson = new Gson().toJson(map); String recurringDepositAccountJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountJson); LOG.info("{}", recurringDepositAccountJson);
return recurringDepositAccountJson; return recurringDepositAccountJson;
} }
public static Integer applyRecurringDepositApplication(final String recurringDepositAccountAsJson, public static Integer applyRecurringDepositApplication(final String recurringDepositAccountAsJson,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
System.out.println("--------------------- APPLYING FOR RECURRING DEPOSIT ACCOUNT ------------------------"); LOG.info("--------------------- APPLYING FOR RECURRING DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_RECURRING_DEPOSIT_ACCOUNT_URL, recurringDepositAccountAsJson, return Utils.performServerPost(requestSpec, responseSpec, APPLY_RECURRING_DEPOSIT_ACCOUNT_URL,
CommonConstants.RESPONSE_RESOURCE_ID); recurringDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static HashMap getRecurringDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getRecurringDepositAccountById(final RequestSpecification requestSpec,
final Integer accountID) { final ResponseSpecification responseSpec, final Integer accountID) {
final String GET_RECURRING_DEPOSIT_BY_ID_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER; final String GET_RECURRING_DEPOSIT_BY_ID_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
System.out.println("------------------------ RETRIEVING RECURRING DEPOSIT ACCOUNT BY ID -------------------------"); + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING RECURRING DEPOSIT ACCOUNT BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_RECURRING_DEPOSIT_BY_ID_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_RECURRING_DEPOSIT_BY_ID_URL, "");
} }
@@ -202,7 +207,7 @@ public class RecurringDepositAccountHelper {
principal += totalInterest; principal += totalInterest;
} }
totalInterest = 0.0f; totalInterest = 0.0f;
System.out.println(principal); LOG.info("{}", principal.toString());
} }
currentDate.add(Calendar.MONTH, 1); currentDate.add(Calendar.MONTH, 1);
@@ -212,7 +217,8 @@ public class RecurringDepositAccountHelper {
} }
public HashMap updateRecurringDepositAccount(final String clientID, final String productID, final String accountID, public HashMap updateRecurringDepositAccount(final String clientID, final String productID, final String accountID,
final String validFrom, final String validTo, final String penalInterestType, final String submittedOnDate) { final String validFrom, final String validTo, final String penalInterestType,
final String submittedOnDate) {
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
@@ -220,128 +226,155 @@ public class RecurringDepositAccountHelper {
todaysDate.add(Calendar.DATE, -1); todaysDate.add(Calendar.DATE, -1);
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime()); final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
final String EXPECTED_FIRST_DEPOSIT_ON_ON_DATE = SUBMITTED_ON_DATE; final String EXPECTED_FIRST_DEPOSIT_ON_ON_DATE = SUBMITTED_ON_DATE;
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec,
.withSubmittedOnDate(SUBMITTED_ON_DATE).withExpectedFirstDepositOnDate(EXPECTED_FIRST_DEPOSIT_ON_ON_DATE) this.responseSpec).withSubmittedOnDate(SUBMITTED_ON_DATE)
.build(clientID, productID, penalInterestType); .withExpectedFirstDepositOnDate(EXPECTED_FIRST_DEPOSIT_ON_ON_DATE)
.build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" return Utils.performServerPut(this.requestSpec, this.responseSpec,
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
} }
public HashMap updateInterestCalculationConfigForRecurringDeposit(final String clientID, final String productID, public HashMap updateInterestCalculationConfigForRecurringDeposit(final String clientID, final String productID,
final String accountID, final String submittedOnDate, final String validFrom, final String validTo, final String accountID, final String submittedOnDate, final String validFrom, final String validTo,
final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType, final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType,
final String interestCompoundingPeriodType, final String interestPostingPeriodType, final String expectedFirstDepositOnDate) { final String interestCompoundingPeriodType, final String interestPostingPeriodType,
final String expectedFirstDepositOnDate) {
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) // final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec,
.withSubmittedOnDate(submittedOnDate) // this.responseSpec) //
.withNumberOfDaysPerYear(numberOfDaysPerYear) // .withSubmittedOnDate(submittedOnDate) //
.withInterestCalculationPeriodType(interestCalculationType) // .withNumberOfDaysPerYear(numberOfDaysPerYear) //
.withInterestCompoundingPeriodType(interestCompoundingPeriodType) // .withInterestCalculationPeriodType(interestCalculationType) //
.withInterestPostingPeriodType(interestPostingPeriodType) // .withInterestCompoundingPeriodType(interestCompoundingPeriodType) //
.withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) // .withInterestPostingPeriodType(interestPostingPeriodType) //
.build(clientID, productID, penalInterestType); .withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) //
.build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" return Utils.performServerPut(this.requestSpec, this.responseSpec,
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
} }
public Integer updateTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate, public Integer updateTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId,
final Float transactionAmount) { final String transactionDate, final Float transactionAmount) {
System.out.println("--------------------------------- UPDATE RECURRING DEPOSIT TRANSACTION ------------------------------------"); LOG.info(
return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID "--------------------------------- UPDATE RECURRING DEPOSIT TRANSACTION ------------------------------------");
+ "/transactions/" + transactionId + "?command=" + MODIFY_TRANSACTION_COMMAND, return Utils.performServerPost(this.requestSpec, this.responseSpec,
RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "/transactions/" + transactionId + "?command="
+ MODIFY_TRANSACTION_COMMAND,
getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID); getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public Integer undoTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate, public Integer undoTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId,
final Float transactionAmount) { final String transactionDate, final Float transactionAmount) {
System.out.println("--------------------------------- UNDO RECURRING DEPOSIT TRANSACTION ------------------------------------"); LOG.info(
return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID "--------------------------------- UNDO RECURRING DEPOSIT TRANSACTION ------------------------------------");
+ "/transactions/" + transactionId + "?command=" + UNDO_TRANSACTION_COMMAND, return Utils.performServerPost(this.requestSpec, this.responseSpec,
RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "/transactions/" + transactionId + "?command="
+ UNDO_TRANSACTION_COMMAND,
getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID); getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public HashMap approveRecurringDeposit(final Integer recurringDepositAccountID, final String approvedOnDate) { public HashMap approveRecurringDeposit(final Integer recurringDepositAccountID, final String approvedOnDate) {
System.out LOG.info(
.println("--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------"); "--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------");
return performRecurringDepositApplicationActions( return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(APPROVE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), createRecurringDepositOperationURL(APPROVE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
getApproveRecurringDepositAccountAsJSON(approvedOnDate)); getApproveRecurringDepositAccountAsJSON(approvedOnDate));
} }
public HashMap undoApproval(final Integer recurringDepositAccountID) { public HashMap undoApproval(final Integer recurringDepositAccountID) {
System.out LOG.info(
.println("--------------------------------- UNDO APPROVING RECURRING DEPOSIT APPLICATION -------------------------------"); "--------------------------------- UNDO APPROVING RECURRING DEPOSIT APPLICATION -------------------------------");
final String undoBodyJson = "{'note':'UNDO APPROVAL'}"; final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
return performRecurringDepositApplicationActions( return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), undoBodyJson); createRecurringDepositOperationURL(UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
undoBodyJson);
} }
public HashMap rejectApplication(final Integer recurringDepositAccountID, final String rejectedOnDate) { public HashMap rejectApplication(final Integer recurringDepositAccountID, final String rejectedOnDate) {
System.out.println("--------------------------------- REJECT RECURRING DEPOSIT APPLICATION -------------------------------"); LOG.info(
"--------------------------------- REJECT RECURRING DEPOSIT APPLICATION -------------------------------");
return performRecurringDepositApplicationActions( return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(REJECT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), createRecurringDepositOperationURL(REJECT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
getRejectedRecurringDepositAsJSON(rejectedOnDate)); getRejectedRecurringDepositAsJSON(rejectedOnDate));
} }
public HashMap withdrawApplication(final Integer recurringDepositAccountID, final String withdrawApplicationOnDate) { public HashMap withdrawApplication(final Integer recurringDepositAccountID,
System.out.println("--------------------------------- WITHDRAW RECURRING DEPOSIT APPLICATION -------------------------------"); final String withdrawApplicationOnDate) {
LOG.info(
"--------------------------------- WITHDRAW RECURRING DEPOSIT APPLICATION -------------------------------");
return performRecurringDepositApplicationActions( return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), createRecurringDepositOperationURL(WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND,
recurringDepositAccountID),
getWithdrawnRecurringDepositAccountAsJSON(withdrawApplicationOnDate)); getWithdrawnRecurringDepositAccountAsJSON(withdrawApplicationOnDate));
} }
public HashMap activateRecurringDeposit(final Integer recurringDepositAccountID, final String activationDate) { public HashMap activateRecurringDeposit(final Integer recurringDepositAccountID, final String activationDate) {
System.out LOG.info(
.println("---------------------------------- ACTIVATING RECURRING DEPOSIT APPLICATION ----------------------------------"); "---------------------------------- ACTIVATING RECURRING DEPOSIT APPLICATION ----------------------------------");
return performRecurringDepositApplicationActions( return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(ACTIVATE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), createRecurringDepositOperationURL(ACTIVATE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
getActivatedRecurringDepositAccountAsJSON(activationDate)); getActivatedRecurringDepositAccountAsJSON(activationDate));
} }
public Object deleteRecurringDepositApplication(final Integer recurringDepositAccountID, final String jsonAttributeToGetBack) { public Object deleteRecurringDepositApplication(final Integer recurringDepositAccountID,
System.out.println("---------------------------------- DELETE RECURRING DEPOSIT APPLICATION ----------------------------------"); final String jsonAttributeToGetBack) {
return Utils.performServerDelete(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" LOG.info(
+ recurringDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack); "---------------------------------- DELETE RECURRING DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec,
RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?" + Utils.TENANT_IDENTIFIER,
jsonAttributeToGetBack);
} }
public Integer calculateInterestForRecurringDeposit(final Integer recurringDepositAccountId) { public Integer calculateInterestForRecurringDeposit(final Integer recurringDepositAccountId) {
System.out.println("--------------------------------- CALCULATING INTEREST FOR RECURRING DEPOSIT --------------------------------"); LOG.info(
"--------------------------------- CALCULATING INTEREST FOR RECURRING DEPOSIT --------------------------------");
return (Integer) performRecurringDepositActions( return (Integer) performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId), createRecurringDepositCalculateInterestURL(CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND,
recurringDepositAccountId),
getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public Integer postInterestForRecurringDeposit(final Integer recurringDepositAccountId) { public Integer postInterestForRecurringDeposit(final Integer recurringDepositAccountId) {
System.out.println("--------------------------------- POST INTEREST FOR RECURRING DEPOSIT --------------------------------"); LOG.info(
"--------------------------------- POST INTEREST FOR RECURRING DEPOSIT --------------------------------");
return (Integer) performRecurringDepositActions( return (Integer) performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(POST_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId), createRecurringDepositCalculateInterestURL(POST_INTEREST_RECURRING_DEPOSIT_COMMAND,
recurringDepositAccountId),
getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public Integer depositToRecurringDepositAccount(final Integer recurringDepositAccountId, final Float depositAmount, public Integer depositToRecurringDepositAccount(final Integer recurringDepositAccountId, final Float depositAmount,
final String depositedOnDate) { final String depositedOnDate) {
System.out.println("--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------"); LOG.info(
"--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------");
return (Integer) performRecurringDepositActions( return (Integer) performRecurringDepositActions(
createDepositToRecurringDepositURL(DEPOSIT_INTO_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId), createDepositToRecurringDepositURL(DEPOSIT_INTO_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId),
getDepositToRecurringDepositAccountAsJSON(depositAmount, depositedOnDate), CommonConstants.RESPONSE_RESOURCE_ID); getDepositToRecurringDepositAccountAsJSON(depositAmount, depositedOnDate),
CommonConstants.RESPONSE_RESOURCE_ID);
} }
public HashMap calculatePrematureAmountForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate) { public HashMap calculatePrematureAmountForRecurringDeposit(final Integer recurringDepositAccountId,
System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR RECURRING DEPOSIT ----------------------------"); final String closedOnDate) {
LOG.info(
"--------------------- CALCULATING PREMATURE AMOUNT FOR RECURRING DEPOSIT ----------------------------");
return (HashMap) performRecurringDepositActions( return (HashMap) performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, recurringDepositAccountId), createRecurringDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND,
recurringDepositAccountId),
getCalculatedPrematureAmountForRecurringDepositAccountAsJSON(closedOnDate), ""); getCalculatedPrematureAmountForRecurringDepositAccountAsJSON(closedOnDate), "");
} }
public Object prematureCloseForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate, public Object prematureCloseForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate,
final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) { final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) {
System.out.println("--------------------- PREMATURE CLOSE FOR RECURRING DEPOSIT ----------------------------"); LOG.info("--------------------- PREMATURE CLOSE FOR RECURRING DEPOSIT ----------------------------");
return performRecurringDepositActions( return performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, recurringDepositAccountId), createRecurringDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, recurringDepositAccountId),
getPrematureCloseForRecurringDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack); getPrematureCloseForRecurringDepositAccountAsJSON(closedOnDate, closureType, toSavingsId),
jsonAttributeToGetBack);
} }
private String getApproveRecurringDepositAccountAsJSON(final String approvedOnDate) { private String getApproveRecurringDepositAccountAsJSON(final String approvedOnDate) {
@@ -351,7 +384,7 @@ public class RecurringDepositAccountHelper {
map.put("approvedOnDate", approvedOnDate); map.put("approvedOnDate", approvedOnDate);
map.put("note", "Approval NOTE"); map.put("note", "Approval NOTE");
String recurringDepositAccountApproveJson = new Gson().toJson(map); String recurringDepositAccountApproveJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountApproveJson); LOG.info(recurringDepositAccountApproveJson);
return recurringDepositAccountApproveJson; return recurringDepositAccountApproveJson;
} }
@@ -362,7 +395,7 @@ public class RecurringDepositAccountHelper {
map.put("transactionDate", transactionDate); map.put("transactionDate", transactionDate);
map.put("transactionAmount", transactionAmount); map.put("transactionAmount", transactionAmount);
String updateTransactionJson = new Gson().toJson(map); String updateTransactionJson = new Gson().toJson(map);
System.out.println(updateTransactionJson); LOG.info(updateTransactionJson);
return updateTransactionJson; return updateTransactionJson;
} }
@@ -373,7 +406,7 @@ public class RecurringDepositAccountHelper {
map.put("rejectedOnDate", rejectedOnDate); map.put("rejectedOnDate", rejectedOnDate);
map.put("note", "Rejected NOTE"); map.put("note", "Rejected NOTE");
String recurringDepositAccountJson = new Gson().toJson(map); String recurringDepositAccountJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountJson); LOG.info("{}", recurringDepositAccountJson);
return recurringDepositAccountJson; return recurringDepositAccountJson;
} }
@@ -384,7 +417,7 @@ public class RecurringDepositAccountHelper {
map.put("withdrawnOnDate", withdrawnApplicationOnDate); map.put("withdrawnOnDate", withdrawnApplicationOnDate);
map.put("note", "Withdraw NOTE"); map.put("note", "Withdraw NOTE");
String recurringDepositAccountJson = new Gson().toJson(map); String recurringDepositAccountJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountJson); LOG.info("{}", recurringDepositAccountJson);
return recurringDepositAccountJson; return recurringDepositAccountJson;
} }
@@ -394,14 +427,14 @@ public class RecurringDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("activatedOnDate", activationDate); map.put("activatedOnDate", activationDate);
String recurringDepositAccountActivateJson = new Gson().toJson(map); String recurringDepositAccountActivateJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountActivateJson); LOG.info(recurringDepositAccountActivateJson);
return recurringDepositAccountActivateJson; return recurringDepositAccountActivateJson;
} }
private String getCalculatedInterestForRecurringDepositApplicationAsJSON() { private String getCalculatedInterestForRecurringDepositApplicationAsJSON() {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
String recurringDepositAccountCalculatedInterestJson = new Gson().toJson(map); String recurringDepositAccountCalculatedInterestJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountCalculatedInterestJson); LOG.info(recurringDepositAccountCalculatedInterestJson);
return recurringDepositAccountCalculatedInterestJson; return recurringDepositAccountCalculatedInterestJson;
} }
@@ -411,7 +444,7 @@ public class RecurringDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
map.put("closedOnDate", closedOnDate); map.put("closedOnDate", closedOnDate);
String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map); String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountPrematureClosureJson); LOG.info(recurringDepositAccountPrematureClosureJson);
return recurringDepositAccountPrematureClosureJson; return recurringDepositAccountPrematureClosureJson;
} }
@@ -422,12 +455,12 @@ public class RecurringDepositAccountHelper {
map.put("transactionAmount", depositAmount); map.put("transactionAmount", depositAmount);
map.put("transactionDate", depositedOnDate); map.put("transactionDate", depositedOnDate);
String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map); String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountPrematureClosureJson); LOG.info(recurringDepositAccountPrematureClosureJson);
return recurringDepositAccountPrematureClosureJson; return recurringDepositAccountPrematureClosureJson;
} }
private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate, final String closureType, private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate,
final Integer toSavingsId) { final String closureType, final Integer toSavingsId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("locale", CommonConstants.locale); map.put("locale", CommonConstants.locale);
map.put("dateFormat", CommonConstants.dateFormat); map.put("dateFormat", CommonConstants.dateFormat);
@@ -438,12 +471,13 @@ public class RecurringDepositAccountHelper {
map.put("transferDescription", "Transferring To Savings Account"); map.put("transferDescription", "Transferring To Savings Account");
} }
String recurringDepositAccountPrematureCloseJson = new Gson().toJson(map); String recurringDepositAccountPrematureCloseJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountPrematureCloseJson); LOG.info(recurringDepositAccountPrematureCloseJson);
return recurringDepositAccountPrematureCloseJson; return recurringDepositAccountPrematureCloseJson;
} }
private String createRecurringDepositOperationURL(final String command, final Integer recurringDepositAccountID) { private String createRecurringDepositOperationURL(final String command, final Integer recurringDepositAccountID) {
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
} }
private Object performRecurringDepositActions(final String postURLForRecurringDeposit, final String jsonToBeSent, private Object performRecurringDepositActions(final String postURLForRecurringDeposit, final String jsonToBeSent,
@@ -452,23 +486,26 @@ public class RecurringDepositAccountHelper {
jsonAttributeToGetBack); jsonAttributeToGetBack);
} }
private HashMap performRecurringDepositApplicationActions(final String postURLForRecurringDepositAction, final String jsonToBeSent) { private HashMap performRecurringDepositApplicationActions(final String postURLForRecurringDepositAction,
final String jsonToBeSent) {
HashMap status = null; HashMap status = null;
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForRecurringDepositAction, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec,
jsonToBeSent, CommonConstants.RESPONSE_CHANGES); postURLForRecurringDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES);
if (response != null) { if (response != null) {
status = (HashMap) response.get("status"); status = (HashMap) response.get("status");
} }
return status; return status;
} }
private String createRecurringDepositCalculateInterestURL(final String command, final Integer recurringDepositAccountID) { private String createRecurringDepositCalculateInterestURL(final String command,
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; final Integer recurringDepositAccountID) {
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
} }
private String createDepositToRecurringDepositURL(final String command, final Integer recurringDepositAccountID) { private String createDepositToRecurringDepositURL(final String command, final Integer recurringDepositAccountID) {
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command + "&" return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command
+ Utils.TENANT_IDENTIFIER; + "&" + Utils.TENANT_IDENTIFIER;
} }
public RecurringDepositAccountHelper withSubmittedOnDate(final String recurringDepositApplicationSubmittedDate) { public RecurringDepositAccountHelper withSubmittedOnDate(final String recurringDepositApplicationSubmittedDate) {
@@ -476,7 +513,8 @@ public class RecurringDepositAccountHelper {
return this; return this;
} }
public RecurringDepositAccountHelper withExpectedFirstDepositOnDate(final String recurringDepositApplicationExpectedFirstDepositOnDate) { public RecurringDepositAccountHelper withExpectedFirstDepositOnDate(
final String recurringDepositApplicationExpectedFirstDepositOnDate) {
this.expectedFirstDepositOnDate = recurringDepositApplicationExpectedFirstDepositOnDate; this.expectedFirstDepositOnDate = recurringDepositApplicationExpectedFirstDepositOnDate;
return this; return this;
} }
@@ -491,7 +529,8 @@ public class RecurringDepositAccountHelper {
return this; return this;
} }
public RecurringDepositAccountHelper withInterestCompoundingPeriodType(final String interestCompoundingPeriodTypeId) { public RecurringDepositAccountHelper withInterestCompoundingPeriodType(
final String interestCompoundingPeriodTypeId) {
this.interestCompoundingPeriodType = interestCompoundingPeriodTypeId; this.interestCompoundingPeriodType = interestCompoundingPeriodTypeId;
return this; return this;
} }
@@ -25,53 +25,55 @@ import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Assert; import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class RecurringDepositAccountStatusChecker { public class RecurringDepositAccountStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositAccountStatusChecker.class);
private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/recurringdepositaccounts"; private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/recurringdepositaccounts";
public static void verifyRecurringDepositIsApproved(final HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositIsApproved(final HashMap recurringDepositStatusHashMap) {
System.out.println("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS APPROVED --------------------"); LOG.info("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS APPROVED --------------------");
assertTrue("Error in Approving Recurring deposit application", getStatus(recurringDepositStatusHashMap, "approved")); assertTrue("Error in Approving Recurring deposit application", getStatus(recurringDepositStatusHashMap, "approved"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static void verifyRecurringDepositIsPending(final HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositIsPending(final HashMap recurringDepositStatusHashMap) {
System.out.println("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS PENDING --------------------"); LOG.info("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue("RECURRING DEPOSIT ACCOUNT IS NOT IN PENDING STATE", assertTrue("RECURRING DEPOSIT ACCOUNT IS NOT IN PENDING STATE",
getStatus(recurringDepositStatusHashMap, "submittedAndPendingApproval")); getStatus(recurringDepositStatusHashMap, "submittedAndPendingApproval"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static void verifyRecurringDepositIsActive(final HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositIsActive(final HashMap recurringDepositStatusHashMap) {
System.out.println("----------------- VERIFYING RECURRING DEPOSIT APPLICATION IS ACTIVE -----------------"); LOG.info("----------------- VERIFYING RECURRING DEPOSIT APPLICATION IS ACTIVE -----------------");
assertTrue("ERROR IN ACTIVATING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "active")); assertTrue("ERROR IN ACTIVATING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "active"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static void verifyRecurringDepositIsRejected(final HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositIsRejected(final HashMap recurringDepositStatusHashMap) {
System.out.println("-------------- VERIFYING RECURRING DEPOSIT APPLICATION IS REJECTED ----------------"); LOG.info("-------------- VERIFYING RECURRING DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue("ERROR IN REJECTING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "rejected")); assertTrue("ERROR IN REJECTING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "rejected"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static void verifyRecurringDepositIsWithdrawn(final HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositIsWithdrawn(final HashMap recurringDepositStatusHashMap) {
System.out.println("---------------- VERIFYING RECURRING DEPOSIT APPLICATION IS WITHDRAWN ----------------"); LOG.info("---------------- VERIFYING RECURRING DEPOSIT APPLICATION IS WITHDRAWN ----------------");
assertTrue("ERROR IN WITHDRAW THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "withdrawnByApplicant")); assertTrue("ERROR IN WITHDRAW THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "withdrawnByApplicant"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static void verifyRecurringDepositAccountIsClosed(final HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositAccountIsClosed(final HashMap recurringDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------"); LOG.info("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue("ERROR IN CLOSING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "closed")); assertTrue("ERROR IN CLOSING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "closed"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static void verifyRecurringDepositAccountIsNotActive(final HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositAccountIsNotActive(final HashMap recurringDepositStatusHashMap) {
System.out.println("------------------ VERIFYING RECURRING DEPOSIT APPLICATION IS INACTIVE --------------------"); LOG.info("------------------ VERIFYING RECURRING DEPOSIT APPLICATION IS INACTIVE --------------------");
Assert.assertFalse(getStatus(recurringDepositStatusHashMap, "active")); Assert.assertFalse(getStatus(recurringDepositStatusHashMap, "active"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static HashMap getStatusOfRecurringDepositAccount(final RequestSpecification requestSpec, public static HashMap getStatusOfRecurringDepositAccount(final RequestSpecification requestSpec,
@@ -82,16 +84,16 @@ public class RecurringDepositAccountStatusChecker {
} }
public static void verifyRecurringDepositAccountIsPrematureClosed(HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositAccountIsPrematureClosed(HashMap recurringDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------"); LOG.info("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue("ERROR IN PREMATURELY CLOSING THE RECURRING DEPOSIT ACCOUNT", assertTrue("ERROR IN PREMATURELY CLOSING THE RECURRING DEPOSIT ACCOUNT",
getStatus(recurringDepositStatusHashMap, "prematureClosed")); getStatus(recurringDepositStatusHashMap, "prematureClosed"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
public static void verifyRecurringDepositAccountIsMatured(HashMap recurringDepositStatusHashMap) { public static void verifyRecurringDepositAccountIsMatured(HashMap recurringDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS MATURED ---------------------"); LOG.info("--------------------- 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"));
System.out.println(recurringDepositStatusHashMap); LOG.info("{}",recurringDepositStatusHashMap.toString());
} }
private static boolean getStatus(final HashMap recurringDepositStatusMap, final String recurringDepositStatusString) { private static boolean getStatus(final HashMap recurringDepositStatusMap, final String recurringDepositStatusString) {
@@ -27,10 +27,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.Account;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class RecurringDepositProductHelper { public class RecurringDepositProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositProductHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -153,7 +155,7 @@ public class RecurringDepositProductHelper {
} }
String RecurringDepositProductCreateJson = new Gson().toJson(map); String RecurringDepositProductCreateJson = new Gson().toJson(map);
System.out.println(RecurringDepositProductCreateJson); LOG.info("{}",RecurringDepositProductCreateJson);
return RecurringDepositProductCreateJson; return RecurringDepositProductCreateJson;
} }
@@ -226,14 +228,14 @@ public class RecurringDepositProductHelper {
public static Integer createRecurringDepositProduct(final String recurrungDepositProductCreateJson, public static Integer createRecurringDepositProduct(final String recurrungDepositProductCreateJson,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
System.out.println("------------------ CREATING RECURRING DEPOSIT PRODUCT--------------------"); LOG.info("------------------ CREATING RECURRING DEPOSIT PRODUCT--------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_RECURRING_DEPOSIT_PRODUCT_URL, recurrungDepositProductCreateJson, return Utils.performServerPost(requestSpec, responseSpec, CREATE_RECURRING_DEPOSIT_PRODUCT_URL, recurrungDepositProductCreateJson,
"resourceId"); "resourceId");
} }
public static ArrayList retrieveAllRecurringDepositProducts(final RequestSpecification requestSpec, public static ArrayList retrieveAllRecurringDepositProducts(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
System.out.println("----------------- RETRIEVING ALL RECURRING DEPOSIT PRODUCTS---------------------------"); LOG.info("----------------- RETRIEVING ALL RECURRING DEPOSIT PRODUCTS---------------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, RECURRING_DEPOSIT_PRODUCT_URL + "?" final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, RECURRING_DEPOSIT_PRODUCT_URL + "?"
+ Utils.TENANT_IDENTIFIER, ""); + Utils.TENANT_IDENTIFIER, "");
return response; return response;
@@ -241,7 +243,7 @@ public class RecurringDepositProductHelper {
public static HashMap retrieveRecurringDepositProductById(final RequestSpecification requestSpec, public static HashMap retrieveRecurringDepositProductById(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String productId) { final ResponseSpecification responseSpec, final String productId) {
System.out.println("-------------------- RETRIEVING RECURRING DEPOSIT PRODUCT BY ID --------------------------"); LOG.info("-------------------- RETRIEVING RECURRING DEPOSIT PRODUCT BY ID --------------------------");
final String GET_RD_PRODUCT_BY_ID_URL = RECURRING_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER; final String GET_RD_PRODUCT_BY_ID_URL = RECURRING_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_RD_PRODUCT_BY_ID_URL, ""); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_RD_PRODUCT_BY_ID_URL, "");
return response; return response;
@@ -249,7 +251,7 @@ public class RecurringDepositProductHelper {
public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec, public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer productId) { final ResponseSpecification responseSpec, final Integer productId) {
System.out.println("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------"); LOG.info("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId, final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId,
"chartSlabs"); "chartSlabs");
return response; return response;
@@ -23,9 +23,11 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AccountTransferHelper { public class AccountTransferHelper {
private final static Logger LOG = LoggerFactory.getLogger(AccountTransferHelper.class);
private static final String ACCOUNT_TRANSFER_URL = "/fineract-provider/api/v1/accounttransfers"; private static final String ACCOUNT_TRANSFER_URL = "/fineract-provider/api/v1/accounttransfers";
private static final String LOAN_REFUND_BY_TRANSFER_URL = "/fineract-provider/api/v1/accounttransfers/refundByTransfer"; private static final String LOAN_REFUND_BY_TRANSFER_URL = "/fineract-provider/api/v1/accounttransfers/refundByTransfer";
private static final String LOCALE = "en_GB"; private static final String LOCALE = "en_GB";
@@ -45,8 +47,9 @@ public class AccountTransferHelper {
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public String build(final String fromAccountId, final String fromClientId, final String toAccountId, final String toClientId, public String build(final String fromAccountId, final String fromClientId, final String toAccountId,
final String fromAccountType, final String toAccountType, final String transferAmount) { final String toClientId, final String fromAccountType, final String toAccountType,
final String transferAmount) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
@@ -63,7 +66,7 @@ public class AccountTransferHelper {
map.put("transferAmount", transferAmount); map.put("transferAmount", transferAmount);
map.put("transferDescription", this.transferDescription); map.put("transferDescription", this.transferDescription);
String savingsApplicationJSON = new Gson().toJson(map); String savingsApplicationJSON = new Gson().toJson(map);
System.out.println(savingsApplicationJSON); LOG.info("{}", savingsApplicationJSON);
return savingsApplicationJSON; return savingsApplicationJSON;
} }
@@ -73,24 +76,26 @@ public class AccountTransferHelper {
} }
public Integer accountTransfer(final Integer fromClientId, final Integer fromAccountId, final Integer toClientId, public Integer accountTransfer(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,
System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------"); final String transferAmount) {
LOG.info("--------------------------------ACCOUNT TRANSFER--------------------------------");
final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) // final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) //
.withTransferOnDate(ACCOUNT_TRANSFER_DATE) // .withTransferOnDate(ACCOUNT_TRANSFER_DATE) //
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), fromAccountType, .build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(),
toAccountType, transferAmount); fromAccountType, toAccountType, transferAmount);
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, return Utils.performServerPost(this.requestSpec, this.responseSpec,
accountTransferJSON, "savingsId"); ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, 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 toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) { final Integer toClientId, final Integer toAccountId, final String fromAccountType,
System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------"); final String toAccountType, final String transferAmount) {
LOG.info("--------------------------------ACCOUNT TRANSFER--------------------------------");
final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) // final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) //
.withTransferOnDate(date) // .withTransferOnDate(date) //
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), fromAccountType, .build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(),
toAccountType, transferAmount); fromAccountType, toAccountType, transferAmount);
return Utils.performServerPost(this.requestSpec, this.responseSpec, LOAN_REFUND_BY_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, return Utils.performServerPost(this.requestSpec, this.responseSpec,
accountTransferJSON, "savingsId"); LOAN_REFUND_BY_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, accountTransferJSON, "savingsId");
} }
} }
@@ -24,117 +24,135 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class SavingsStatusChecker { public class SavingsStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(SavingsStatusChecker.class);
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) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS APPROVED ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS APPROVED ------------------------------------");
assertTrue("ERROR IN APPROVING SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "approved")); assertTrue("ERROR IN APPROVING SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "approved"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Status: {} \n", savingsStatusHashMap);
} }
public static void verifySavingsIsPending(final HashMap savingsStatusHashMap) { public static void verifySavingsIsPending(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS PENDING ------------------------------------"); LOG.info(
assertTrue("SAVINGS ACCOUNT IS NOT IN PENDING STATE", getStatus(savingsStatusHashMap, "submittedAndPendingApproval")); "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS PENDING ------------------------------------");
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); assertTrue("SAVINGS ACCOUNT IS NOT IN PENDING STATE",
getStatus(savingsStatusHashMap, "submittedAndPendingApproval"));
LOG.info("Savings Application Status: {} \n", savingsStatusHashMap);
} }
public static void verifySavingsIsActive(final HashMap savingsStatusHashMap) { public static void verifySavingsIsActive(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------");
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"); LOG.info("Savings Application Status: {} \n", savingsStatusHashMap);
} }
public static void verifySavingsIsRejected(final HashMap savingsStatusHashMap) { public static void verifySavingsIsRejected(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS REJECTED ------------------------------------"); LOG.info(
"\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"); LOG.info("Savings Application Status: {} \n", savingsStatusHashMap);
} }
public static void verifySavingsIsWithdrawn(final HashMap savingsStatusHashMap) { public static void verifySavingsIsWithdrawn(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------"); LOG.info(
assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "withdrawnByApplicant")); "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------");
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION",
getStatus(savingsStatusHashMap, "withdrawnByApplicant"));
LOG.info("Savings Application Status: {}", savingsStatusHashMap);
} }
public static void verifySavingsAccountIsClosed(final HashMap savingsStatusHashMap) { public static void verifySavingsAccountIsClosed(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS CLOSED ------------------------------------"); LOG.info(
"\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"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Status: {}", savingsStatusHashMap);
} }
public static void verifySavingsAccountIsNotActive(final HashMap savingsStatusHashMap) { public static void verifySavingsAccountIsNotActive(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS INACTIVE ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS INACTIVE ------------------------------------");
assertTrue(getStatus(savingsStatusHashMap, "active")); assertTrue(getStatus(savingsStatusHashMap, "active"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Status: {} \n", savingsStatusHashMap);
} }
public static HashMap getStatusOfSavings(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getStatusOfSavings(final RequestSpecification requestSpec,
final Integer savingsID) { final ResponseSpecification responseSpec, final Integer savingsID) {
final String url = SAVINGS_ACCOUNT_URL+"/" + savingsID + "?"+Utils.TENANT_IDENTIFIER; final String url = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, url, "status"); return Utils.performServerGet(requestSpec, responseSpec, url, "status");
} }
public static HashMap getSubStatusOfSavings(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static HashMap getSubStatusOfSavings(final RequestSpecification requestSpec,
final Integer savingsID) { final ResponseSpecification responseSpec, final Integer savingsID) {
final String url = SAVINGS_ACCOUNT_URL+"/" + savingsID + "?"+Utils.TENANT_IDENTIFIER; final String url = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, url, "subStatus"); return Utils.performServerGet(requestSpec, responseSpec, url, "subStatus");
} }
private static boolean getStatus(final HashMap savingsStatusMap, final String nameOfSavingsStatusString) { private static boolean getStatus(final HashMap savingsStatusMap, final String nameOfSavingsStatusString) {
return (Boolean) savingsStatusMap.get(nameOfSavingsStatusString); return (Boolean) savingsStatusMap.get(nameOfSavingsStatusString);
} }
public static void verifySavingsSubStatusInactive(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusInactive(HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------");
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"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
public static void verifySavingsSubStatusDormant(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusDormant(HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); LOG.info(
"\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"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
public static void verifySavingsSubStatusEscheat(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusEscheat(HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------");
assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "escheat")); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "escheat"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
public static void verifySavingsSubStatusNone(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusNone(HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------");
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"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
public static void verifySavingsSubStatusblock(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusblock(HashMap savingsStatusHashMap) {
System.out.println( LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS ACCOUNT IS BLOCKED ------------------------------------"); "\n-------------------------------------- VERIFYING SAVINGS ACCOUNT IS BLOCKED ------------------------------------");
assertTrue("block", getStatus(savingsStatusHashMap, "block")); assertTrue("block", getStatus(savingsStatusHashMap, "block"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
public static void verifySavingsSubStatusIsNone(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusIsNone(HashMap savingsStatusHashMap) {
System.out.println("\n------------------------- VERIFYING SAVINGS ACCOUNT IS NOT BLOCKED FOR ANY TYPE OF TRANSACTIONS ---------------------------"); LOG.info(
"\n------------------------- VERIFYING SAVINGS ACCOUNT IS NOT BLOCKED FOR ANY TYPE OF TRANSACTIONS ---------------------------");
assertTrue("none", getStatus(savingsStatusHashMap, "none")); assertTrue("none", getStatus(savingsStatusHashMap, "none"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
public static void verifySavingsSubStatusIsDebitBlocked(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusIsDebitBlocked(HashMap savingsStatusHashMap) {
System.out.println("\n--------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR DEBIT TRANSACTIONS ---------------------"); LOG.info(
"\n--------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR DEBIT TRANSACTIONS ---------------------");
assertTrue("status is blockDebit", getStatus(savingsStatusHashMap, "blockDebit")); assertTrue("status is blockDebit", getStatus(savingsStatusHashMap, "blockDebit"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
public static void verifySavingsSubStatusIsCreditBlocked(HashMap savingsStatusHashMap) { public static void verifySavingsSubStatusIsCreditBlocked(HashMap savingsStatusHashMap) {
System.out.println("\n---------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR CREDIT TRANSACTIONS ---------------"); LOG.info(
"\n---------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR CREDIT TRANSACTIONS ---------------");
assertTrue("blockCredit ", getStatus(savingsStatusHashMap, "blockCredit")); assertTrue("blockCredit ", getStatus(savingsStatusHashMap, "blockCredit"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
} }
} }
@@ -23,10 +23,11 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShareAccountHelper { public class ShareAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(ShareAccountHelper.class);
private static final String LOCALE = "en_GB"; private static final String LOCALE = "en_GB";
private String clientId ; private String clientId ;
@@ -96,7 +97,7 @@ public class ShareAccountHelper {
} }
String shareAccountCreateJson = new Gson().toJson(map); String shareAccountCreateJson = new Gson().toJson(map);
System.out.println(shareAccountCreateJson); LOG.info("{}",shareAccountCreateJson);
return shareAccountCreateJson; return shareAccountCreateJson;
} }
@@ -40,9 +40,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShareAccountIntegrationTests { public class ShareAccountIntegrationTests {
private final static Logger LOG = LoggerFactory.getLogger(ShareAccountIntegrationTests.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ShareProductHelper shareProductHelper; private ShareProductHelper shareProductHelper;
@@ -59,21 +61,21 @@ public class ShareAccountIntegrationTests {
public void testCreateShareProduct() { public void testCreateShareProduct() {
// This method will check create share product, get share product, // This method will check create share product, get share product,
// update share product. // update share product.
System.out.println("------------------------------CREATING NEW SHARE PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW SHARE PRODUCT ---------------------------------------");
shareProductHelper = new ShareProductHelper(); shareProductHelper = new ShareProductHelper();
final Integer shareProductId = createShareProduct(); final Integer shareProductId = createShareProduct();
Assert.assertNotNull(shareProductId); Assert.assertNotNull(shareProductId);
System.out.println("------------------------------CREATING SHARE PRODUCT COMPLETE---------------------------------------"); LOG.info("------------------------------CREATING SHARE PRODUCT COMPLETE---------------------------------------");
System.out.println("------------------------------RETRIEVING SHARE PRODUCT---------------------------------------"); LOG.info("------------------------------RETRIEVING SHARE PRODUCT---------------------------------------");
Map<String, Object> shareProductData = ShareProductTransactionHelper Map<String, Object> shareProductData = ShareProductTransactionHelper
.retrieveShareProduct(shareProductId, requestSpec, responseSpec); .retrieveShareProduct(shareProductId, requestSpec, responseSpec);
Assert.assertNotNull(shareProductData); Assert.assertNotNull(shareProductData);
shareProductHelper.verifyShareProduct(shareProductData); shareProductHelper.verifyShareProduct(shareProductData);
System.out.println("------------------------------RETRIEVING SHARE PRODUCT COMPLETE---------------------------------------"); LOG.info("------------------------------RETRIEVING SHARE PRODUCT COMPLETE---------------------------------------");
System.out.println("------------------------------UPDATING SHARE PRODUCT---------------------------------------"); LOG.info("------------------------------UPDATING SHARE PRODUCT---------------------------------------");
Map<String, Object> shareProductDataForUpdate = new HashMap<>(); Map<String, Object> shareProductDataForUpdate = new HashMap<>();
@@ -90,7 +92,7 @@ public class ShareAccountIntegrationTests {
String updatedSharesIssued = String.valueOf(updatedShareProductData.get("totalSharesIssued")); String updatedSharesIssued = String.valueOf(updatedShareProductData.get("totalSharesIssued"));
Assert.assertEquals("2000", updatedTotalShares); Assert.assertEquals("2000", updatedTotalShares);
Assert.assertEquals("2000", updatedSharesIssued); Assert.assertEquals("2000", updatedSharesIssued);
System.out.println("------------------------------UPDATING SHARE PRODUCT COMPLETE---------------------------------------"); LOG.info("------------------------------UPDATING SHARE PRODUCT COMPLETE---------------------------------------");
} }
@@ -29,11 +29,12 @@ import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.junit.Assert; import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShareProductHelper { public class ShareProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(ShareProductHelper.class);
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";
@@ -94,7 +95,7 @@ public class ShareProductHelper {
} }
String shareProductCreateJson = new Gson().toJson(map); String shareProductCreateJson = new Gson().toJson(map);
System.out.println(shareProductCreateJson); LOG.info("{}",shareProductCreateJson);
return shareProductCreateJson; return shareProductCreateJson;
} }
@@ -23,9 +23,11 @@ import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AccountNumberPreferencesHelper { public class AccountNumberPreferencesHelper {
private final static Logger LOG = LoggerFactory.getLogger(AccountNumberPreferencesHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -41,8 +43,7 @@ public class AccountNumberPreferencesHelper {
public Object createClientAccountNumberPreference( public Object createClientAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out LOG.info("---------------------------------CREATING CLIENT ACCOUNT NUMBER PREFERENCE------------------------------------------");
.println("---------------------------------CREATING CLIENT ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder() final String requestJSON = new AccountNumberPreferencesTestBuilder()
.clientBuild(); .clientBuild();
@@ -56,8 +57,7 @@ public class AccountNumberPreferencesHelper {
public Object createLoanAccountNumberPreference( public Object createLoanAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out LOG.info("---------------------------------CREATING LOAN ACCOUNT NUMBER PREFERENCE------------------------------------------");
.println("---------------------------------CREATING LOAN ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder() final String requestJSON = new AccountNumberPreferencesTestBuilder()
.loanBuild(); .loanBuild();
@@ -70,8 +70,7 @@ public class AccountNumberPreferencesHelper {
public Object createSavingsAccountNumberPreference( public Object createSavingsAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out LOG.info("---------------------------------CREATING SAVINGS ACCOUNT NUMBER PREFERENCE------------------------------------------");
.println("---------------------------------CREATING SAVINGS ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder() final String requestJSON = new AccountNumberPreferencesTestBuilder()
.savingsBuild(); .savingsBuild();
@@ -85,8 +84,7 @@ public class AccountNumberPreferencesHelper {
public Object createGroupsAccountNumberPreference( public Object createGroupsAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out LOG.info("---------------------------------CREATING GROUPS ACCOUNT NUMBER PREFERENCE------------------------------------------");
.println("---------------------------------CREATING GROUPS ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder() final String requestJSON = new AccountNumberPreferencesTestBuilder()
.groupsBuild(); .groupsBuild();
@@ -100,8 +98,7 @@ public class AccountNumberPreferencesHelper {
public Object createCenterAccountNumberPreference( public Object createCenterAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out LOG.info("---------------------------------CREATING CENTER ACCOUNT NUMBER PREFERENCE------------------------------------------");
.println("---------------------------------CREATING CENTER ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder() final String requestJSON = new AccountNumberPreferencesTestBuilder()
.centerBuild(); .centerBuild();
@@ -146,8 +143,7 @@ public class AccountNumberPreferencesHelper {
final Integer accountNumberFormatId, final Integer accountNumberFormatId,
ResponseSpecification responseSpec, String jsonAttributeToGetBack) { ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out LOG.info("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE------------------------------------------");
.println("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/" final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
+ accountNumberFormatId + "?" + Utils.TENANT_IDENTIFIER; + accountNumberFormatId + "?" + Utils.TENANT_IDENTIFIER;
@@ -27,9 +27,11 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DatatableHelper { public class DatatableHelper {
private final static Logger LOG = LoggerFactory.getLogger(DatatableHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -58,7 +60,7 @@ public class DatatableHelper {
public static void verifyDatatableCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyDatatableCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String generatedDatatableName) { final String generatedDatatableName) {
System.out.println("------------------------------CHECK DATATABLE DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK DATATABLE DETAILS------------------------------------\n");
final String responseRegisteredTableName = Utils.performServerGet(requestSpec, responseSpec, DATATABLE_URL + "/" final String responseRegisteredTableName = Utils.performServerGet(requestSpec, responseSpec, DATATABLE_URL + "/"
+ generatedDatatableName + "?" + Utils.TENANT_IDENTIFIER, "registeredTableName"); + generatedDatatableName + "?" + Utils.TENANT_IDENTIFIER, "registeredTableName");
assertEquals("ERROR IN CREATING THE DATATABLE", generatedDatatableName, responseRegisteredTableName); assertEquals("ERROR IN CREATING THE DATATABLE", generatedDatatableName, responseRegisteredTableName);
@@ -76,7 +78,7 @@ public class DatatableHelper {
addDatatableColumns(datatableColumnsList, "Date of Approval", "Date", false, null); addDatatableColumns(datatableColumnsList, "Date of Approval", "Date", false, null);
map.put("columns", datatableColumnsList); map.put("columns", datatableColumnsList);
String requestJsonString = new Gson().toJson(map); String requestJsonString = new Gson().toJson(map);
System.out.println("map : " + requestJsonString); LOG.info("map : {}" , requestJsonString);
return requestJsonString; return requestJsonString;
} }
@@ -45,9 +45,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GuarantorTest { public class GuarantorTest {
private final static Logger LOG = LoggerFactory.getLogger(GuarantorTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@@ -146,7 +148,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_2, null); verifySavingsOnHoldBalance(externalSavigsId_2, null);
Assert.assertNotNull(externalGuarantee_2); Assert.assertNotNull(externalGuarantee_2);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -157,14 +159,14 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID); loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0)); verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0));
verifySavingsOnHoldBalance(externalSavigsId_1, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_1, Float.valueOf((float)0));
verifySavingsOnHoldBalance(externalSavigsId_2, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_2, Float.valueOf((float)0));
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -172,7 +174,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -303,7 +305,7 @@ public class GuarantorTest {
Assert.assertNotNull(externalGuarantee_2); Assert.assertNotNull(externalGuarantee_2);
verifySavingsOnHoldBalance(externalSavigsId_2, null); verifySavingsOnHoldBalance(externalSavigsId_2, null);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -314,14 +316,14 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID); loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0)); verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0));
verifySavingsOnHoldBalance(externalSavigsId_1, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_1, Float.valueOf((float)0));
verifySavingsOnHoldBalance(externalSavigsId_2, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_2, Float.valueOf((float)0));
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -363,7 +365,7 @@ public class GuarantorTest {
} }
} }
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -457,7 +459,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, null); verifySavingsOnHoldBalance(externalSavigsId_1, null);
Assert.assertNotNull(externalGuarantee_1); Assert.assertNotNull(externalGuarantee_1);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -466,7 +468,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds); verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -530,7 +532,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, null); verifySavingsOnHoldBalance(externalSavigsId_1, null);
Assert.assertNotNull(externalGuarantee_1); Assert.assertNotNull(externalGuarantee_1);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -539,7 +541,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds); verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -599,7 +601,7 @@ public class GuarantorTest {
Assert.assertNotNull(externalGuarantee_1); Assert.assertNotNull(externalGuarantee_1);
verifySavingsOnHoldBalance(externalSavigsId_1, null); verifySavingsOnHoldBalance(externalSavigsId_1, null);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -608,7 +610,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds); verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -660,7 +662,7 @@ public class GuarantorTest {
private Integer createLoanProductWithHoldFunds(final String mandatoryGuarantee, final String minimumGuaranteeFromGuarantor, private Integer createLoanProductWithHoldFunds(final String mandatoryGuarantee, final String minimumGuaranteeFromGuarantor,
final String minimumGuaranteeFromOwnFunds) { final String minimumGuaranteeFromOwnFunds) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("4") LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("4")
.withRepaymentAfterEvery("1").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2") .withRepaymentAfterEvery("1").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance() .withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance()
@@ -671,7 +673,7 @@ public class GuarantorTest {
} }
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String disbursementDate) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String disbursementDate) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000.00") // .withPrincipal("10000.00") //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -21,9 +21,11 @@ package org.apache.fineract.integrationtests.loanaccount.guarantor;
import com.google.gson.Gson; import com.google.gson.Gson;
import java.util.HashMap; import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GuarantorTestBuilder { public class GuarantorTestBuilder {
private final static Logger LOG = LoggerFactory.getLogger(GuarantorTestBuilder.class);
private static final String GUARANTOR_TYPE_CUSTOMER = "1"; private static final String GUARANTOR_TYPE_CUSTOMER = "1";
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String GUARANTOR_TYPE_STAFF = "2"; private static final String GUARANTOR_TYPE_STAFF = "2";
@@ -57,7 +59,7 @@ public class GuarantorTestBuilder {
map.put("amount", guaranteeAmount); map.put("amount", guaranteeAmount);
map.put("savingsId", savingsId); map.put("savingsId", savingsId);
} }
System.out.println("map : " + map); LOG.info("map : {}" , map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -30,12 +30,14 @@ import java.util.Map;
import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.Account;
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class VariableInstallmentsDecliningBalanceHelper { public class VariableInstallmentsDecliningBalanceHelper {
private final static Logger LOG = LoggerFactory.getLogger(VariableInstallmentsDecliningBalanceHelper.class);
public static String createLoanProductWithoutVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { public static String createLoanProductWithoutVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") // .withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -51,7 +53,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
} }
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") // .withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -69,7 +71,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
} }
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") // .withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -88,7 +90,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
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--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) // .withPrincipal(principal) //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -108,7 +110,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
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--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) // .withPrincipal(principal) //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -30,12 +30,14 @@ import java.util.Map;
import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.Account;
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class VariableInstallmentsFlatHelper { public class VariableInstallmentsFlatHelper {
private final static Logger LOG = LoggerFactory.getLogger(VariableInstallmentsFlatHelper.class);
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 ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") // .withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -55,7 +57,7 @@ public class VariableInstallmentsFlatHelper {
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--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) // .withPrincipal(principal) //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -33,11 +33,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class VariableInstallmentsIntegrationTest { public class VariableInstallmentsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(VariableInstallmentsIntegrationTest.class);
private static final String NONE = "1"; private static final String NONE = "1";
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -56,7 +57,7 @@ public class VariableInstallmentsIntegrationTest {
public void testVariableLoanProductCreation() { public void testVariableLoanProductCreation() {
final String json = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE); final String json = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(json); final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(json);
System.out.println("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------"); LOG.info("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------");
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")) ;
Assert.assertEquals(Integer.valueOf(5), loanProduct.get("minimumGap")) ; Assert.assertEquals(Integer.valueOf(5), loanProduct.get("minimumGap")) ;
@@ -68,7 +69,7 @@ public class VariableInstallmentsIntegrationTest {
public void testLoanProductCreation() { public void testLoanProductCreation() {
final String josn = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithoutVaribleConfig(false, NONE); final String josn = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithoutVaribleConfig(false, NONE);
Integer loanProductID = this.loanTransactionHelper.getLoanProductId(josn); Integer loanProductID = this.loanTransactionHelper.getLoanProductId(josn);
System.out.println("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------"); LOG.info("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------");
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")) ;
} }
@@ -22,10 +22,13 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
public abstract class ApplicationExitUtil {
public abstract class ApplicationExitUtil {
private final static Logger LOG = LoggerFactory.getLogger(ApplicationExitUtil.class);
private ApplicationExitUtil() {} private ApplicationExitUtil() {}
public static void waitForKeyPressToCleanlyExit(ConfigurableApplicationContext ctx) throws IOException { public static void waitForKeyPressToCleanlyExit(ConfigurableApplicationContext ctx) throws IOException {
@@ -34,7 +37,7 @@ public abstract class ApplicationExitUtil {
// button).. In the case of MariaDB4j that's a problem because then the // button).. In the case of MariaDB4j that's a problem because then the
// mysqld won't be stopped, so: // mysqld won't be stopped, so:
// (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016) // (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016)
System.out.println("\nHit Enter to quit..."); LOG.info("\nHit Enter to quit...");
// NOTE: In Eclipse, System.console() is not available.. so: // NOTE: In Eclipse, System.console() is not available.. so:
// (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429) // (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429)
BufferedReader d = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); BufferedReader d = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
@@ -25,6 +25,8 @@ import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Exception with multiple root causes. * Exception with multiple root causes.
@@ -41,7 +43,7 @@ import java.util.List;
* @author Michael Vorburger.ch <mike@vorburger.ch> * @author Michael Vorburger.ch <mike@vorburger.ch>
*/ */
public class MultiException extends Exception { public class MultiException extends Exception {
private final static Logger LOG = LoggerFactory.getLogger(MultiException.class);
private final List<Throwable> throwables; private final List<Throwable> throwables;
public MultiException(List<Throwable> problems) { public MultiException(List<Throwable> problems) {
@@ -71,10 +73,10 @@ public class MultiException extends Exception {
@Override @Override
public void printStackTrace() { public void printStackTrace() {
System.err.println(super.getMessage()); LOG.info("{}", super.getMessage());
int i = 0; int i = 0;
for (Throwable e : throwables) { for (Throwable e : throwables) {
System.err.print(++i + "."); LOG.info("{}.",++i);
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -30,7 +30,8 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.conn.HttpHostConnectException; import org.apache.http.conn.HttpHostConnectException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
@@ -42,7 +43,7 @@ import org.apache.http.conn.HttpHostConnectException;
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class Utils { public class Utils {
private final static Logger LOG = LoggerFactory.getLogger(Utils.class);
public static final String TENANT_IDENTIFIER = "tenantIdentifier=default"; public static final String TENANT_IDENTIFIER = "tenantIdentifier=default";
private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?username=mifos&password=password&" + TENANT_IDENTIFIER; private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?username=mifos&password=password&" + TENANT_IDENTIFIER;
@@ -56,7 +57,7 @@ public class Utils {
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() { public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
try { try {
System.out.println("-----------------------------------LOGIN-----------------------------------------"); LOG.info("-----------------------------------LOGIN-----------------------------------------");
final String json = RestAssured.post(LOGIN_URL).asString(); final String json = RestAssured.post(LOGIN_URL).asString();
assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false)); assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false));
return JsonPath.with(json).get("base64EncodedAuthenticationKey"); return JsonPath.with(json).get("base64EncodedAuthenticationKey");
@@ -43,12 +43,14 @@ import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class XBRLBuilderTest { public class XBRLBuilderTest {
private final static Logger LOG = LoggerFactory.getLogger(XBRLBuilderTest.class);
@Mock @Mock
private NamespaceReadPlatformServiceImpl readNamespaceService; private NamespaceReadPlatformServiceImpl readNamespaceService;
@@ -58,8 +60,8 @@ public class XBRLBuilderTest {
@Before @Before
public void setUp() { public void setUp() {
this.readNamespaceService = Mockito.mock(NamespaceReadPlatformServiceImpl.class); this.readNamespaceService = Mockito.mock(NamespaceReadPlatformServiceImpl.class);
lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString())).thenReturn( lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString()))
new NamespaceData(1l, "mockedprefix", "mockedurl")); .thenReturn(new NamespaceData(1l, "mockedprefix", "mockedurl"));
} }
@Test @Test
@@ -68,10 +70,12 @@ public class XBRLBuilderTest {
final MixTaxonomyData data1 = Mockito.mock(MixTaxonomyData.class); final MixTaxonomyData data1 = Mockito.mock(MixTaxonomyData.class);
when(data1.getName()).thenReturn("Assets"); when(data1.getName()).thenReturn("Assets");
map.put(data1, new BigDecimal(10000)); map.put(data1, new BigDecimal(10000));
final String result = this.xbrlBuilder.build(map, Date.valueOf("2005-11-11"), Date.valueOf("2013-07-17"), "USD"); final String result = this.xbrlBuilder.build(map, Date.valueOf("2005-11-11"), Date.valueOf("2013-07-17"),
System.out.println(result); "USD");
NodeList nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( LOG.info("{}", result);
new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))).getElementsByTagName("Assets"); NodeList nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8)))
.getElementsByTagName("Assets");
assertNotNull(nodes); assertNotNull(nodes);
assertNotNull(nodes.item(0)); assertNotNull(nodes.item(0));
assertEquals("Assets", nodes.item(0).getNodeName()); assertEquals("Assets", nodes.item(0).getNodeName());
@@ -22,13 +22,15 @@ import javax.jms.JMSException;
import javax.jms.Message; import javax.jms.Message;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.listener.SessionAwareMessageListener; import org.springframework.jms.listener.SessionAwareMessageListener;
public class Listener implements SessionAwareMessageListener { public class Listener implements SessionAwareMessageListener {
private final static Logger LOG = LoggerFactory.getLogger(Listener.class);
@Override @Override
public void onMessage(Message message, Session session) throws JMSException { public void onMessage(Message message, Session session) throws JMSException {
TextMessage msg = (TextMessage) message; TextMessage msg = (TextMessage) message;
System.out.println("Received: " + msg.getText()); LOG.info("Received: {}" ,msg.getText());
} }
} }
@@ -25,6 +25,8 @@ import javax.jms.Session;
import org.apache.fineract.notification.data.NotificationData; import org.apache.fineract.notification.data.NotificationData;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator; import org.springframework.jms.core.MessageCreator;
@@ -36,7 +38,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
}) })
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
public class SenderTest { public class SenderTest {
private final static Logger LOG = LoggerFactory.getLogger(SenderTest.class);
@Autowired @Autowired
private JmsTemplate jmsTemplate; private JmsTemplate jmsTemplate;
@@ -68,7 +70,7 @@ public class SenderTest {
jmsTemplate.send(mockQueue, new MessageCreator() { jmsTemplate.send(mockQueue, new MessageCreator() {
@Override @Override
public Message createMessage(Session session) throws JMSException { public Message createMessage(Session session) throws JMSException {
System.out.println("Message send successfully"); LOG.info("Message send successfully");
return session.createObjectMessage(notificationData); return session.createObjectMessage(notificationData);
} }
}); });