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"/>
</module>
-->
<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="RedundantImport"/>
@@ -84,12 +90,6 @@
<property name="forbiddenImportsExcludesRegexp" value="" />
<message key="forbid.certain.imports" value="Use ''java.nio.charset.StandardCharsets'' instead of ''{0}''" />
</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">
<property name="format" value="\.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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AccountNumberPreferencesTest {
private final static Logger LOG = LoggerFactory.getLogger(AccountNumberPreferencesTest.class);
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
private ResponseSpecification responseValidationError;
@@ -149,10 +152,10 @@ public class AccountNumberPreferencesTest {
Integer id = (Integer) preferenceId.get("id");
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 */
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,
this.responseNotFoundError, "");
@@ -179,23 +182,23 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreference() {
this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference(
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.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.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.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.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.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId,
@@ -208,7 +211,7 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) {
/* 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(
this.responseForbiddenError, accountType, prefixType, "");
@@ -221,7 +224,7 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) {
/* 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(
this.responseValidationError, accountType, prefixType, "");
@@ -241,14 +244,14 @@ public class AccountNumberPreferencesTest {
HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference(
this.clientAccountNumberPreferenceId, "101", this.responseSpec, "");
System.out.println("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID "
+ accountNumberPreferences.get("resourceId"));
LOG.info("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID {}"
, accountNumberPreferences.get("resourceId"));
this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"),
this.responseSpec, this.requestSpec);
/* 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 */
HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101",
@@ -380,20 +383,20 @@ public class AccountNumberPreferencesTest {
private void createLoanProduct() {
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)
.withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear().build(null);
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) {
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)
.withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsMonths().withNumberOfRepayments(numberOfRepayments)
@@ -402,7 +405,7 @@ public class AccountNumberPreferencesTest {
.withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2")
.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);
String loanAccountNo = (String) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanId,
@@ -419,17 +422,17 @@ public class AccountNumberPreferencesTest {
this.loanProductId, "shortName");
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 {
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, null);
System.out.println("SUCCESSFULLY CREATED LOAN APPLICATION (ID: " + loanId + ")");
LOG.info("SUCCESSFULLY CREATED LOAN APPLICATION (ID: {} )",loanId);
}
}
private void createSavingsProduct() {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
@@ -446,7 +449,7 @@ public class AccountNumberPreferencesTest {
.withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance)
.withMinimumOpenningBalance(this.MINIMUM_OPENING_BALANCE).build();
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");
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 {
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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* JUnit Test Cases for Account Transfer for.
@@ -56,6 +58,7 @@ import org.junit.Test;
@SuppressWarnings({ "rawtypes", "unused" })
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 ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
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,
final String minOpenningBalance, final Account... accounts) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
final String savingsProductJSON = savingsProductHelper //
.withInterestCompoundingPeriodTypeAsDaily() //
@@ -454,7 +457,7 @@ public class AccountTransferTest {
}
private Integer createLoanProduct(final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("8,000.00") //
.withNumberOfRepayments("4") //
@@ -470,7 +473,7 @@ public class AccountTransferTest {
}
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("8,000.00") //
.withLoanTermFrequency("4") //
@@ -64,10 +64,12 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
public class AccountingScenarioIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class);
private static RequestSpecification requestSpec;
private static ResponseSpecification responseSpec;
@@ -146,19 +148,19 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES
System.out.println("Entries ......");
LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f;
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.DEBIT), };
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);
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.EXPECTED_DISBURSAL_DATE, incomeJournalEntry);
// MAKE 1
System.out.println("Repayment 1 ......");
LOG.info("Repayment 1 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
final float FIRST_INTEREST = 200.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),
new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
System.out.println("Repayment 1 Done......");
LOG.info("Repayment 1 Done......");
// REPAYMENT 2
System.out.println("Repayment 2 ......");
LOG.info("Repayment 2 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
final float SECOND_AND_THIRD_INTEREST = 400.0f;
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),
new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
System.out.println("Repayment 2 Done ......");
LOG.info("Repayment 2 Done ......");
// 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);
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);
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry);
System.out.println("Waive Interest Done......");
LOG.info("Waive Interest Done......");
// REPAYMENT 3
System.out.println("Repayment 3 ......");
LOG.info("Repayment 3 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
System.out.println("Repayment 3 Done ......");
LOG.info("Repayment 3 Done ......");
// REPAYMENT 4
System.out.println("Repayment 4 ......");
LOG.info("Repayment 4 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
System.out.println("Repayment 4 Done ......");
LOG.info("Repayment 4 Done ......");
// Repayment 5
System.out.println("Repayment 5 ......");
LOG.info("Repayment 5 ......");
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
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) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
@@ -234,7 +236,7 @@ public class AccountingScenarioIntegrationTest {
}
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())
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths().withNumberOfRepayments(this.LP_REPAYMENTS)
.withRepaymentEveryAfter(this.LP_REPAYMENT_PERIOD).withRepaymentFrequencyTypeAsMonths()
@@ -283,7 +285,7 @@ public class AccountingScenarioIntegrationTest {
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsID);
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,
JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liabililityAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT,
@@ -299,7 +301,7 @@ public class AccountingScenarioIntegrationTest {
summary = this.savingsAccountHelper.getSavingsSummary(savingsID);
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,
JournalEntry.TransactionType.CREDIT) };
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) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() //
.withInterestPostingPeriodTypeAsQuarterly() //
.withInterestCalculationPeriodTypeAsDailyBalance() //
@@ -515,7 +517,7 @@ public class AccountingScenarioIntegrationTest {
}
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);
final String fixedDepositProductJSON = fixedDepositProductHelper //
.withPeriodRangeChart()//
@@ -525,7 +527,7 @@ public class AccountingScenarioIntegrationTest {
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom,
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) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper
@@ -533,7 +535,7 @@ public class AccountingScenarioIntegrationTest {
}
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);
final String recurringDepositProductJSON = recurringDepositProductHelper //
.withPeriodRangeChart()//
@@ -543,7 +545,7 @@ public class AccountingScenarioIntegrationTest {
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
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)
//
.withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate)
@@ -577,7 +579,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES
System.out.println("Entries ......");
LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -592,7 +594,7 @@ public class AccountingScenarioIntegrationTest {
}
// MAKE 1
System.out.println("Repayment 1 ......");
LOG.info("Repayment 1 ......");
final float FIRST_INTEREST = 200.0f;
final float FIRST_PRINCIPAL = 2000.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),
new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
System.out.println("Repayment 1 Done......");
LOG.info("Repayment 1 Done......");
// REPAYMENT 2
System.out.println("Repayment 2 ......");
LOG.info("Repayment 2 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
final float SECOND_AND_THIRD_INTEREST = 400.0f;
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),
new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
System.out.println("Repayment 2 Done ......");
LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST
System.out.println("Waive Interest ......");
LOG.info("Waive Interest ......");
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[4]), FIRST_INTEREST,
FEE_PORTION, PENALTY_PORTION, loanID);
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);
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry);
System.out.println("Waive Interest Done......");
LOG.info("Waive Interest Done......");
// REPAYMENT 3
System.out.println("Repayment 3 ......");
LOG.info("Repayment 3 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
System.out.println("Repayment 3 Done ......");
LOG.info("Repayment 3 Done ......");
// REPAYMENT 4
System.out.println("Repayment 4 ......");
LOG.info("Repayment 4 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
System.out.println("Repayment 4 Done ......");
LOG.info("Repayment 4 Done ......");
// Repayment 5
System.out.println("Repayment 5 ......");
LOG.info("Repayment 5 ......");
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry);
System.out.println("Repayment 5 Done ......");
LOG.info("Repayment 5 Done ......");
}
@Test
@@ -694,7 +696,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES
System.out.println("Entries ......");
LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -709,7 +711,7 @@ public class AccountingScenarioIntegrationTest {
}
// MAKE 1
System.out.println("Repayment 1 ......");
LOG.info("Repayment 1 ......");
final float FIRST_INTEREST = 200.0f;
final float FIRST_PRINCIPAL = 2000.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.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f,
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)));
// CHECK ACCOUNT ENTRIES
System.out.println("Entries ......");
LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f;
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)));
// CHECK ACCOUNT ENTRIES
System.out.println("Entries ......");
LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f;
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
@@ -946,7 +948,7 @@ public class AccountingScenarioIntegrationTest {
}
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()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
@@ -979,7 +981,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// CHECK ACCOUNT ENTRIES
System.out.println("Entries ......");
LOG.info("Entries ......");
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
final float TOTAL_INTEREST = 1000.0f;
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);
// MAKE 1
System.out.println("Repayment 1 ......");
LOG.info("Repayment 1 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
final float FIRST_INTEREST = 200.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),
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
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,
JournalEntry.TransactionType.CREDIT));
System.out.println("Repayment 1 Done......");
LOG.info("Repayment 1 Done......");
// REPAYMENT 2
System.out.println("Repayment 2 ......");
LOG.info("Repayment 2 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
final float SECOND_AND_THIRD_INTEREST = 400.0f;
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),
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
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(
SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT));
System.out.println("Repayment 2 Done ......");
LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST
System.out.println("Waive Interest ......");
LOG.info("Waive Interest ......");
Integer transactionId = this.loanTransactionHelper.waiveInterestAndReturnTransactionId(this.REPAYMENT_DATE[4],
this.AMOUNT_TO_BE_WAIVE.toString(), loanID);
// waive of fees and interest are not considered in cash based
@@ -1025,38 +1027,38 @@ public class AccountingScenarioIntegrationTest {
this.journalEntryHelper.ensureNoAccountingTransactionsWithTransactionId("L" + transactionId);
// REPAYMENT 3
System.out.println("Repayment 3 ......");
LOG.info("Repayment 3 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
System.out.println("Repayment 3 Done ......");
LOG.info("Repayment 3 Done ......");
// REPAYMENT 4
System.out.println("Repayment 4 ......");
LOG.info("Repayment 4 ......");
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
System.out.println("Repayment 4 Done ......");
LOG.info("Repayment 4 Done ......");
// Repayment 5
System.out.println("Repayment 5 ......");
LOG.info("Repayment 5 ......");
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
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) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test class for testing the integration of Batch API with custom batch
@@ -46,6 +48,7 @@ import org.junit.Test;
*/
public class BatchRequestsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(BatchRequestsIntegrationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -88,7 +91,7 @@ public class BatchRequestsIntegrationTest {
for (Integer i = 0; i < clientsCount; i++) {
clientIDs[i] = ClientHelper.createClient(this.requestSpec, this.responseSpec);
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
@@ -38,9 +38,11 @@ import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CenterIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(CenterIntegrationTest.class);
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
@@ -198,7 +200,7 @@ public class CenterIntegrationTest {
public void testStaffAssignmentDuringCenterCreation() {
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);
final int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId);
@@ -212,7 +214,7 @@ public class CenterIntegrationTest {
@Test
public void testAssignStaffToCenter() {
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);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
@@ -233,7 +235,7 @@ public class CenterIntegrationTest {
@Test
public void testUnassignStaffToCenter() {
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);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
@@ -56,13 +56,15 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Client Savings Integration Test for checking Savings Application.
*/
@SuppressWarnings({ "rawtypes"})
public class ClientSavingsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ClientSavingsIntegrationTest.class);
public static final String DEPOSIT_AMOUNT = "2000";
public static final String WITHDRAW_AMOUNT = "1000";
public static final String WITHDRAW_AMOUNT_ADJUSTED = "500";
@@ -970,8 +972,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
@@ -1007,8 +1008,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked-------");
LOG.info("-----Post Interest As on Successfully Worked-------");
//DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar transactionCalendarDateFormat = Calendar.getInstance();
@@ -1047,8 +1047,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
}
DateFormat lastTransactionDateFormat = new SimpleDateFormat(
"dd MMMM yyyy", Locale.US);
@@ -1091,8 +1090,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
}
transactionDate.set(Calendar.DAY_OF_MONTH, 1);
@@ -1128,8 +1126,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
}
@@ -1313,8 +1310,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3);
TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
@@ -1350,8 +1346,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked-------");
LOG.info("-----Post Interest As on Successfully Worked-------");
//DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar transactionCalendarDateFormat = Calendar.getInstance();
@@ -1390,8 +1385,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
}
DateFormat lastTransactionDateFormat = new SimpleDateFormat(
"dd MMMM yyyy", Locale.US);
@@ -1434,8 +1428,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
}
transactionDate.set(Calendar.DAY_OF_MONTH, 1);
@@ -1471,8 +1464,7 @@ public class ClientSavingsIntegrationTest {
decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals("Verifying interest posted", interestPosted,
accountDetailsPostInterestPosted);
System.out
.println("-----Post Interest As on Successfully Worked----------");
LOG.info("-----Post Interest As on Successfully Worked----------");
}
@SuppressWarnings("unchecked")
@@ -1619,7 +1611,7 @@ public class ClientSavingsIntegrationTest {
interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
//actualInterestPosted = Float.valueOf(decimalFormat.format(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();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
@@ -1706,7 +1698,7 @@ public class ClientSavingsIntegrationTest {
final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime());
Calendar postedLastDate = Calendar.getInstance();
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);
final String POSTED_LAST_TRANSACTION_DATE = dateFormat.format(postedLastDate.getTime());
@@ -1786,7 +1778,7 @@ public class ClientSavingsIntegrationTest {
interestPosted = Float.valueOf(decimalFormat.format(interestPosted));
actualInterestPosted = Float.valueOf(decimalFormat.format(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);
HashMap accountLastDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
@@ -1806,7 +1798,7 @@ public class ClientSavingsIntegrationTest {
interestLastPosted = Float.valueOf(decimalLastFormat.format(interestLastPosted));
actualInterestPosted = Float.valueOf(decimalFormat.format(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,
final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance,
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();
if (allowOverdraft) {
final String overDraftLimit = "2000.0";
@@ -2104,7 +2096,7 @@ public class ClientSavingsIntegrationTest {
/*
* private void verifySavingsInterest(final Object savingsInterest) {
* System.out.println(
* LOG.info(
* "--------------------VERIFYING THE BALANCE, INTEREST --------------------------"
* );
*
@@ -21,41 +21,49 @@ package org.apache.fineract.integrationtests;
import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ClientStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(ClientStatusChecker.class);
public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) {
assertEquals((int) clientStatusHashMap.get("id"), 300);
}
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);
System.out.println("Client Status:" + clientStatusHashMap + "\n");
LOG.info("Client Status: {} \n", 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);
System.out.println("Client Status:" + clientStatusHashMap + "\n");
LOG.info("Client Status: {} \n", 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);
System.out.println("Client Status:" + clientStatusHashMap + "\n");
LOG.info("Client Status: {} \n", 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);
System.out.println("Client Status:" + clientStatusHashMap + "\n");
LOG.info("Client Status: {} \n", 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);
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.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConcurrencyIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ConcurrencyIntegrationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -73,7 +75,7 @@ public class ConcurrencyIntegrationTest {
date.set(2011, 9, 20);
Float repaymentAmount = 100.0f;
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);
repaymentAmount = repaymentAmount + 100;
Runnable worker = new LoanRepaymentExecutor(loanTransactionHelper, loanID, repaymentAmount, date);
@@ -85,12 +87,12 @@ public class ConcurrencyIntegrationTest {
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) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") //
.withNumberOfRepayments("4") //
@@ -111,7 +113,7 @@ public class ConcurrencyIntegrationTest {
}
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() //
.withPrincipal(principal) //
.withLoanTermFrequency("4") //
@@ -150,13 +152,12 @@ public class ConcurrencyIntegrationTest {
try {
this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId);
} catch (Exception e) {
System.out.println("Found an exception" + e.getMessage());
System.out.println("Details of failed concurrent transaction (date, amount, loanId) are " + repaymentDate + ","
+ repaymentAmount + "," + loanId);
LOG.info("Found an exception {}" , e.getMessage());
LOG.info("Details of failed concurrent transaction (date, amount, loanId) are {},{},{}" , repaymentDate, repaymentAmount , loanId);
throw (e);
}
System.out.println("Details of passed concurrent transaction, details (date, amount, loanId) are " + repaymentDate + ","
+ repaymentAmount + "," + loanId);
LOG.info("Details of passed concurrent transaction, details (date, amount, loanId) are {},{},{}" , repaymentDate
, repaymentAmount , loanId);
}
}
@@ -53,321 +53,362 @@ import org.junit.Test;
@Ignore
public class DisbursalAndRepaymentScheduleTest {
private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403;
private ResponseSpecification generalResponseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
private LoanRescheduleRequestHelper loanRescheduleRequestHelper;
private Integer loanRescheduleRequestId;
private Integer clientId;
private Integer groupId;
private Integer groupCalendarId;
private Integer loanProductId;
private Integer loanId;
private final String loanPrincipalAmount = "100000.00";
private final String numberOfRepayments = "12";
private final String interestRatePerPeriod = "18";
private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403;
private ResponseSpecification generalResponseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
private LoanRescheduleRequestHelper loanRescheduleRequestHelper;
private Integer loanRescheduleRequestId;
private Integer clientId;
private Integer groupId;
private Integer groupCalendarId;
private Integer loanProductId;
private Integer loanId;
private final String loanPrincipalAmount = "100000.00";
private final String numberOfRepayments = "12";
private final String interestRatePerPeriod = "18";
private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy");
private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy");
@Before
public void setup() {
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));
@Before
public void setup() {
Utils.initializeRESTAssured();
}
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
// after group creation
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
final String rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date());
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
final String loanType = "jlg";
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());
final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
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);
final String disbursalDate = groupMeetingDate; // first meeting date
// after group creation
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date());
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);
final String loanType = "jlg";
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.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
Assert.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
// system.out.println("---------------------------------CREATING ENTITIES AND
// 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.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
// Test for loan account approved can be disbursed
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// Test for loan account is created
Assert.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec,
this.loanId);
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
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
ArrayList loanRepaymnetSchedule = this.loanTransactionHelper
.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
// Test for loan account is created, can be approved
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");
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));
// Test for loan account approved can be disbursed
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
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")
.updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate)
.updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString());
ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
generalResponseSpec, this.loanId);
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
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);
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));
// system.out.println("---------------------------------CREATING LOAN RESCHEDULE
// REQUEST------------------------------------------");
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)
.getApproveLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
generalResponseSpec, this.loanId);
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");
assertTrue((Boolean) response.get("approved"));
// system.out.println("Successfully created loan reschedule request (ID: " +
// 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");
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 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 + ")");
requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate)
.getApproveLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId,
requestJSON);
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
}
final HashMap response = (HashMap) this.loanRescheduleRequestHelper
.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean) response.get("approved"));
@Test
public void testChangeGroupMeetingMaturedOnDate() {
System.out
.println("---------------------------------STARTING GROUP LOAN MEETING CHANGE DATE EXPECTED MATURED CHANGE------------------------------------------");
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
generalResponseSpec, this.loanId);
Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
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 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);
// 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));
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec,
this.responseSpecForStatusCode403);
}
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
// after group creation
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
final String loanType = "jlg";
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.
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
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);
final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String disbursalDate = groupMeetingDate; // first meeting date
// after group creation
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);
final String loanType = "jlg";
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.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
Assert.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
// system.out.println("---------------------------------CREATING ENTITIES AND
// 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.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
// Test for loan account approved can be disbursed
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// Test for loan account is created
Assert.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec,
this.loanId);
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
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
Calendar expectedMaturityCalendar = Calendar.getInstance();
expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY);
ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec,
this.loanId, "timeline")).get("expectedMaturityDate"));
// Test for loan account is created, can be approved
this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), (Integer) expectedMaturityDate.get(1) - 1,
(Integer) expectedMaturityDate.get(2));
// Test for loan account approved can be disbursed
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,
expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK));
// 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
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"));
/**
* entities for jlg loan
**/
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();
expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0),
(Integer) expectedMaturityDate.get(1) - 1, (Integer) expectedMaturityDate.get(2));
}
assertEquals("AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY", 3,
expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK));
/*
* Associate client to the group
*/
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec,
this.responseSpecForStatusCode403);
}
private void associateClientToGroup(final Integer groupId, final Integer clientId) {
GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString());
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId);
}
/**
* entities for jlg loan
**/
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,
frequency, interval, repeatsOnDay));
}
private void associateClientToGroup(final Integer groupId, final Integer clientId) {
GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(),
clientId.toString());
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId);
}
/**
* create a new client
**/
private void createClientEntity() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId);
}
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);
/**
* 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);
}
final String startDate = groupActivationDate;
public void setGroupCalendarId(Integer groupCalendarId) {
this.groupCalendarId = groupCalendarId;
}
this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec,
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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
public class ExternalServicesConfigurationTest {
private final static Logger LOG = LoggerFactory.getLogger(ExternalServicesConfigurationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private ExternalServicesConfigurationHelper externalServicesConfigurationHelper;
@@ -67,7 +69,7 @@ public class ExternalServicesConfigurationTest {
value = "testnull";
}
String newValue = "test";
System.out.println(name + ":" + value);
LOG.info( "{} : {}",name, value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "S3", name, newValue);
Assert.assertNotNull(arrayListValue.get("value"));
@@ -95,7 +97,7 @@ public class ExternalServicesConfigurationTest {
value = "testnull";
}
String newValue = "test";
System.out.println(name + ":" + value);
LOG.info("{} : {}",name,value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "SMTP", name, newValue);
Assert.assertNotNull(arrayListValue.get("value"));
@@ -63,10 +63,12 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" })
public class FixedDepositTest {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private FixedDepositProductHelper fixedDepositProductHelper;
@@ -1224,7 +1226,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE);
@@ -1236,7 +1238,7 @@ public class FixedDepositTest {
decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal));
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);
}
@@ -1298,7 +1300,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE);
@@ -1309,7 +1311,7 @@ public class FixedDepositTest {
decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal));
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);
}
@@ -1376,7 +1378,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1);
@@ -1387,12 +1389,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE);
@@ -1484,7 +1486,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}", perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1);
@@ -1495,12 +1497,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE);
@@ -1597,7 +1599,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1);
@@ -1608,12 +1610,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE);
@@ -1713,7 +1715,7 @@ public class FixedDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.add(Calendar.MONTH, -1);
@@ -1724,12 +1726,12 @@ public class FixedDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
LOG.info("{}",monthDayFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId,
CLOSED_ON_DATE);
@@ -1812,7 +1814,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE);
@@ -1824,7 +1826,7 @@ public class FixedDepositTest {
decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal));
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);
}
@@ -1853,7 +1855,7 @@ public class FixedDepositTest {
dateFormat.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);
Assert.assertNotNull(clientId);
@@ -1889,7 +1891,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
todaysDate.getActualMaximum(Calendar.DATE);
@@ -1899,7 +1901,7 @@ public class FixedDepositTest {
principal = new BigDecimal(principal).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);
}
@@ -1925,7 +1927,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -1971,7 +1973,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2009,7 +2011,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2055,7 +2057,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2094,7 +2096,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2137,7 +2139,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2176,7 +2178,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2219,7 +2221,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" ,perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2258,7 +2260,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2301,7 +2303,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
@@ -2339,7 +2341,7 @@ public class FixedDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2382,7 +2384,7 @@ public class FixedDepositTest {
Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
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,
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);
if (accountingRule.equals(CASH_BASED)) {
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -2415,7 +2417,7 @@ public class FixedDepositTest {
private Integer createFixedDepositProductWithWithHoldTax(final String validFrom, final String validTo, final String taxGroupId,
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);
if (accountingRule.equals(CASH_BASED)) {
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -2430,7 +2432,7 @@ public class FixedDepositTest {
private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule,
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);
if (accountingRule.equals(CASH_BASED)) {
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -2461,7 +2463,7 @@ public class FixedDepositTest {
private Integer applyForFixedDepositApplication(final String clientID, final String productID, 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) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper
@@ -2470,7 +2472,7 @@ public class FixedDepositTest {
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate,
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)
//
.withSubmittedOnDate(submittedOnDate).withDepositPeriod(depositPeriod).withDepositAmount(depositAmount)
@@ -2481,7 +2483,7 @@ public class FixedDepositTest {
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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();
if (accountingRule.equals(CASH_BASED)) {
@@ -39,10 +39,12 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
public class FlexibleSavingsInterestPostingIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class);
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
private ResponseSpecification responseSpec;
@@ -84,7 +86,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
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
// balance
// 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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Group Test for checking Group: Creation, Activation, Client Association,
* Updating & Deletion
*/
public class GroupTest {
private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -107,11 +109,11 @@ public class GroupTest {
// create staff
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);
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);
// assign staff "createStaffId1" to group
@@ -155,7 +157,7 @@ public class GroupTest {
}
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() //
.withPrincipal(principal) //
.withLoanTermFrequency("4") //
@@ -36,9 +36,11 @@ import org.apache.http.conn.HttpHostConnectException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HookIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(HookIntegrationTest.class);
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
@@ -77,7 +79,7 @@ public class HookIntegrationTest {
final Integer notificationOfficeId = JsonPath.with(json).get("officeId");
Assert.assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID,
notificationOfficeId);
System.out.println("Notification Office Id - " + notificationOfficeId);
LOG.info("Notification Office Id - {}" , notificationOfficeId);
i = 6;
} catch (Exception e) {
TimeUnit.SECONDS.sleep(3);
@@ -102,13 +104,13 @@ public class HookIntegrationTest {
Long hookId = this.hookHelper.createHook(payloadURL).longValue();
Assert.assertNotNull(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.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.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.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanApplicationApprovalTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class);
private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403;
private ResponseSpecification responseSpecForStatusCode400;
@@ -128,14 +130,14 @@ public class LoanApplicationApprovalTest {
createTranches.add(createTrancheDetail("23 March 2014", "4000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID);
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
@@ -153,19 +155,18 @@ public class LoanApplicationApprovalTest {
approveTranches.add(createTrancheDetail("23 March 2014", "1000"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ loanID);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out
.println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
LOG.info("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
}
@@ -200,13 +201,13 @@ public class LoanApplicationApprovalTest {
approveTranche4.add(createTrancheDetail("24 March 2014", "100"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ loanID);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
, loanID);
HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode400);
/* Tranches with same expected disbursement date */
@@ -256,7 +257,7 @@ public class LoanApplicationApprovalTest {
public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal,
List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
.withPrincipal(principal)
@@ -35,10 +35,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanApplicationUndoLastTrancheTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -65,15 +67,15 @@ public class LoanApplicationUndoLastTrancheTest {
// CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID);
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
, clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
// CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>();
@@ -87,14 +89,14 @@ public class LoanApplicationUndoLastTrancheTest {
// APPLY FOR LOAN WITH TRANCHES
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ loanID);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches);
@@ -109,11 +111,11 @@ public class LoanApplicationUndoLastTrancheTest {
// VALIDATE THE LOAN IS ACTIVE STATUS
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
System.out.println("-------------Make repayment 1-----------");
LOG.info("-------------Make repayment 1-----------");
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);
System.out.println("-------------Make repayment 3-----------");
LOG.info("-------------Make repayment 3-----------");
this.loanTransactionHelper.makeRepayment("01 June 2014", Float.valueOf("204"), loanID);
// DISBURSE A SECOND TRANCHE
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,
List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
.withPrincipal(principal)
@@ -35,10 +35,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanDisbursalDateValidationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -63,25 +65,25 @@ public class LoanDisbursalDateValidationTest {
// CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID);
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
, clientID);
// CREATE LOAN PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withSyncExpectedWithDisbursementDate(true).build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
// APPLY FOR LOAN
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ loanID);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(approveDate, loanID);
// 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.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class LoanDisbursementDetailsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursementDetailsIntegrationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -73,21 +75,20 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID);
LOG.info("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------{}"
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
installmentAmount);
System.out
.println("-----------------------------------LOAN CREATED WITH EMI LOANID-------------------------------------------------"
+ loanIDWithEmi);
LOG.info("-----------------------------------LOAN CREATED WITH EMI LOANID------------------------------------------------- {}"
, loanIDWithEmi);
HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec,
loanIDWithEmi, "repaymentSchedule");
@@ -100,13 +101,12 @@ public class LoanDisbursementDetailsIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithEmi);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000", loanIDWithEmi,
createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out
.println("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
withoutInstallmentAmount);
@@ -117,9 +117,8 @@ public class LoanDisbursementDetailsIntegrationTest {
ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods");
assertEquals(periods1.size(), 15);
System.out
.println("-----------------------------------LOAN CREATED WITHOUT EMI LOANID-------------------------------------------------"
+ loanIDWithoutEmi);
LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}"
, loanIDWithoutEmi);
/* To be uncommented once issue MIFOSX-2006 is closed. */
// this.validateRepaymentScheduleWithoutEMI(periods1);
@@ -127,13 +126,12 @@ public class LoanDisbursementDetailsIntegrationTest {
HashMap loanStatusMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithoutEmi);
LoanStatusChecker.verifyLoanIsPending(loanStatusMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000",
loanIDWithoutEmi, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out
.println("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
}
@@ -209,7 +207,7 @@ public class LoanDisbursementDetailsIntegrationTest {
assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate());
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
.getTotalOriginalDueForPeriod().floatValue(), 0.0f);
@@ -342,7 +340,7 @@ public class LoanDisbursementDetailsIntegrationTest {
private Integer applyForLoanApplicationWithEmiAmount(final Integer clientID, final Integer loanProductID, final String proposedAmount,
List<HashMap> tranches, final String installmentAmount) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
.withPrincipal(proposedAmount)
@@ -373,29 +371,28 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID);
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ loanID);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out
.println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
LOG.info("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper.getLoanDetail(this.requestSpec,
this.responseSpec, this.loanID, "disbursementDetails");
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,
List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
.withPrincipal(principal)
@@ -40,10 +40,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker;
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanRepaymentRescheduleAtDisbursementTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -73,8 +75,8 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
// CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID);
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}"
, clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION
final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY,
@@ -102,7 +104,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
// VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches);
@@ -167,7 +169,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
boolean isArrearsBasedOnOriginalSchedule, final Integer recalculationCompoundingFrequencyOnDayType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder()
.withPrincipal("10000.00")
.withNumberOfRepayments("12")
@@ -207,7 +209,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID,
final String disbursementDate, final String repaymentStrategy, final List<HashMap> charges, final String graceOnInterestPayment,
final String graceOnPrincipalPayment, List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000.00") //
.withLoanTermFrequency("24") //
@@ -36,12 +36,15 @@ import org.apache.fineract.integrationtests.common.loans.LoanRescheduleRequestTe
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test the creation, approval and rejection of a loan reschedule request
**/
@SuppressWarnings({ "rawtypes" })
public class LoanRescheduleRequestTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class);
private ResponseSpecification responseSpec;
private ResponseSpecification generalResponseSpec;
private RequestSpecification requestSpec;
@@ -93,7 +96,7 @@ public class LoanRescheduleRequestTest {
* create a new loan product
**/
private void createLoanProductEntity() {
System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder()
.withPrincipal(loanPrincipalAmount)
@@ -103,14 +106,14 @@ public class LoanRescheduleRequestTest {
.build(null);
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
**/
private void createLoanEntity() {
System.out.println("---------------------------------NEW LOAN APPLICATION------------------------------------------");
LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
.withPrincipal(loanPrincipalAmount)
@@ -131,7 +134,7 @@ public class LoanRescheduleRequestTest {
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.disburseLoan();
@@ -144,7 +147,7 @@ public class LoanRescheduleRequestTest {
if(this.loanId != null) {
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) {
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
**/
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());
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
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
@@ -182,7 +185,7 @@ public class LoanRescheduleRequestTest {
public void testRejectLoanRescheduleRequest() {
this.createLoanRescheduleRequest();
System.out.println("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------");
LOG.info("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------");
final String requestJSON = new LoanRescheduleRequestTestBuilder().getRejectLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
@@ -190,14 +193,14 @@ public class LoanRescheduleRequestTest {
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
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
public void testApproveLoanRescheduleRequest() {
this.createLoanRescheduleRequest();
System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------");
LOG.info("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------");
final String requestJSON = new LoanRescheduleRequestTestBuilder().getApproveLoanRescheduleRequestJSON();
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("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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoanReschedulingWithinCenterTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class);
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -133,7 +135,7 @@ public class LoanReschedulingWithinCenterTest {
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------");
LOG.info("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------");
Calendar todaysdate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
todaysdate.add(Calendar.DAY_OF_MONTH, 14);
String oldMeetingDate = dateFormat.format(todaysdate.getTime());
@@ -181,7 +183,7 @@ public class LoanReschedulingWithinCenterTest {
Integer calendarId = CalendarHelper.createMeetingForGroup(this.requestSpec, this.responseSpec, centerId, startDate, frequency,
interval, repeatsOnDay.toString());
System.out.println("calendarId " + calendarId);
LOG.info("calendarId {}" , calendarId);
return calendarId;
}
@@ -253,7 +255,7 @@ public class LoanReschedulingWithinCenterTest {
// VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches);
@@ -265,7 +267,7 @@ public class LoanReschedulingWithinCenterTest {
this.loanTransactionHelper.disburseLoan(disbursementDate, 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());
todaysdate.add(Calendar.DAY_OF_MONTH, 14);
String oldMeetingDate = dateFormat.format(todaysdate.getTime());
@@ -312,7 +314,7 @@ public class LoanReschedulingWithinCenterTest {
final Integer recalculationCompoundingFrequencyOnDayType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder()
.withPrincipal("10000.00")
.withNumberOfRepayments("12")
@@ -359,7 +361,7 @@ public class LoanReschedulingWithinCenterTest {
final Integer loanProductID, final String disbursementDate, final String restStartDate, final String compoundingStartDate,
final String repaymentStrategy, final List<HashMap> charges, final String graceOnInterestPayment,
final String graceOnPrincipalPayment, List<HashMap> tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000.00") //
.withLoanTermFrequency("24") //
@@ -33,6 +33,8 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Client Loan Integration Test for checking Loan Disbursement with Waive
@@ -40,7 +42,7 @@ import org.junit.Test;
*/
@SuppressWarnings({ "rawtypes" })
public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -74,7 +76,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -83,14 +85,14 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------RE-APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------RE-APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("1 October 2010", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
// DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
System.out.println("DISBURSE " + loanStatusHashMap);
LOG.info("DISBURSE {}" , loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// PERFORM REPAYMENTS AND CHECK LOAN STATUS
@@ -103,7 +105,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DIBURSE AGAIN
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
System.out.println("DISBURSE " + loanStatusHashMap);
LOG.info("DISBURSE {}" , loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS
@@ -142,14 +144,14 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
// DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
System.out.println("DISBURSE " + loanStatusHashMap);
LOG.info("DISBURSE {}" , loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS
@@ -179,7 +181,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
}
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()
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
@@ -189,7 +191,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
}
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)
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths()
.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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NotificationApiTest {
private final static Logger LOG = LoggerFactory.getLogger(NotificationApiTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -48,7 +50,7 @@ public class NotificationApiTest {
public void testNotificationRetrieval() {
HashMap<String, Object> response = (HashMap<String, Object>) NotificationHelper.getNotifications(this.requestSpec,
this.responseSpec, "");
System.out.println("Response : " + response.toString());
LOG.info("Response : {}" , response.toString());
Assert.assertNotNull(response);
}
}
@@ -32,10 +32,12 @@ import org.apache.fineract.integrationtests.common.PasswordPreferencesHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class PasswordPreferencesIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(PasswordPreferencesIntegrationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private ResponseSpecification generalResponseSpec;
@@ -60,7 +62,7 @@ public class PasswordPreferencesIntegrationTest {
private void validateIfThePasswordIsUpdated(String validationPolicyId){
Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec);
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.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
public class RecurringDepositTest {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private RecurringDepositProductHelper recurringDepositProductHelper;
@@ -1420,7 +1422,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -1432,7 +1434,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal));
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);
}
@@ -1505,7 +1507,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -1517,7 +1519,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal));
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);
}
@@ -1588,7 +1590,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
@@ -1601,7 +1603,7 @@ public class RecurringDepositTest {
principal += interestToBePosted;
Float expectedBalanceAfter = Float.valueOf(decimalFormat.format(principal));
System.out.println(expectedBalanceAfter);
LOG.info("{}",expectedBalanceAfter.toString());
Integer transactionIdForPostInterest = this.recurringDepositAccountHelper
.postInterestForRecurringDeposit(recurringDepositAccountId);
@@ -1696,7 +1698,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance();
@@ -1707,7 +1709,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount;
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());
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -1716,9 +1718,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE);
@@ -1828,7 +1830,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance();
@@ -1839,7 +1841,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount;
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());
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -1848,9 +1850,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE);
@@ -1967,7 +1969,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance();
@@ -1979,7 +1981,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount;
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());
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -1988,9 +1990,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE);
@@ -2112,7 +2114,7 @@ public class RecurringDepositTest {
interestRate -= preClosurePenalInterestRate;
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Calendar calendar = Calendar.getInstance();
@@ -2124,7 +2126,7 @@ public class RecurringDepositTest {
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
principal += interestPerMonth + depositAmount;
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());
Integer newTransactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
@@ -2133,9 +2135,9 @@ public class RecurringDepositTest {
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
LOG.info("IPM = {}" , interestPerMonth);
principal += interestPerMonth;
System.out.println("principal = " + principal);
LOG.info("principal = {}" , principal);
HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit(
recurringDepositAccountId, CLOSED_ON_DATE);
@@ -2227,7 +2229,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -2239,7 +2241,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal));
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);
}
@@ -2312,7 +2314,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
@@ -2324,7 +2326,7 @@ public class RecurringDepositTest {
decimalFormat.applyPattern(".");
principal = Float.valueOf(decimalFormat.format(principal));
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);
}
@@ -2355,7 +2357,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2403,7 +2405,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {}" , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2446,7 +2448,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2494,7 +2496,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2536,7 +2538,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2585,7 +2587,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2627,7 +2629,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2676,7 +2678,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2719,7 +2721,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2767,7 +2769,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay;
principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
@@ -2810,7 +2812,7 @@ public class RecurringDepositTest {
Integer daysLeft = daysInMonth - currentDate;
todaysDate.add(Calendar.DATE, (daysLeft + 1));
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_TO = null;
@@ -2858,7 +2860,7 @@ public class RecurringDepositTest {
Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod);
double interestRateInFraction = (interestRate / 100);
double perDay = (double) 1 / (daysInYear);
System.out.println("per day = " + perDay);
LOG.info("per day = {} " , perDay);
double interestPerDay = interestRateInFraction * perDay;
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,
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);
if (accountingRule.equals(CASH_BASED)) {
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,
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);
if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -3068,7 +3070,7 @@ public class RecurringDepositTest {
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule,
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);
if (accountingRule.equals(CASH_BASED)) {
recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -3098,7 +3100,7 @@ public class RecurringDepositTest {
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
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)
.withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate)
.build(clientID, productID, penalInterestType);
@@ -3109,7 +3111,7 @@ public class RecurringDepositTest {
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 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)
.withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate)
.withDepositPeriod(depositPeriod).withMandatoryDepositAmount(depositAmount).build(clientID, productID, penalInterestType);
@@ -3119,7 +3121,7 @@ public class RecurringDepositTest {
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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();
if (accountingRule.equals(CASH_BASED)) {
savingsProductHelper = savingsProductHelper.withAccountingRuleAsCashBased(accounts);
@@ -34,9 +34,11 @@ import org.apache.fineract.integrationtests.useradministration.users.UserHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RolesTest {
private final static Logger LOG = LoggerFactory.getLogger(RolesTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -52,11 +54,11 @@ public class RolesTest {
@Test
public void testCreateRolesStatus() {
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------");
LOG.info("---------------------------------CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------");
LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId);
@@ -66,15 +68,15 @@ public class RolesTest {
@Test
public void testDisableRolesStatus() {
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------");
LOG.info("---------------------------------CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------");
LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, 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);
assertEquals(disableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
@@ -87,22 +89,22 @@ public class RolesTest {
@Test
public void testEnableRolesStatus() {
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------");
LOG.info("---------------------------------CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------");
LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, 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);
assertEquals(disableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId);
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);
assertEquals(enableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
@@ -115,15 +117,15 @@ public class RolesTest {
@Test
public void testDeleteRoleStatus() {
System.out.println("-------------------------------- CREATING A ROLE---------------------------------------------");
LOG.info("-------------------------------- CREATING A ROLE---------------------------------------------");
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
Assert.assertNotNull(roleId);
System.out.println("--------------------------------- Getting ROLE -------------------------------");
LOG.info("--------------------------------- Getting ROLE -------------------------------");
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, 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);
assertEquals(deleteRoleId, roleId);
}
@@ -51,10 +51,13 @@ public class SchedulerJobsTest {
@Test // FINERACT-926
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.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);
}
@@ -77,7 +80,8 @@ public class SchedulerJobsTest {
@Test
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);
// For each retrieved scheduled job (by ID)...
@@ -119,13 +123,13 @@ public class SchedulerJobsTest {
Thread.sleep(500);
schedulerJob = schedulerJobHelper.getSchedulerJobById(jobId);
assertNotNull(schedulerJob);
System.out.println("Job " + jobId +" is Still Running");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
List<Map> jobHistoryData = schedulerJobHelper.getSchedulerJobHistory(jobId);
// 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",
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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" })
public class SkipRepaymentOnMonthFirstTest {
private final static Logger LOG = LoggerFactory.getLogger(SkipRepaymentOnMonthFirstTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private GlobalConfigurationHelper globalConfigurationHelper;
@@ -102,10 +104,10 @@ public class SkipRepaymentOnMonthFirstTest {
final String interval = "1"; //Every One Moth
Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency,
interval, null);
System.out.println("caladerId --------------------" + calendarID);
LOG.info("caladerId -------------------- {}" , calendarID);
final Integer loanProductID = createLoanProduct();
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,
this.responseSpec, loanID);
verifyLoanRepaymentSchedule(loanSchedule);
@@ -113,7 +115,7 @@ public class SkipRepaymentOnMonthFirstTest {
}
private Integer createLoanProduct() {
System.out.println(
LOG.info(
"------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") //
@@ -130,7 +132,7 @@ public class SkipRepaymentOnMonthFirstTest {
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID,
Integer clientID) {
System.out.println(
LOG.info(
"--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("12,000.00") //
@@ -147,27 +149,27 @@ public class SkipRepaymentOnMonthFirstTest {
.withCalendarID(calendarID.toString()) //
.withSubmittedOnDate("01 October 2011") //
.withLoanType("jlg").build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
System.out.println(loanApplicationJSON);
LOG.info(loanApplicationJSON);
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
}
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)),
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)),
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)),
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)),
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.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UserAdministrationTest {
private final static Logger LOG = LoggerFactory.getLogger(UserAdministrationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
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");
Map reason = (Map) errors.get(0);
System.out.println("Reason: " + reason.get("defaultUserMessage"));
System.out.println("Code: " + reason.get("userMessageGlobalisationCode"));
LOG.info("Reason: {}" , reason.get("defaultUserMessage"));
LOG.info("Code: {}" , reason.get("userMessageGlobalisationCode"));
Assert.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage"));
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.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class XBRLIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(XBRLIntegrationTest.class);
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
@@ -57,7 +59,7 @@ public class XBRLIntegrationTest {
}
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"));
}
@@ -28,6 +28,8 @@ import java.util.Map;
import org.apache.fineract.batch.domain.BatchRequest;
import org.apache.fineract.batch.domain.BatchResponse;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It
@@ -39,7 +41,7 @@ import org.junit.Assert;
* @see org.apache.fineract.integrationtests.BatchApiTest
*/
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_EXT = BATCH_API_URL + "&enclosingTransaction=true";
@@ -422,7 +424,7 @@ public class BatchHelper {
*/
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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 Integer responseRecords = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "totalFilteredRecords");
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.ResponseSpecification;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 PARENT_ENTITY_NAME = "groups/";
private static final String ENITY_NAME = "/calendars";
@@ -37,11 +39,11 @@ public class CalendarHelper {
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) {
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;
System.out.println(CALENDAR_RESOURCE_URL);
LOG.info("{}",CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
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 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;
System.out.println(CALENDAR_RESOURCE_URL);
LOG.info("{}",CALENDAR_RESOURCE_URL);
// TODO: check that resource id indeed exists in calendar update put.
return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -74,13 +76,13 @@ public class CalendarHelper {
map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4));
map.put("typeId", "1");
map.put("startDate", startDate);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
public static void verifyCalendarCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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 responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL,
"collectionMeetingCalendar");
@@ -91,11 +93,11 @@ public class CalendarHelper {
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) {
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;
System.out.println(CALENDAR_RESOURCE_URL);
LOG.info("{}",CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -104,12 +106,12 @@ public class CalendarHelper {
public static Integer updateMeetingCalendarForCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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 + "?"
+ 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),
"resourceId");
@@ -123,7 +125,7 @@ public class CalendarHelper {
map.put("newMeetingDate", startDate);
map.put("presentMeetingDate", oldDate);
map.put("reschedulebasedOnMeetingDates", "true");
System.out.println("map : " + map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
}
@@ -22,9 +22,11 @@ import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CenterDomain implements Comparable<CenterDomain> {
private final static Logger LOG = LoggerFactory.getLogger(CenterDomain.class);
public static class Builder {
private Integer id;
@@ -147,7 +149,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
}
if (externalId != null) map.put("externalId", externalId);
if (groupMembers != null) map.put("groupMembers", groupMembers);
System.out.println(map);
LOG.info("{}",map.toString());
return new Gson().toJson(map);
}
@@ -27,10 +27,12 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class CenterHelper {
private final static Logger LOG = LoggerFactory.getLogger(CenterHelper.class);
private static final String CENTERS_URL = "/fineract-provider/api/v1/centers";
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) {
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, "");
final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<CenterDomain>() {}.getType());
@@ -47,7 +49,7 @@ public class CenterHelper {
public static ArrayList<CenterDomain> paginatedListCenters(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
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");
final String jsonData = new Gson().toJson(get);
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) {
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, "");
final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CenterDomain>>() {}.getType());
@@ -101,14 +103,14 @@ public class CenterHelper {
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");
}
public static HashMap<String, String> updateCenter(final int id, HashMap request, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
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),
"changes");
return hash;
@@ -119,10 +121,10 @@ public class CenterHelper {
final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&" + Utils.TENANT_IDENTIFIER;
HashMap groupMemberHashMap = new HashMap();
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,
new Gson().toJson(groupMemberHashMap), "changes");
System.out.println(hash);
LOG.info("{}",hash.toString());
ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers");
int[] ret = new int[arr.size()];
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) {
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, "");
}
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@SuppressWarnings("unused") final boolean active) {
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------");
LOG.info("---------------------------------CREATING A CENTER---------------------------------------------");
return createCenter(requestSpec, responseSpec, "CREATED_DATE");
}
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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");
}
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),
"groupId");
}
public static int createCenterWithStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer staffId) {
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------");
LOG.info("---------------------------------CREATING A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL,
getTestCenterWithStaffAsJSON(true, CenterHelper.CREATED_DATE, staffId), "groupId");
}
public static void verifyCenterCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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 Integer responseCenterID = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "id");
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,
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 Boolean responseCenterStatus = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "active");
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,
final String centerId) {
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");
}
@@ -226,14 +228,14 @@ public class CenterHelper {
public static String assignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
public static String unassignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
@@ -245,9 +247,9 @@ public class CenterHelper {
map.put("activationDate", activationDate);
} else {
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);
}
@@ -259,7 +261,7 @@ public class CenterHelper {
final String groupId, final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
System.out.println("---------------------------------Assign Staff---------------------------------------------");
LOG.info("---------------------------------Assign Staff---------------------------------------------");
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 GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=unassignStaff";
System.out.println("---------------------------------Unassign Staff---------------------------------------------");
LOG.info("---------------------------------Unassign Staff---------------------------------------------");
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.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ClientHelper {
private final static Logger LOG = LoggerFactory.getLogger(ClientHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -67,7 +69,8 @@ public class ClientHelper {
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");
}
@@ -78,100 +81,110 @@ public class ClientHelper {
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) {
System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(activationDate, officeId),
"clientId");
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
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");
}
public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String submittedOnDate) {
public static Integer createClientPending(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String submittedOnDate) {
return createClientPending(requestSpec, responseSpec, submittedOnDate, "1");
}
public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String submittedOnDate, final String officeId) {
System.out.println("---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSONPending(submittedOnDate, officeId),
"clientId");
public static Integer createClientPending(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String submittedOnDate, final String officeId) {
LOG.info(
"---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestClientAsJSONPending(submittedOnDate, officeId), "clientId");
}
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,
getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack);
}
public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec,
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,
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");
}
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate) {
public static Integer createClientAsPerson(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String activationDate) {
return createClientAsPerson(requestSpec, responseSpec, activationDate, "1");
}
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) {
public static Integer createClientAsPerson(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String activationDate, final String officeId) {
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId),
"clientId");
LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
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");
}
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate) {
public static Integer createClientAsEntity(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String activationDate) {
return createClientAsEntity(requestSpec, responseSpec, activationDate, "1");
}
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) {
public static Integer createClientAsEntity(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String activationDate, final String officeId) {
Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution")
.get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper
.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId),
"clientId");
LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "clientId");
}
public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer clientType, String jsonAttributeToGetBack) {
public static Integer createClientForAccountPreference(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer clientType, String jsonAttributeToGetBack) {
final String activationDate = "04 March 2011";
final String officeId = "1";
System.out.println(
LOG.info(
"---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------");
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,
final String clientId, final String staffId) {
final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
public static Object assignStaffToClient(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String clientId, final String staffId) {
final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?"
+ Utils.TENANT_IDENTIFIER + "&command=assignStaff";
System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes");
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL,
assignStaffToClientAsJson(staffId), "changes");
}
public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId) {
public static Integer getClientsStaffId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String clientId) {
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
}
@@ -185,7 +198,7 @@ public class ClientHelper {
map.put("locale", "en");
map.put("active", "true");
map.put("activationDate", dateOfJoining);
System.out.println("map : " + map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -199,7 +212,7 @@ public class ClientHelper {
map.put("locale", "en");
map.put("active", "false");
map.put("submittedOnDate", submittedOnDate);
System.out.println("map : " + map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -214,7 +227,7 @@ public class ClientHelper {
map.put("active", "false");
map.put("submittedOnDate", "04 March 2014");
String requestJson = getTestDatatableAsJson(map, registeredTableName);
System.out.println("map : " + requestJson);
LOG.info("map : {}", requestJson);
return requestJson;
}
@@ -246,11 +259,12 @@ public class ClientHelper {
map.put("activationDate", dateOfJoining);
map.put("legalFormId", 1);
System.out.println("map : " + map);
LOG.info("map : {}", 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<>();
map.put("officeId", officeId);
map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
@@ -265,11 +279,12 @@ public class ClientHelper {
clientNonPersonMap.put("constitutionId", soleProprietorCodeValueId);
map.put("clientNonPersonDetails", clientNonPersonMap);
System.out.println("map : " + map);
LOG.info("map : {}", 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<>();
map.put("officeId", officeId);
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
@@ -280,37 +295,38 @@ public class ClientHelper {
map.put("active", "true");
map.put("activationDate", dateOfJoining);
map.put("clientTypeId", clientType);
System.out.println("map : " + map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
public static String assignStaffToClientAsJson(final String staffId) {
final HashMap<String, String> map = new HashMap<>();
map.put("staffId", staffId);
System.out.println("map : " + map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedClientID) {
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer generatedClientID) {
LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?"
+ Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
}
public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId,
final String jsonReturn) {
public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId, final String jsonReturn) {
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);
}
/* Client status is a map.So adding SuppressWarnings */
@SuppressWarnings("unchecked")
public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId) {
public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String clientId) {
return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status");
}
@@ -327,7 +343,8 @@ public class ClientHelper {
Integer clientClosureCodeId = (Integer) code.get("id");
/* 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");
map.put("closureReasonId", closureReasonId.toString());
@@ -336,7 +353,7 @@ public class ClientHelper {
map.put("closureDate", CREATED_DATE_PLUS_ONE);
String clientJson = new Gson().toJson(map);
System.out.println(clientJson);
LOG.info(clientJson);
return clientJson;
}
@@ -347,7 +364,7 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("reactivationDate", CREATED_DATE_PLUS_ONE);
String clientJson = new Gson().toJson(map);
System.out.println(clientJson);
LOG.info(clientJson);
return clientJson;
}
@@ -358,7 +375,7 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("reopenedDate", date);
String clientJson = new Gson().toJson(map);
System.out.println(clientJson);
LOG.info(clientJson);
return clientJson;
}
@@ -369,7 +386,7 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("reopenedDate", date);
String clientJson = new Gson().toJson(map);
System.out.println(clientJson);
LOG.info(clientJson);
return clientJson;
}
@@ -391,7 +408,7 @@ public class ClientHelper {
map.put("rejectionDate", CREATED_DATE_PLUS_ONE);
map.put("rejectionReasonId", rejectionReasonId.toString());
String clientJson = new Gson().toJson(map);
System.out.println(clientJson);
LOG.info(clientJson);
return clientJson;
}
@@ -402,12 +419,10 @@ public class ClientHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("activationDate", date);
String clientJson = new Gson().toJson(map);
System.out.println(clientJson);
LOG.info(clientJson);
return clientJson;
}
private String getWithdrawClientAsJSON() {
final HashMap<String, String> map = new HashMap<>();
/* Retrieve Code id for the Code "ClientWithdrawReason" */
@@ -416,8 +431,8 @@ public class ClientHelper {
Integer clientWithdrawReasonCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, this.requestSpec,
this.responseSpec);
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId,
this.requestSpec, this.responseSpec);
Integer withdrawalReasonId = (Integer) codeValue.get("id");
map.put("locale", CommonConstants.locale);
@@ -425,7 +440,7 @@ public class ClientHelper {
map.put("withdrawalDate", CREATED_DATE_PLUS_ONE);
map.put("withdrawalReasonId", withdrawalReasonId.toString());
String clientJson = new Gson().toJson(map);
System.out.println(clientJson);
LOG.info(clientJson);
return clientJson;
}
@@ -448,7 +463,7 @@ public class ClientHelper {
map.put("transactionDate", date);
map.put("amount", amount);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -458,33 +473,38 @@ public class ClientHelper {
map.put("amount", amount);
map.put("clientChargeId", clientChargeId);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
public HashMap<String, Object> closeClient(final Integer clientId) {
System.out.println("--------------------------------- CLOSE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
LOG.info("--------------------------------- CLOSE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(),
clientId);
}
public HashMap<String, Object> reactivateClient(final Integer clientId) {
System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId),
getReactivateClientAsJSON(), clientId);
}
public HashMap<String, Object> rejectClient(final Integer clientId) {
System.out.println("--------------------------------- REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
LOG.info("--------------------------------- REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(),
clientId);
}
public HashMap<String, Object> activateClient(final Integer clientId) {
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), clientId);
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), clientId);
}
public HashMap<String, Object> withdrawClient(final Integer clientId) {
System.out.println("--------------------------------- WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId),
getWithdrawClientAsJSON(), 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) {
System.out.println("--------------------------------- UNDO REJECT CLIENT -------------------------------");
LOG.info("--------------------------------- UNDO REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId),
getUndoRejectClientAsJSON(CREATED_DATE_PLUS_TWO), 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),
getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId);
}
public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId, final String jsonAttributeToGetBack,
final String rejectedDate) {
System.out.println("----------------------------------UNDO REJECT CLIENT ----------------------------------");
public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId,
final String jsonAttributeToGetBack, final String rejectedDate) {
LOG.info("----------------------------------UNDO REJECT CLIENT ----------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId),
getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack);
}
public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId, final String jsonAttributeToGetBack,
final String rejectedDate) {
System.out.println("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------");
public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId,
final String jsonAttributeToGetBack, final String rejectedDate) {
LOG.info("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------");
return performClientActionsWithValidationErrors(
createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack);
}
public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId, final String jsonAttributeToGetBack) {
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId,
final String jsonAttributeToGetBack) {
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack);
}
public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId,
final String activationDate) {
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(activationDate), clientId);
}
@@ -537,88 +558,97 @@ public class ClientHelper {
jsonAttributeToGetBack);
}
private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS);
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent,
final Integer clientId) {
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent,
CommonConstants.RESPONSE_STATUS);
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
return response;
}
public static Integer addChargesForClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer clientId, final String request) {
System.out.println("--------------------------------- ADD CHARGES FOR Client --------------------------------");
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" + Utils.TENANT_IDENTIFIER;
public static Integer addChargesForClient(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer clientId, final String request) {
LOG.info("--------------------------------- ADD CHARGES FOR Client --------------------------------");
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, "");
return (Integer) response.get("resourceId");
}
public static String payChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer clientId, final Integer clientChargeId, final String json) {
System.out.println("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=paycharge&"
+ Utils.TENANT_IDENTIFIER;
public static String payChargesForClients(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId,
final String json) {
LOG.info("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------");
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, "");
return response.get("transactionId") != null ? response.get("transactionId").toString() : null;
}
public static String waiveChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer clientId, final Integer clientChargeId, final String json) {
System.out.println("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=waive&"
+ Utils.TENANT_IDENTIFIER;
public static String waiveChargesForClients(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId,
final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------");
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, "");
return response.get("transactionId").toString();
}
public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId, String clientChargeId) {
System.out.println("---------------------------------UNDO TRANSACTION---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId + "?command=undo&"
+ Utils.TENANT_IDENTIFIER;
public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String clientId, String clientChargeId) {
LOG.info("---------------------------------UNDO TRANSACTION---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId
+ "?command=undo&" + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", "");
return (Integer) response.get("resourceId");
}
public static Object getClientCharge(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId, final String clientChargeId) {
System.out.println("---------------------------------GET CLIENT CHARGE---------------------------------------------");
public static Object getClientCharge(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String clientId, final String clientChargeId) {
LOG.info("---------------------------------GET CLIENT CHARGE---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding");
}
public static Boolean getClientTransactions(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId, final String transactionId) {
System.out.println("---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + "?"
+ Utils.TENANT_IDENTIFIER;
public static Boolean getClientTransactions(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String clientId, final String transactionId) {
LOG.info(
"---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId
+ "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed");
}
public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel");
byte [] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,CLIENT_URL+"/downloadtemplate"+"?"+
Utils.TENANT_IDENTIFIER+"&legalFormType="+clientsEntity+"&dateFormat="+dateFormat);
InputStream inputStream= new ByteArrayInputStream(byteArray);
Workbook workbook=new HSSFWorkbook(inputStream);
requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate"
+ "?" + Utils.TENANT_IDENTIFIER + "&legalFormType=" + clientsEntity + "&dateFormat=" + dateFormat);
InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook = new HSSFWorkbook(inputStream);
return workbook;
}
public String getOutputTemplateLocation(final String importDocumentId){
requestSpec.header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?"
+Utils.TENANT_IDENTIFIER,importDocumentId);
public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
"/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER,
importDocumentId);
}
public String importClientEntityTemplate(File file){
String locale="en";
String dateFormat="dd MMMM yyyy";
String legalFormType=GlobalEntityType.CLIENTS_ENTTTY.toString();
public String importClientEntityTemplate(File file) {
String locale = "en";
String dateFormat = "dd MMMM yyyy";
String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString();
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec,responseSpec,CLIENT_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER,
legalFormType,file,locale,dateFormat);
return Utils.performServerTemplatePost(requestSpec, responseSpec,
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 java.util.ArrayList;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class CurrenciesHelper {
private final static Logger LOG = LoggerFactory.getLogger(CurrenciesHelper.class);
private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies";
public static ArrayList<CurrencyDomain> getAllCurrencies(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
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, "");
ArrayList<HashMap> selectedCurrencyOptions = (ArrayList<HashMap>) response.get("selectedCurrencyOptions");
ArrayList<HashMap> currencyOptions = (ArrayList<HashMap>) response.get("currencyOptions");
@@ -45,7 +47,7 @@ public class CurrenciesHelper {
public static ArrayList<CurrencyDomain> getSelectedCurrencies(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
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 String jsonData = new Gson().toJson(response.get("selectedCurrencyOptions"));
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,
final ResponseSpecification responseSpec, final ArrayList<String> currencies) {
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");
return (ArrayList<String>) hash.get("currencies");
}
@@ -71,7 +73,7 @@ public class CurrenciesHelper {
private static String currenciesToJSON(final ArrayList<String> currencies) {
HashMap map = new HashMap<>();
map.put("currencies", currencies);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
}
@@ -29,24 +29,28 @@ public class ExternalServicesConfigurationHelper {
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
}
public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String serviceName) {
final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?"
+ Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------");
public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(
final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String serviceName) {
final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/"
+ 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, "");
}
public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec,
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 + "?"
+ Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------");
final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName
+ "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------UPDATE VALUE FOR GLOBAL
// CONFIG---------------------------------------------");
HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL,
updateExternalServicesConfigUpdateValueAsJSON(name, value), "");
@@ -56,7 +60,7 @@ public class ExternalServicesConfigurationHelper {
public static String updateExternalServicesConfigUpdateValueAsJSON(final String name, final String value) {
final HashMap<String, String> map = new HashMap<>();
map.put(name, value);
System.out.println("map : " + map);
// system.out.println("map : " + map);
return new Gson().toJson(map);
}
@@ -24,10 +24,12 @@ import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" })
public class GlobalConfigurationHelper {
private final static Logger LOG = LoggerFactory.getLogger(GlobalConfigurationHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -38,7 +40,7 @@ public class GlobalConfigurationHelper {
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;
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, "");
return (ArrayList<HashMap>) response.get("globalConfiguration");
}
@@ -46,7 +48,7 @@ public class GlobalConfigurationHelper {
public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String configId) {
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, "");
}
@@ -338,7 +340,7 @@ public class GlobalConfigurationHelper {
public static Integer updateValueForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String configId, final String value) {
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),
"resourceId");
}
@@ -346,8 +348,7 @@ public class GlobalConfigurationHelper {
public static Integer updateEnabledFlagForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String configId, final Boolean enabled) {
final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
System.out
.println("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------");
LOG.info("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL,
updateGlobalConfigUpdateEnabledFlagAsJSON(enabled), "resourceId");
}
@@ -355,7 +356,7 @@ public class GlobalConfigurationHelper {
public static ArrayList getGlobalConfigurationIsCacheEnabled(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
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, "");
return response;
}
@@ -363,7 +364,7 @@ public class GlobalConfigurationHelper {
public static HashMap updateIsCacheEnabledForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String cacheType) {
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,
updateIsCacheEnabledGlobalConfigUpdateAsJSON(cacheType), "changes");
}
@@ -371,7 +372,7 @@ public class GlobalConfigurationHelper {
public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec,
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;
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,
updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack);
}
@@ -379,7 +380,7 @@ public class GlobalConfigurationHelper {
public static String updateGlobalConfigUpdateValueAsJSON(final String value) {
final HashMap<String, String> map = new HashMap<>();
map.put("value", value);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
@@ -389,21 +390,21 @@ public class GlobalConfigurationHelper {
map.put("value", value);
}
map.put("enabled", enabled);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) {
final HashMap<String, Boolean> map = new HashMap<String, Boolean>();
map.put("enabled", enabled);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) {
final HashMap<String, String> map = new HashMap<>();
map.put("cacheType", cacheType);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
@@ -24,10 +24,12 @@ import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" })
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 CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
@@ -57,14 +59,14 @@ public class HolidayHelper {
map.put("repaymentsRescheduledTo", "08 April 2013");
map.put("reschedulingType", 2);
String HolidayCreateJson = new Gson().toJson(map);
System.out.println(HolidayCreateJson);
LOG.info("{}",HolidayCreateJson);
return HolidayCreateJson;
}
public static String getActivateHolidayDataAsJSON() {
final HashMap<String, String> map = new HashMap<>();
String activateHoliday = new Gson().toJson(map);
System.out.println(activateHoliday);
LOG.info("{}",activateHoliday);
return activateHoliday;
}
@@ -80,7 +82,7 @@ public class HolidayHelper {
public static HashMap getHolidayById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String holidayID) {
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, "");
return response;
}
@@ -26,9 +26,11 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HookHelper {
private final static Logger LOG = LoggerFactory.getLogger(HookHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -40,7 +42,7 @@ public class HookHelper {
}
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),
"resourceId");
}
@@ -60,31 +62,31 @@ public class HookHelper {
createOfficeEvent.put("entityName", "OFFICE");
events.add(createOfficeEvent);
map.put("events", events);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
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;
return Utils.performServerPut(this.requestSpec, this.responseSpec, UPDATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId");
}
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;
return Utils.performServerDelete(this.requestSpec, this.responseSpec, DELETE_HOOK_URL, "resourceId");
}
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 Integer responseHookId = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "id");
assertEquals(hookId.toString(), responseHookId.toString());
}
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;
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);
@@ -92,7 +94,7 @@ public class HookHelper {
}
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;
ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build();
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.ResponseSpecification;
import org.apache.http.HttpHeaders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 IMAGES_URI = "/images";
public static Integer createImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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;
return Utils.performServerPost(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId");
}
public static Integer updateImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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;
return Utils.performServerPut(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId");
}
public static String getStaffImageAsText(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;
requestSpec.header(HttpHeaders.ACCEPT, "text/plain");
return Utils.performGetTextResponse(requestSpec, responseSpec, URL);
@@ -51,14 +53,14 @@ public class ImageHelper {
public static byte[] getStaffImageAsBinary(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;
requestSpec.header(HttpHeaders.ACCEPT, "application/octet-stream");
return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL);
}
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;
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.ResponseSpecification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NotificationHelper {
private final static Logger LOG = LoggerFactory.getLogger(NotificationHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -36,7 +38,7 @@ public class NotificationHelper {
public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String jsonReturn) {
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, "");
}
}
@@ -31,9 +31,11 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OfficeHelper {
private final static Logger LOG = LoggerFactory.getLogger(OfficeHelper.class);
private static final String OFFICE_URL = "/fineract-provider/api/v1/offices";
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -67,7 +69,7 @@ public class OfficeHelper {
map.put("locale", "en");
map.put("openingDate", openingDate);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL
+ "/" + id + "?" + Utils.TENANT_IDENTIFIER,
@@ -81,7 +83,7 @@ public class OfficeHelper {
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en");
map.put("openingDate", openingDate);
System.out.println("map : " + map);
LOG.info("map : {}" , 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";
public static Object updatePasswordPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
String validationPolicyId) {
public static Object updatePasswordPreferences(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, String validationPolicyId) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("---------------------------------UPDATE PASSWORD PREFERENCE---------------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesAsJson(validationPolicyId), "");
// system.out.println("---------------------------------UPDATE PASSWORD
// PREFERENCE---------------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL,
updatePreferencesAsJson(validationPolicyId), "");
}
public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,String invalidValidationPolicyId, String jsonAttributeToGetback) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out
.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------");
//system.out
//.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId),
jsonAttributeToGetback);
}
@@ -55,14 +57,17 @@ public class PasswordPreferencesHelper {
return new Gson().toJson(map);
}
public static int getActivePasswordPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id");
public static int getActivePasswordPreference(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
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" })
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";
public static Integer createPaymentType(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String name, final String description, final Boolean isCashPayment, final Integer position) {
System.out.println("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------");
public static Integer createPaymentType(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String name, final String description,
final Boolean isCashPayment, final Integer position) {
// system.out.println("---------------------------------CREATING A PAYMENT
// TYPE---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL,
getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId");
}
public static String getJsonToCreatePaymentType(final String name, final String description, final Boolean isCashPayment,
final Integer position) {
public static String getJsonToCreatePaymentType(final String name, final String description,
final Boolean isCashPayment, final Integer position) {
HashMap hm = new HashMap();
hm.put("name", name);
if (description != null) hm.put("description", description);
if (description != null)
hm.put("description", description);
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);
}
public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedPaymentTypeID) {
System.out.println("------------------------------CHECK PAYMENT DETAILS------------------------------------\n");
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER;
final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id");
public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer generatedPaymentTypeID) {
// system.out.println("------------------------------CHECK PAYMENT
// DETAILS------------------------------------\n");
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);
}
public static PaymentTypeDomain retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec,
final Integer paymentTypeId) {
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, "");
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,
final ResponseSpecification responseSpec) {
public static HashMap<String, String> updatePaymentType(final int id, HashMap request,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
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,
new Gson().toJson(request), "changes");
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;
System.out.println("---------------------------------DELETING PAYMENT TYPE " + id + "--------------------------------------------");
// system.out.println("---------------------------------DELETING PAYMENT TYPE "
// + id + "--------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId");
}
@@ -44,10 +44,12 @@ import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class ProvisioningIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ProvisioningIntegrationTest.class);
private static final String NONE = "1";
private final static int LOANPRODUCTS_SIZE = 10;
@@ -84,7 +86,7 @@ public class ProvisioningIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------");
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loans.add(loanID);
@@ -181,7 +183,7 @@ public class ProvisioningIntegrationTest {
}
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() //
.withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") //
@@ -203,7 +205,7 @@ public class ProvisioningIntegrationTest {
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges,
final String savingsId, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) //
.withLoanTermFrequency("4") //
@@ -31,10 +31,12 @@ import java.util.Map;
import java.util.function.ToIntFunction;
import java.util.stream.Collectors;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class SchedulerJobHelper {
private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification response200Spec;
private final ResponseSpecification response202Spec;
@@ -53,7 +55,7 @@ public class SchedulerJobHelper {
private List getAllSchedulerJobs() {
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, "");
return response;
}
@@ -65,16 +67,16 @@ public class SchedulerJobHelper {
public Map<String, Object> getSchedulerJobById(int jobId) {
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, "");
System.out.println(response);
LOG.info("{}",response.toString());
assertNotNull(response);
return response;
}
public Boolean getSchedulerStatus() {
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, "");
return (Boolean) response.get("active");
}
@@ -82,13 +84,13 @@ public class SchedulerJobHelper {
public void updateSchedulerStatus(final boolean on) {
String command = on ? "start" : "stop";
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);
}
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;
System.out.println("------------------------ UPDATING SCHEDULER JOB -------------------------");
LOG.info("------------------------ UPDATING SCHEDULER JOB -------------------------");
final Map<String, Object> response = Utils.performServerPut(requestSpec, response200Spec, UPDATE_SCHEDULER_JOB_URL,
updateSchedulerJobAsJSON(active), "changes");
return response;
@@ -97,13 +99,13 @@ public class SchedulerJobHelper {
private static String updateSchedulerJobAsJSON(final String active) {
final Map<String, String> map = new HashMap<>();
map.put("active", active);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
public List getSchedulerJobHistory(int jobId) {
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, "");
return (ArrayList) response.get("pageItems");
}
@@ -111,14 +113,14 @@ public class SchedulerJobHelper {
public static void runSchedulerJob(final RequestSpecification requestSpec, final String jobId) {
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;
System.out.println("------------------------ RUN SCHEDULER JOB -------------------------");
LOG.info("------------------------ RUN SCHEDULER JOB -------------------------");
Utils.performServerPost(requestSpec, responseSpec, RUN_SCHEDULER_JOB_URL, runSchedulerJobAsJSON(), null);
}
private static String runSchedulerJobAsJSON() {
final Map<String, String> map = new HashMap<>();
String runSchedulerJob = new Gson().toJson(map);
System.out.println(runSchedulerJob);
LOG.info(runSchedulerJob);
return runSchedulerJob;
}
@@ -142,7 +144,7 @@ public class SchedulerJobHelper {
Thread.sleep(15000);
schedulerJob = getSchedulerJobById(jobId);
Assert.assertNotNull(schedulerJob);
System.out.println("Job is Still Running");
LOG.info("Job is Still Running");
}
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());
// print error associated with recent job failure (if any)
System.out.println("Job run error message (printed only if the job fails: "
+ jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorMessage"));
System.out.println("Job failure error log (printed only if the job fails: "
+ jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorLog"));
LOG.info("Job run error message (printed only if the job fails: {}"
, jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorMessage"));
LOG.info("Job failure error log (printed only if the job fails: {}"
, jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorLog"));
// Verifying the Status of the Recently executed Scheduler Job
Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
@@ -23,10 +23,12 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"unused", "rawtypes", "unchecked" })
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_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory";
private static final String LOCALE = "en_GB";
@@ -88,13 +90,13 @@ public class StandingInstructionsHelper {
map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS);
map.put("recurrenceOnMonthDay", monthDay);
String savingsApplicationJSON = new Gson().toJson(map);
System.out.println(savingsApplicationJSON);
LOG.info("{}",savingsApplicationJSON);
return savingsApplicationJSON;
}
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) {
System.out.println("-------------------------------- CREATE STANDING INSTRUCTIONS --------------------------------");
LOG.info("-------------------------------- CREATE STANDING INSTRUCTIONS --------------------------------");
final String standingInstructionAsJSON = new StandingInstructionsHelper(this.requestSpec, this.responseSpec) //
.build(clientId.toString(), fromAccountId.toString(), toAccountId.toString(), fromAccountType, toAccountType, validFrom,
validTo, monthDay);
@@ -104,7 +106,7 @@ public class StandingInstructionsHelper {
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 + "?"
+ Utils.TENANT_IDENTIFIER;
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
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId
+ "&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,
STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems");
return response;
@@ -24,9 +24,11 @@ import com.google.gson.Gson;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
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,
final String activationDate) {
System.out.println("---------------------------------FULFIL PPI ---------------------------------------------");
LOG.info("---------------------------------FULFIL PPI ---------------------------------------------");
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_fryingpans_cd_q10_fryingpans", "138");
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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 Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id");
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
@@ -23,14 +23,16 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.accounting.Account;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
public static Integer createTaxComponent(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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,
getTaxComponentAsJSON(percentage, liabilityAccountId), "resourceId");
}
@@ -41,7 +43,7 @@ public class TaxComponentHelper {
map.put("creditAccountType", Account.AccountType.LIABILITY.toString());
map.put("creditAcountId", String.valueOf(creditAccountId));
}
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
@@ -25,14 +25,16 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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");
}
@@ -61,7 +61,7 @@ public class Utils {
public static final String TENANT_TIME_ZONE = "Asia/Kolkata";
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() {
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);
return;
} 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);
}
} 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;
sleep(3);
}
@@ -97,7 +99,8 @@ public class Utils {
logger.error("{} still not reachable, giving up", HEALTH_URL, lastException);
throw new AssertionError(HEALTH_URL + " not reachable", lastException);
} 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());
}
}
@@ -115,10 +118,10 @@ public class Utils {
awaitSpringBootActuatorHealthyUp();
try {
logger.info("Logging in, for integration test...");
System.out.println("-----------------------------------LOGIN-----------------------------------------");
// system.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.given().contentType(ContentType.JSON)
.body("{\"username\":\"mifos\", \"password\":\"password\"}")
.expect().log().ifError().when().post(LOGIN_URL).asString();
.body("{\"username\":\"mifos\", \"password\":\"password\"}").expect().log().ifError().when()
.post(LOGIN_URL).asString();
assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false));
String key = JsonPath.with(json).get("base64EncodedAuthenticationKey");
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,
final String getURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
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)
public static <T> T performServerGet(final RequestSpecification requestSpec,
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();
if (jsonAttributeToGetBack == null) { return (T) json; }
if (jsonAttributeToGetBack == null) {
return (T) json;
}
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String putURL, final String jsonBodyToSend, 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()
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();
if (jsonAttributeToGetBack == null) {
return (T) json;
}
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()
public static <T> T performServerPut(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String putURL, final String jsonBodyToSend,
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();
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));
}
@@ -208,11 +221,12 @@ public class Utils {
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
return randomStringGenerator(prefix, lenOfRandomSuffix);
}
public static Long randomNumberGenerator(final int expectedLength){
final String source="1234567890";
final int lengthofSource=source.length();
final Random random=new Random();
StringBuilder stringBuilder=new StringBuilder(expectedLength);
public static Long randomNumberGenerator(final int expectedLength) {
final String source = "1234567890";
final int lengthofSource = source.length();
final Random random = new Random();
StringBuilder stringBuilder = new StringBuilder(expectedLength);
for (int i = 0; i < expectedLength; i++) {
stringBuilder.append(source.charAt(random.nextInt(lengthofSource)));
}
@@ -238,28 +252,20 @@ public class Utils {
return TimeZone.getTimeZone(TENANT_TIME_ZONE);
}
public static String performServerTemplatePost(final RequestSpecification requestSpec,final ResponseSpecification responseSpec,
final String postURL,final String legalFormType,final File file,final String locale,final String dateFormat) {
public static String performServerTemplatePost(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String postURL, final String legalFormType, final File file,
final String locale, final String dateFormat) {
final String importDocumentId=given().spec(requestSpec)
.queryParam("legalFormType",legalFormType)
.multiPart("file",file)
.formParam("locale",locale)
.formParam("dateFormat",dateFormat)
.expect().spec(responseSpec).
log().ifError().when().post(postURL)
.andReturn().asString();
final String importDocumentId = given().spec(requestSpec).queryParam("legalFormType", legalFormType)
.multiPart("file", file).formParam("locale", locale).formParam("dateFormat", dateFormat).expect()
.spec(responseSpec).log().ifError().when().post(postURL).andReturn().asString();
return importDocumentId;
}
public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec,final ResponseSpecification responseSpec,
final String getURL,final String importDocumentId){
final String templateLocation=given().spec(requestSpec).
queryParam("importDocumentId",importDocumentId)
.expect().spec(responseSpec)
.log().ifError().when().get(getURL)
.andReturn().asString();
return templateLocation.substring(1,templateLocation.length()-1);
public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String getURL, final String importDocumentId) {
final String templateLocation = given().spec(requestSpec).queryParam("importDocumentId", importDocumentId)
.expect().spec(responseSpec).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 java.util.HashMap;
import java.util.Random;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WorkingDaysHelper {
private final static Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class);
private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays";
public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
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(), "");
}
public static Object updateWorkingDaysWithWrongRecurrence(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, String jsonAttributeToGetback) {
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out
.println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
LOG.info("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(),
jsonAttributeToGetback);
}
@@ -49,7 +50,7 @@ public class WorkingDaysHelper {
map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
@@ -59,7 +60,7 @@ public class WorkingDaysHelper {
map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false);
System.out.println("map : " + map);
LOG.info("map : {}" , 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.Utils;
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" })
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 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_OVERDRAFT_FEE = 10;
private static final Integer WEEKLY_FEE = 11;
private static final Integer SHAREACCOUNT_ACTIVATION = 13 ;
private static final Integer SHARE_PURCHASE = 14 ;
private static final Integer SHARE_REDEEM = 15 ;
private static final Integer SHAREACCOUNT_ACTIVATION = 13;
private static final Integer SHARE_PURCHASE = 14;
private static final Integer SHARE_REDEEM = 15;
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("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -101,7 +103,7 @@ public class ChargesHelper {
final HashMap<String, Object> map = populateDefaultsForSavings(amount.toString(), currencyCode);
map.put("chargeTimeType", timeType.getValue());
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -110,7 +112,7 @@ public class ChargesHelper {
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay);
map.put("chargeTimeType", CHARGE_ANNUAL_FEE);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -120,7 +122,7 @@ public class ChargesHelper {
map.put("chargeTimeType", CHARGE_MONTHLY_FEE);
map.put("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -129,7 +131,7 @@ public class ChargesHelper {
map.put("chargeTimeType", WEEKLY_FEE);
map.put("feeInterval", 1);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -137,7 +139,7 @@ public class ChargesHelper {
final HashMap<String, Object> map = populateDefaultsForSavings();
map.put("chargeTimeType", CHARGE_OVERDRAFT_FEE);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -166,31 +168,37 @@ public class ChargesHelper {
return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
}
public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, final String amount) {
return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType,
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();
map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE);
map.put("chargePaymentMode", paymentmode);
map.put("amount", amount);
map.put("chargeCalculationType", chargeCalculationType);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
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) {
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount,
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,
final Integer paymentMode) {
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount,
final boolean penalty, final Integer paymentMode) {
final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE);
map.put("chargePaymentMode", paymentMode);
@@ -199,26 +207,29 @@ public class ChargesHelper {
map.put("chargeCalculationType", chargeCalculationType);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, final String amount,
boolean penalty) {
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
}
public static String getLoanSpecifiedDueDateWithAccountTransferJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, ChargesHelper.penalty,
public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType,
final String amount, boolean penalty) {
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
}
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
public static String getLoanSpecifiedDueDateWithAccountTransferJSON() {
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,
final Integer paymentMode) {
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount,
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();
map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE);
map.put("chargePaymentMode", paymentMode);
@@ -227,36 +238,39 @@ public class ChargesHelper {
map.put("chargeCalculationType", chargeCalculationType);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, final String amount, boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType,
final String amount, boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
}
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() {
HashMap<String, Object> map = populateDefaultsShareActivationCharge() ;
HashMap<String, Object> map = populateDefaultsShareActivationCharge();
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
public static String getShareAccountPurchaseChargeJson() {
HashMap<String, Object> map = populateDefaultsSharePurchaseFlatCharge() ;
HashMap<String, Object> map = populateDefaultsSharePurchaseFlatCharge();
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
public static String getShareAccountRedeemChargeJson() {
HashMap<String, Object> map = populateDefaultsShareRedeemFlatCharge() ;
HashMap<String, Object> map = populateDefaultsShareRedeemFlatCharge();
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -269,7 +283,7 @@ public class ChargesHelper {
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay);
map.put("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -281,7 +295,7 @@ public class ChargesHelper {
map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
String chargesCreateJson = new Gson().toJson(map);
System.out.println(chargesCreateJson);
LOG.info("{}", chargesCreateJson);
return chargesCreateJson;
}
@@ -304,7 +318,7 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_CLIENT);
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("locale", CommonConstants.locale);
map.put("monthDayFormat", ChargesHelper.monthDayFormat);
@@ -318,7 +332,7 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
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("locale", CommonConstants.locale);
map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8));
@@ -331,7 +345,7 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
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("locale", CommonConstants.locale);
map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8));
@@ -344,43 +358,47 @@ public class ChargesHelper {
map.put("amount", ChargesHelper.amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
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("locale", CommonConstants.locale);
map.put("name", Utils.randomNameGenerator("Charge_Share_Redeem_", 8));
return map;
}
public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String request) {
public static Integer createCharges(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String request) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
}
public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec,
CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
}
public static HashMap getChargeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
public static HashMap getChargeById(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
}
public static HashMap getChargeChanges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER,
CommonConstants.RESPONSE_CHANGES);
public static HashMap getChargeChanges(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_CHANGES);
}
public static HashMap updateCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer chargeId, final String request) {
return Utils.performServerPut(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
public static HashMap updateCharges(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer chargeId, final String request) {
return Utils.performServerPut(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
CommonConstants.RESPONSE_CHANGES);
}
public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec,
final Integer chargeId) {
return Utils.performServerDelete(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER,
CommonConstants.RESPONSE_RESOURCE_ID);
return Utils.performServerDelete(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID);
}
public static String getModifyChargeJSON() {
@@ -388,7 +406,7 @@ public class ChargesHelper {
map.put("locale", CommonConstants.locale);
map.put("amount", "200.0");
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -397,7 +415,7 @@ public class ChargesHelper {
map.put("locale", CommonConstants.locale);
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -407,7 +425,7 @@ public class ChargesHelper {
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -417,7 +435,7 @@ public class ChargesHelper {
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -427,7 +445,7 @@ public class ChargesHelper {
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST);
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -437,7 +455,7 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_DAYS);
map.put("feeInterval", 2);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -447,7 +465,7 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_WEEKS);
map.put("feeInterval", 2);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -457,7 +475,7 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS);
map.put("feeInterval", 2);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -467,19 +485,21 @@ public class ChargesHelper {
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_YEARS);
map.put("feeInterval", 2);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
public static String getChargeSpecifiedDueDateJSON() {
final HashMap<String, Object> map = populateDefaultsClientCharge();
String chargesCreateJson = new Gson().toJson(map);
System.out.println("chargesCreateJson:"+chargesCreateJson);
LOG.info("chargesCreateJson: {}", chargesCreateJson);
return chargesCreateJson;
}
public static String applyCharge(RequestSpecification requestSpec,ResponseSpecification responseSpec, String chargeId,String json) {
return Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json,"status");
public static String applyCharge(RequestSpecification requestSpec, ResponseSpecification responseSpec,
String chargeId, String json) {
return Utils.performServerPost(requestSpec, responseSpec,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json, "status");
}
}
@@ -26,10 +26,12 @@ import java.util.Calendar;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountHelper.class);
private final RequestSpecification requestSpec;
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 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 UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval";
private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject";
@@ -126,21 +129,22 @@ public class FixedDepositAccountHelper {
map.put("transferInterestToSavings", transferInterest);
String fixedDepositAccountJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountJson);
LOG.info("{}", fixedDepositAccountJson);
return fixedDepositAccountJson;
}
public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
System.out.println("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, fixedDepositAccountAsJson,
CommonConstants.RESPONSE_RESOURCE_ID);
public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
LOG.info("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL,
fixedDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID);
}
public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer accountID) {
final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------");
public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer accountID) {
final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, "");
}
@@ -173,8 +177,8 @@ public class FixedDepositAccountHelper {
return annualInterestRate;
}
public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Integer depositPeriod,
double interestPerDay, Integer compoundingInterval, Integer postingInterval) {
public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal,
Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval) {
Float totalInterest = 0.0f;
Float interestEarned = 0.0f;
@@ -194,7 +198,7 @@ public class FixedDepositAccountHelper {
principal += totalInterest;
}
totalInterest = 0.0f;
System.out.println(principal);
LOG.info("{}", principal.toString());
}
currentDate.add(Calendar.MONTH, 1);
@@ -203,21 +207,23 @@ public class FixedDepositAccountHelper {
return principal;
}
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom,
final String validTo, final String penalInterestType, final String submittedOnDate) {
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID,
final String validFrom, final String validTo, final String penalInterestType,
final String submittedOnDate) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) //
.build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
return Utils.performServerPut(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
}
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID,
final String submittedOnDate, final String validFrom, final String validTo, final String numberOfDaysPerYear,
final String penalInterestType, final String interestCalculationType, final String interestCompoundingPeriodType,
final String interestPostingPeriodType) {
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID,
final String accountID, final String submittedOnDate, final String validFrom, final String validTo,
final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType,
final String interestCompoundingPeriodType, final String interestPostingPeriodType) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) //
@@ -227,75 +233,91 @@ public class FixedDepositAccountHelper {
.withInterestPostingPeriodType(interestPostingPeriodType) //
.build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
return Utils.performServerPut(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
}
public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) {
System.out.println("--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------");
return performFixedDepositApplicationActions(createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
LOG.info(
"--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------");
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getApproveFixedDepositAccountAsJSON(approvedOnDate));
}
public HashMap undoApproval(final Integer fixedDepositAccountID) {
System.out.println("--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
LOG.info(
"--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
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) {
System.out.println("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions(createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getRejectedFixedDepositAsJSON(rejectedOnDate));
}
public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) {
System.out.println("--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
LOG.info(
"--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate));
}
public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) {
System.out.println("---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------");
return performFixedDepositApplicationActions(createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
LOG.info(
"---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------");
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getActivatedFixedDepositAccountAsJSON(activationDate));
}
public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, final String jsonAttributeToGetBack) {
System.out.println("---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?"
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID,
final String jsonAttributeToGetBack) {
LOG.info(
"---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER,
jsonAttributeToGetBack);
}
public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) {
System.out.println("--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
LOG.info(
"--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
return (Integer) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
}
public Integer postInterestForFixedDeposit(final Integer fixedDepositAccountId) {
System.out.println("--------------------------------- POST INTEREST FOR FIXED DEPOSIT --------------------------------");
LOG.info("--------------------------------- POST INTEREST FOR FIXED DEPOSIT --------------------------------");
return (Integer) performFixedDepositActions(
createFixedDepositCalculateInterestURL(POST_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
}
public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate) {
System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------");
public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId,
final String closedOnDate) {
LOG.info("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------");
return (HashMap) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId),
getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), "");
}
public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, final String closureType,
final Integer toSavingsId, final String jsonAttributeToGetBack) {
System.out.println("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------");
return performFixedDepositActions(createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId),
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack);
public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate,
final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) {
LOG.info("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------");
return performFixedDepositActions(
createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId),
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId),
jsonAttributeToGetBack);
}
private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) {
@@ -305,7 +327,7 @@ public class FixedDepositAccountHelper {
map.put("approvedOnDate", approvedOnDate);
map.put("note", "Approval NOTE");
String fixedDepositAccountApproveJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountApproveJson);
LOG.info(fixedDepositAccountApproveJson);
return fixedDepositAccountApproveJson;
}
@@ -316,7 +338,7 @@ public class FixedDepositAccountHelper {
map.put("rejectedOnDate", rejectedOnDate);
map.put("note", "Rejected NOTE");
String fixedDepositAccountJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountJson);
LOG.info("{}", fixedDepositAccountJson);
return fixedDepositAccountJson;
}
@@ -327,7 +349,7 @@ public class FixedDepositAccountHelper {
map.put("withdrawnOnDate", withdrawnApplicationOnDate);
map.put("note", "Withdraw NOTE");
String fixedDepositAccountJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountJson);
LOG.info("{}", fixedDepositAccountJson);
return fixedDepositAccountJson;
}
@@ -337,14 +359,14 @@ public class FixedDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("activatedOnDate", activationDate);
String fixedDepositAccountActivateJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountActivateJson);
LOG.info("{}", fixedDepositAccountActivateJson);
return fixedDepositAccountActivateJson;
}
private String getCalculatedInterestForFixedDepositApplicationAsJSON() {
final HashMap<String, String> map = new HashMap<>();
String fixedDepositAccountCalculatedInterestJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountCalculatedInterestJson);
LOG.info(fixedDepositAccountCalculatedInterestJson);
return fixedDepositAccountCalculatedInterestJson;
}
@@ -354,7 +376,7 @@ public class FixedDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("closedOnDate", closedOnDate);
String fixedDepositAccountPrematureClosureJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountPrematureClosureJson);
LOG.info(fixedDepositAccountPrematureClosureJson);
return fixedDepositAccountPrematureClosureJson;
}
@@ -370,23 +392,26 @@ public class FixedDepositAccountHelper {
map.put("transferDescription", "Transferring To Savings Account");
}
String fixedDepositAccountPrematureCloseJson = new Gson().toJson(map);
System.out.println(fixedDepositAccountPrematureCloseJson);
LOG.info(fixedDepositAccountPrematureCloseJson);
return fixedDepositAccountPrematureCloseJson;
}
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,
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;
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDepositAction, jsonToBeSent,
CommonConstants.RESPONSE_CHANGES);
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec,
postURLForFixedDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES);
if (response != null) {
status = (HashMap) response.get("status");
}
@@ -394,13 +419,15 @@ public class FixedDepositAccountHelper {
}
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) {
System.out.println("-------------------- RETRIEVING ALL FIXED DEPOSIT ACCOUNTS ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "?"
+ Utils.TENANT_IDENTIFIER, "");
public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT ACCOUNTS ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER, "");
return response;
}
@@ -439,7 +466,8 @@ public class FixedDepositAccountHelper {
return this;
}
public FixedDepositAccountHelper withLockinPeriodFrequency(final String lockingPeriodFrequencyType, final String lockinPeriodFrequency) {
public FixedDepositAccountHelper withLockinPeriodFrequency(final String lockingPeriodFrequencyType,
final String lockinPeriodFrequency) {
this.lockingPeriodFrequencyType = lockingPeriodFrequencyType;
this.lockinPeriodFrequency = lockinPeriodFrequency;
return this;
@@ -456,7 +484,9 @@ public class FixedDepositAccountHelper {
}
private String getDepositAmount() {
if (this.newDepositAmount == null) { return depositAmount; }
if (this.newDepositAmount == null) {
return depositAmount;
}
return this.newDepositAmount;
}
}
@@ -25,71 +25,78 @@ import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
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";
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"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) {
System.out.println("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue("FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE", getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue("FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE",
getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
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"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) {
System.out.println("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue("ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "rejected"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue("ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION",
getStatus(fixedDepositStatusHashMap, "rejected"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) {
System.out.println("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------");
assertTrue("ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------");
assertTrue("ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION",
getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
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"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
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"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String fixedDepositAccountID) {
final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?"
+ Utils.TENANT_IDENTIFIER;
public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String fixedDepositAccountID) {
final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID
+ "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status");
}
public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "prematureClosed"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT",
getStatus(fixedDepositStatusHashMap, "prematureClosed"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) {
System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue("ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "matured"));
System.out.println(fixedDepositStatusHashMap);
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue("ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT",
getStatus(fixedDepositStatusHashMap, "matured"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
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.Utils;
import org.apache.fineract.integrationtests.common.accounting.Account;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositProductHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -147,7 +149,7 @@ public class FixedDepositProductHelper {
}
String FixedDepositProductCreateJson = new Gson().toJson(map);
System.out.println(FixedDepositProductCreateJson);
LOG.info("{}",FixedDepositProductCreateJson);
return FixedDepositProductCreateJson;
}
@@ -421,13 +423,13 @@ public class FixedDepositProductHelper {
public static Integer createFixedDepositProduct(final String fixedDepositProductCreateJson, final RequestSpecification requestSpec,
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,
CommonConstants.RESPONSE_RESOURCE_ID);
}
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 + "?"
+ Utils.TENANT_IDENTIFIER, "");
return response;
@@ -435,7 +437,7 @@ public class FixedDepositProductHelper {
public static HashMap retrieveFixedDepositProductById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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 HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_FD_PRODUCT_BY_ID_URL, "");
return response;
@@ -443,7 +445,7 @@ public class FixedDepositProductHelper {
public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer productId) {
System.out.println("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------");
LOG.info("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId,
"chartSlabs");
return response;
@@ -49,9 +49,10 @@ public class LoanTransactionHelper {
private final ResponseSpecification responseSpec;
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 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 UNDO_APPROVAL_LOAN_COMMAND = "undoApproval";
private static final String DISBURSE_LOAN_COMMAND = "disburse";
@@ -75,25 +76,29 @@ public class LoanTransactionHelper {
}
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) {
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, "");
}
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");
}
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) {
@@ -102,66 +107,74 @@ public class LoanTransactionHelper {
}
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) {
return Utils.performServerPut(this.requestSpec, this.responseSpec, "/fineract-provider/api/v1/loans/" + id + "?"
+ Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId");
return Utils.performServerPut(this.requestSpec, this.responseSpec,
"/fineract-provider/api/v1/loans/" + id + "?" + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId");
}
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&" + Utils.TENANT_IDENTIFIER;
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&"
+ Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
return (ArrayList) response.get("periods");
}
public ArrayList getLoanCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&" + Utils.TENANT_IDENTIFIER;
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges");
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&"
+ Utils.TENANT_IDENTIFIER;
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges");
}
public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule,futureSchedule&"
+ Utils.TENANT_IDENTIFIER;
public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID
+ "?associations=repaymentSchedule,futureSchedule&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
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 HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
return response;
}
public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID,
final String param) {
public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanID, final String param) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
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;
return Utils.performServerGet(requestSpec, responseSpec, URL, null);
}
public Object getLoanProductDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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);
}
public String getLoanProductDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer loanProductId) {
final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER;
public String getLoanProductDetails(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer loanProductId) {
final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, null);
}
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, "");
}
@@ -179,13 +192,17 @@ public class LoanTransactionHelper {
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches));
}
public List<HashMap<String, Object>> approveLoanForTranches(final String approvalDate, final String expectedDisbursementDate,
final String approvalAmount, final Integer loanID, List<HashMap> tranches, final String responseAttribute) {
return (List<HashMap<String, Object>>) performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches), responseAttribute);
public List<HashMap<String, Object>> approveLoanForTranches(final String approvalDate,
final String expectedDisbursementDate, final String approvalAmount, final Integer loanID,
List<HashMap> tranches, final String 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 approvalJSONData = getApproveLoanAsJSON(approvalDate, null, approvalAmount, null);
@@ -199,24 +216,29 @@ public class LoanTransactionHelper {
}
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) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanWithRepaymentRescheduleAsJSON(date,
null, adjustRepaymentDate));
public HashMap disburseLoanWithRepaymentReschedule(final String date, final Integer loanID,
String adjustRepaymentDate) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanWithRepaymentRescheduleAsJSON(date, null, adjustRepaymentDate));
}
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) {
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) {
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) {
@@ -231,14 +253,15 @@ public class LoanTransactionHelper {
final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}";
final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID);
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,
final List<Map<String, Object>> approvalFormData, final Integer glimID) {
final List<Map<String, Object>> approvalFormData, final Integer glimID) {
String approvalForm = new LoanApplicationTestBuilder() //
.withApprovalFormData(approvalFormData)
.build();
.withApprovalFormData(approvalFormData).build();
final String approvalURL = createGlimAccountURL(APPROVE_LOAN_COMMAND, glimID);
return performLoanTransaction(approvalURL, approvalForm);
@@ -262,8 +285,8 @@ public class LoanTransactionHelper {
}
public HashMap rejectGlimAccount(final String date, final Integer glimID) {
LOG.info("--------------------------------- REJECT GLIM APPLICATION -------------------------------");
return performLoanTransaction(createGlimAccountURL(REJECT_LOAN_COMMAND, glimID), getRejectAsJSON(date));
LOG.info("--------------------------------- REJECT GLIM APPLICATION -------------------------------");
return performLoanTransaction(createGlimAccountURL(REJECT_LOAN_COMMAND, glimID), getRejectAsJSON(date));
}
public void recoverFromGuarantor(final Integer loanID) {
@@ -271,16 +294,20 @@ public class LoanTransactionHelper {
}
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) {
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,
createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived), "resourceId");
createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived),
"resourceId");
return resourceId;
}
@@ -301,13 +328,16 @@ public class LoanTransactionHelper {
public Integer addChargesForLoan(final Integer loanId, final String request) {
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, "");
return (Integer) response.get("resourceId");
}
public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request, final ResponseSpecification responseSpecification) {
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request,
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, "");
}
@@ -329,16 +359,16 @@ public class LoanTransactionHelper {
public Integer waiveChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=waive&"
+ Utils.TENANT_IDENTIFIER;
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
+ "?command=waive&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return (Integer) response.get("resourceId");
}
public Integer payChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=pay&"
+ Utils.TENANT_IDENTIFIER;
final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
+ "?command=pay&" + Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return (Integer) response.get("resourceId");
}
@@ -356,7 +386,8 @@ public class LoanTransactionHelper {
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<>();
map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy");
@@ -374,8 +405,8 @@ public class LoanTransactionHelper {
return getApproveLoanAsJSON(approvalDate, null, null, null);
}
private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate, final String approvalAmount,
List<HashMap> tranches) {
private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate,
final String approvalAmount, List<HashMap> tranches) {
final HashMap<String, Object> map = new HashMap<>();
map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy");
@@ -426,7 +457,7 @@ public class LoanTransactionHelper {
map.put("transactionDate", transactionDate);
map.put("note", "Foreclosure Made!!!");
String json = new Gson().toJson(map);
LOG.info(json);
LOG.info("{}", json);
return json;
}
@@ -463,7 +494,8 @@ public class LoanTransactionHelper {
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<>();
map.put("locale", "en_GB");
map.put("dateFormat", "dd MMMM yyyy");
@@ -471,7 +503,7 @@ public class LoanTransactionHelper {
map.put("dueDate", dueDate);
map.put("chargeId", chargeId);
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
@@ -486,7 +518,7 @@ public class LoanTransactionHelper {
map.put("amount", amount);
map.put("chargeId", chargeId);
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
@@ -497,7 +529,7 @@ public class LoanTransactionHelper {
map.put("amount", amount);
map.put("chargeId", chargeId);
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
@@ -507,7 +539,7 @@ public class LoanTransactionHelper {
map.put("dateFormat", "dd MMMM yyyy");
map.put("amount", amount);
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
@@ -520,7 +552,7 @@ public class LoanTransactionHelper {
map.put("installmentNumber", installmentNumber);
}
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
@@ -529,7 +561,7 @@ public class LoanTransactionHelper {
map.put("locale", "en_GB");
map.put("installmentNumber", installmentNumber);
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
@@ -559,44 +591,53 @@ public class LoanTransactionHelper {
}
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) {
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) {
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent,
"changes");
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction,
jsonToBeSent, "changes");
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,
"changes");
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction,
jsonToBeSent, "changes");
return (Float) response.get("disbursedAmount");
}
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, responseAttribute);
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent,
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,
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,
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);
}
@@ -607,11 +648,12 @@ public class LoanTransactionHelper {
map.put("transactionDate", date);
map.put("transactionAmount", transactionAmount);
String json = new Gson().toJson(map);
LOG.info(json);
LOG.info("{}", 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&"
+ Utils.TENANT_IDENTIFIER;
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "");
@@ -622,17 +664,20 @@ public class LoanTransactionHelper {
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--------------------------------");
final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding, repaymentPeriods.get(repaymentNumber)
.get("principalLoanBalanceOutstanding"));
final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
loanID);
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,
final Float penaltyPortion, final Integer loanID) {
public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion,
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;
for (int i = 0; i < transactions.size(); i++) {
HashMap transactionType = (HashMap) transactions.get(i).get("type");
@@ -640,8 +685,8 @@ public class LoanTransactionHelper {
if (isAccrualTransaction) {
ArrayList<Integer> accrualEntryDateAsArray = (ArrayList<Integer>) transactions.get(i).get("date");
LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
accrualEntryDateAsArray.get(2));
LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0),
accrualEntryDateAsArray.get(1), accrualEntryDateAsArray.get(2));
if (transactionDate.equals(accrualEntryDate)) {
isTransactionFound = true;
@@ -664,10 +709,10 @@ public class LoanTransactionHelper {
getRefundByCashBodyAsJSON(date, amountToBeRefunded));
}
public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId,
final Integer fromClientId, final String date, final Float amountToBeRefunded) {
return performLoanTransaction(createLoanRefundTransferURL(),
getRefundByTransferBodyAsJSON(fromAccountId, toClientId, toAccountId, fromClientId, date, amountToBeRefunded));
public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId,
final Integer toAccountId, final Integer fromClientId, final String date, final Float amountToBeRefunded) {
return performLoanTransaction(createLoanRefundTransferURL(), getRefundByTransferBodyAsJSON(fromAccountId,
toClientId, toAccountId, fromClientId, date, amountToBeRefunded));
}
private String getRefundByCashBodyAsJSON(final String transactionDate, final Float transactionAmount) {
@@ -680,8 +725,9 @@ public class LoanTransactionHelper {
return new Gson().toJson(map);
}
private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId,
final Integer fromClientId, final String transactionDate, final Float transactionAmount) {
private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId,
final Integer toAccountId, final Integer fromClientId, final String transactionDate,
final Float transactionAmount) {
final HashMap<String, String> map = new HashMap<>();
map.put("fromAccountId", fromAccountId.toString());
map.put("fromAccountType", "1");
@@ -701,7 +747,7 @@ public class LoanTransactionHelper {
public HashMap createTrancheDetail(final String id, final String date, final String amount) {
HashMap<String, Object> detail = new HashMap<>();
if(id != null){
if (id != null) {
detail.put("id", id);
}
detail.put("expectedDisbursementDate", date);
@@ -710,26 +756,34 @@ public class LoanTransactionHelper {
return detail;
}
public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, final String approvalAmount, final String expectedDisbursementDate,
final String updatedExpectedDisbursementDate, final String updatedPrincipal, final String jsonAttributeToGetBack) {
public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId,
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,
updatedExpectedDisbursementDate, updatedPrincipal), jsonAttributeToGetBack);
return Utils.performServerPut(this.requestSpec, this.responseSpec,
createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount,
expectedDisbursementDate, updatedExpectedDisbursementDate, updatedPrincipal),
jsonAttributeToGetBack);
}
public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, final String expectedDisbursementDate
, List<HashMap> disbursementData, final String jsonAttributeToGetBack) {
public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount,
final String expectedDisbursementDate, List<HashMap> disbursementData,
final String jsonAttributeToGetBack) {
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) {
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) {
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,
@@ -742,12 +796,12 @@ public class LoanTransactionHelper {
map.put("updatedExpectedDisbursementDate", updatedExpectedDisbursementDate);
map.put("updatedPrincipal", updatedPrincipal);
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate,
final List<HashMap> disbursementData) {
public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount,
final String expectedDisbursementDate, final List<HashMap> disbursementData) {
final HashMap map = new HashMap<>();
map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy");
@@ -755,7 +809,7 @@ public class LoanTransactionHelper {
map.put("expectedDisbursementDate", expectedDisbursementDate);
map.put("disbursementData", disbursementData);
String json = new Gson().toJson(map);
LOG.info("{}",json);
LOG.info("{}", json);
return json;
}
@@ -776,27 +830,29 @@ public class LoanTransactionHelper {
}
public Workbook getLoanWorkbook(String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel");
byte[] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,LOAN_ACCOUNT_URL+"/downloadtemplate"+"?"+
Utils.TENANT_IDENTIFIER+"&dateFormat="+dateFormat);
InputStream inputStream= new ByteArrayInputStream(byteArray);
Workbook workbook=new HSSFWorkbook(inputStream);
requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec,
LOAN_ACCOUNT_URL + "/downloadtemplate" + "?" + Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook = new HSSFWorkbook(inputStream);
return workbook;
}
public String importLoanTemplate(File file) {
String locale="en";
String dateFormat="dd MMMM yyyy";
String legalFormType= null;
String locale = "en";
String dateFormat = "dd MMMM yyyy";
String legalFormType = null;
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec,responseSpec,LOAN_ACCOUNT_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER,
legalFormType,file,locale,dateFormat);
return Utils.performServerTemplatePost(requestSpec, responseSpec,
LOAN_ACCOUNT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale,
dateFormat);
}
public String getOutputTemplateLocation(final String importDocumentId){
requestSpec.header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?"
+Utils.TENANT_IDENTIFIER,importDocumentId);
public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
"/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.report.ReportData;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
public class CampaignsHelper {
private final static Logger LOG = LoggerFactory.getLogger(CampaignsHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -52,51 +54,58 @@ public class CampaignsHelper {
}
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;
return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL, getCreateCampaignJSON(reportName, triggerType),
"resourceId");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL,
getCreateCampaignJSON(reportName, triggerType), "resourceId");
}
public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId) {
System.out.println("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n");
final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER;
final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL, "id");
public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer generatedCampaignId) {
LOG.info("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n");
final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?"
+ Utils.TENANT_IDENTIFIER;
final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL,
"id");
assertEquals("ERROR IN CREATING THE CAMPAIGN", generatedCampaignId, responseCampaignId);
}
public Integer updateCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId, String reportName, Integer triggerType) {
System.out.println("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n");
final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL, getUpdateCampaignJSON(reportName, triggerType),
"resourceId");
LOG.info("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n");
final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL,
getUpdateCampaignJSON(reportName, triggerType), "resourceId");
}
public Integer deleteCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId) {
System.out.println("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n");
final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n");
final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_SMS_CAMPAIGNS_URL, "resourceId");
}
public Integer performActionsOnCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedCampaignId, String command) {
System.out.println("------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n");
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
public Integer performActionsOnCampaign(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer generatedCampaignId, String command) {
LOG.info(
"------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n");
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command
+ "&" + Utils.TENANT_IDENTIFIER;
String actionDate = Utils.getLocalDateOfTenant().toString(DATE_FORMAT);
return Utils
.performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL, getJSONForCampaignAction(command, actionDate), "resourceId");
return Utils.performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL,
getJSONForCampaignAction(command, actionDate), "resourceId");
}
public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command, String actionDate, String responseJsonAttribute) {
System.out.println("--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n");
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(this.requestSpec, this.responseSpec, SMS_CAMPAIGNS_ACTION_URL, getJSONForCampaignAction(command, actionDate),
responseJsonAttribute);
public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command,
String actionDate, String responseJsonAttribute) {
LOG.info(
"--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n");
final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command
+ "&" + 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) {
@@ -122,7 +131,7 @@ public class CampaignsHelper {
paramValueMap.put("reportName", reportName);
map.put("paramValue", paramValueMap);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -147,7 +156,7 @@ public class CampaignsHelper {
paramValueMap.put("reportName", reportName);
map.put("paramValue", paramValueMap);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -158,7 +167,7 @@ public class CampaignsHelper {
map.put("locale", "en");
map.put("dateFormat", DATE_FORMAT);
String json = new Gson().toJson(map);
System.out.println(json);
LOG.info("{}", json);
return json;
}
@@ -167,17 +176,18 @@ public class CampaignsHelper {
}
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");
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()
.asString();
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when()
.get(templateUrl).andReturn().asString();
Assert.notNull(json, "json");
ArrayList<ReportData> reportsList = new ArrayList<>();
String reportsString = new Gson().toJson(from(json).get(jsonAttributeToGetBack));
Assert.notNull(reportsString, "reportsString");
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);
return reportsList;
}
@@ -187,7 +197,9 @@ public class CampaignsHelper {
if (reports != null && !reports.isEmpty()) {
for (ReportData reportData : reports) {
if (reportName.equals(reportData.getReportName())) { return reportData.getReportId(); }
if (reportName.equals(reportData.getReportName())) {
return reportData.getReportId();
}
}
}
Assert.notNull(null, "null");
@@ -31,10 +31,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
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_SELECTED = CURRENCY_URL + "&fields=selectedCurrencyOptions";
@@ -59,19 +61,19 @@ public class CurrencyHelper {
return getCurrencies(CURRENCY_URL_SELECTED, permittedCurrencyArraySelected);
}
private ArrayList<Currency> getCurrencies(final String getUrl, final List<String> permittedCurrencyArrays) {
System.out.println("--------------------------------- GET CURRENCY OPTIONS -------------------------------");
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when()
.get(getUrl).andReturn().asString();
LOG.info("--------------------------------- GET CURRENCY OPTIONS -------------------------------");
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getUrl)
.andReturn().asString();
final Gson gson = new Gson();
Assert.notNull(json, "json");
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);
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");
for(Currency currency : entry.getValue()) {
for (Currency currency : entry.getValue()) {
currencyList.add(currency);
}
}
@@ -79,13 +81,14 @@ public class CurrencyHelper {
}
public List<String> updateCurrencies(final List<String> currencies) {
System.out.println("--------------------------------- UPDATE CURRENCY OPTIONS -------------------------------");
final String json = given().spec(requestSpec).body(getUpdateJSON(currencies)).expect().spec(responseSpec).log().ifError().when()
.put(CURRENCY_URL).andReturn().asString();
LOG.info("--------------------------------- UPDATE CURRENCY OPTIONS -------------------------------");
final String json = given().spec(requestSpec).body(getUpdateJSON(currencies)).expect().spec(responseSpec).log()
.ifError().when().put(CURRENCY_URL).andReturn().asString();
final Gson gson = new Gson();
Assert.notNull(json, "json");
final Type typeOfHashMap = new TypeToken<Map<String,Map<String, List<String>>>>() { }.getType();
final Map<String,Map<String, List<String>>> responseMap = gson.fromJson(json, typeOfHashMap);
final Type typeOfHashMap = new TypeToken<Map<String, Map<String, List<String>>>>() {
}.getType();
final Map<String, Map<String, List<String>>> responseMap = gson.fromJson(json, typeOfHashMap);
return responseMap.get("changes").get("currencies");
}
@@ -23,9 +23,11 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EntityDatatableChecksHelper {
private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -59,7 +61,7 @@ public class EntityDatatableChecksHelper {
map.put("productId", productId);
}
String requestJsonString = new Gson().toJson(map);
System.out.println("map : " + requestJsonString);
LOG.info("map : {}" , requestJsonString);
return requestJsonString;
}
@@ -42,6 +42,8 @@ import org.apache.fineract.integrationtests.common.system.DatatableHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Entity Datatable Checks Integration Test for checking Creation, Deletion and
@@ -49,7 +51,7 @@ import org.junit.Test;
*/
public class EntityDatatableChecksIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksIntegrationTest.class);
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
private EntityDatatableChecksHelper entityDatatableChecksHelper;
@@ -407,7 +409,7 @@ public class EntityDatatableChecksIntegrationTest {
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance,
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();
if (allowOverdraft) {
final String overDraftLimit = "2000.0";
@@ -433,7 +435,7 @@ public class EntityDatatableChecksIntegrationTest {
}
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() //
.withPrincipal("10000000.00") //
.withNumberOfRepayments("24") //
@@ -450,7 +452,7 @@ public class EntityDatatableChecksIntegrationTest {
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment,
final String registeredTableName) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000000.00") //
.withLoanTermFrequency("24") //
@@ -471,7 +473,7 @@ public class EntityDatatableChecksIntegrationTest {
private Object applyForLoanApplicationWithError(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment,
final String responseAttribute) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000000.00") //
.withLoanTermFrequency("24") //
@@ -26,9 +26,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 CREATE_STAFF_URL = "/fineract-provider/api/v1/staff";
@@ -46,7 +48,7 @@ public class StaffHelper {
final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffToTransferId);
map.put("note", note);
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
@@ -97,7 +99,7 @@ public class StaffHelper {
map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy");
map.put("joiningDate", "20 September 2011") ;
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
@@ -119,7 +121,7 @@ public class StaffHelper {
if(fieldList.contains("mobileNo")) {
map.put("mobileNo", "+123515198");
}
System.out.println("map : " + map);
LOG.info("map : {}" , map);
return new Gson().toJson(map);
}
}
@@ -29,20 +29,24 @@ import java.util.HashMap;
import java.util.Locale;
import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" })
public class RecurringDepositAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositAccountHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
public RecurringDepositAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
public RecurringDepositAccountHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
}
private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/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 UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND = "undoapproval";
private static final String REJECT_RECURRING_DEPOSIT_COMMAND = "reject";
@@ -140,21 +144,22 @@ public class RecurringDepositAccountHelper {
map.put("isCalendarInherited", this.isCalendarInherited);
String recurringDepositAccountJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountJson);
LOG.info("{}", recurringDepositAccountJson);
return recurringDepositAccountJson;
}
public static Integer applyRecurringDepositApplication(final String recurringDepositAccountAsJson,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
System.out.println("--------------------- APPLYING FOR RECURRING DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_RECURRING_DEPOSIT_ACCOUNT_URL, recurringDepositAccountAsJson,
CommonConstants.RESPONSE_RESOURCE_ID);
LOG.info("--------------------- APPLYING FOR RECURRING DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_RECURRING_DEPOSIT_ACCOUNT_URL,
recurringDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID);
}
public static HashMap getRecurringDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer accountID) {
final String GET_RECURRING_DEPOSIT_BY_ID_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RETRIEVING RECURRING DEPOSIT ACCOUNT BY ID -------------------------");
public static HashMap getRecurringDepositAccountById(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer accountID) {
final String GET_RECURRING_DEPOSIT_BY_ID_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING RECURRING DEPOSIT ACCOUNT BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_RECURRING_DEPOSIT_BY_ID_URL, "");
}
@@ -202,7 +207,7 @@ public class RecurringDepositAccountHelper {
principal += totalInterest;
}
totalInterest = 0.0f;
System.out.println(principal);
LOG.info("{}", principal.toString());
}
currentDate.add(Calendar.MONTH, 1);
@@ -212,7 +217,8 @@ public class RecurringDepositAccountHelper {
}
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);
Calendar todaysDate = Calendar.getInstance();
@@ -220,128 +226,155 @@ public class RecurringDepositAccountHelper {
todaysDate.add(Calendar.DATE, -1);
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
final String EXPECTED_FIRST_DEPOSIT_ON_ON_DATE = SUBMITTED_ON_DATE;
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec)
.withSubmittedOnDate(SUBMITTED_ON_DATE).withExpectedFirstDepositOnDate(EXPECTED_FIRST_DEPOSIT_ON_ON_DATE)
.build(clientID, productID, penalInterestType);
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec,
this.responseSpec).withSubmittedOnDate(SUBMITTED_ON_DATE)
.withExpectedFirstDepositOnDate(EXPECTED_FIRST_DEPOSIT_ON_ON_DATE)
.build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
return Utils.performServerPut(this.requestSpec, this.responseSpec,
RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
}
public HashMap updateInterestCalculationConfigForRecurringDeposit(final String clientID, final String productID,
final String accountID, final String submittedOnDate, final String validFrom, final String validTo,
final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType,
final String interestCompoundingPeriodType, final String interestPostingPeriodType, final String expectedFirstDepositOnDate) {
final String interestCompoundingPeriodType, final String interestPostingPeriodType,
final String expectedFirstDepositOnDate) {
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) //
.withNumberOfDaysPerYear(numberOfDaysPerYear) //
.withInterestCalculationPeriodType(interestCalculationType) //
.withInterestCompoundingPeriodType(interestCompoundingPeriodType) //
.withInterestPostingPeriodType(interestPostingPeriodType) //
.withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) //
.build(clientID, productID, penalInterestType);
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec,
this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) //
.withNumberOfDaysPerYear(numberOfDaysPerYear) //
.withInterestCalculationPeriodType(interestCalculationType) //
.withInterestCompoundingPeriodType(interestCompoundingPeriodType) //
.withInterestPostingPeriodType(interestPostingPeriodType) //
.withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) //
.build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
return Utils.performServerPut(this.requestSpec, this.responseSpec,
RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
}
public Integer updateTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate,
final Float transactionAmount) {
System.out.println("--------------------------------- UPDATE RECURRING DEPOSIT TRANSACTION ------------------------------------");
return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID
+ "/transactions/" + transactionId + "?command=" + MODIFY_TRANSACTION_COMMAND,
public Integer updateTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId,
final String transactionDate, final Float transactionAmount) {
LOG.info(
"--------------------------------- UPDATE RECURRING DEPOSIT TRANSACTION ------------------------------------");
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);
}
public Integer undoTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate,
final Float transactionAmount) {
System.out.println("--------------------------------- UNDO RECURRING DEPOSIT TRANSACTION ------------------------------------");
return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID
+ "/transactions/" + transactionId + "?command=" + UNDO_TRANSACTION_COMMAND,
public Integer undoTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId,
final String transactionDate, final Float transactionAmount) {
LOG.info(
"--------------------------------- UNDO RECURRING DEPOSIT TRANSACTION ------------------------------------");
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);
}
public HashMap approveRecurringDeposit(final Integer recurringDepositAccountID, final String approvedOnDate) {
System.out
.println("--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------");
LOG.info(
"--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------");
return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(APPROVE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
getApproveRecurringDepositAccountAsJSON(approvedOnDate));
}
public HashMap undoApproval(final Integer recurringDepositAccountID) {
System.out
.println("--------------------------------- UNDO APPROVING RECURRING DEPOSIT APPLICATION -------------------------------");
LOG.info(
"--------------------------------- UNDO APPROVING RECURRING DEPOSIT APPLICATION -------------------------------");
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
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) {
System.out.println("--------------------------------- REJECT RECURRING DEPOSIT APPLICATION -------------------------------");
LOG.info(
"--------------------------------- REJECT RECURRING DEPOSIT APPLICATION -------------------------------");
return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(REJECT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
getRejectedRecurringDepositAsJSON(rejectedOnDate));
}
public HashMap withdrawApplication(final Integer recurringDepositAccountID, final String withdrawApplicationOnDate) {
System.out.println("--------------------------------- WITHDRAW RECURRING DEPOSIT APPLICATION -------------------------------");
public HashMap withdrawApplication(final Integer recurringDepositAccountID,
final String withdrawApplicationOnDate) {
LOG.info(
"--------------------------------- WITHDRAW RECURRING DEPOSIT APPLICATION -------------------------------");
return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
createRecurringDepositOperationURL(WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND,
recurringDepositAccountID),
getWithdrawnRecurringDepositAccountAsJSON(withdrawApplicationOnDate));
}
public HashMap activateRecurringDeposit(final Integer recurringDepositAccountID, final String activationDate) {
System.out
.println("---------------------------------- ACTIVATING RECURRING DEPOSIT APPLICATION ----------------------------------");
LOG.info(
"---------------------------------- ACTIVATING RECURRING DEPOSIT APPLICATION ----------------------------------");
return performRecurringDepositApplicationActions(
createRecurringDepositOperationURL(ACTIVATE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID),
getActivatedRecurringDepositAccountAsJSON(activationDate));
}
public Object deleteRecurringDepositApplication(final Integer recurringDepositAccountID, final String jsonAttributeToGetBack) {
System.out.println("---------------------------------- DELETE RECURRING DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/"
+ recurringDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
public Object deleteRecurringDepositApplication(final Integer recurringDepositAccountID,
final String jsonAttributeToGetBack) {
LOG.info(
"---------------------------------- DELETE RECURRING DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec,
RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?" + Utils.TENANT_IDENTIFIER,
jsonAttributeToGetBack);
}
public Integer calculateInterestForRecurringDeposit(final Integer recurringDepositAccountId) {
System.out.println("--------------------------------- CALCULATING INTEREST FOR RECURRING DEPOSIT --------------------------------");
LOG.info(
"--------------------------------- CALCULATING INTEREST FOR RECURRING DEPOSIT --------------------------------");
return (Integer) performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId),
createRecurringDepositCalculateInterestURL(CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND,
recurringDepositAccountId),
getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
}
public Integer postInterestForRecurringDeposit(final Integer recurringDepositAccountId) {
System.out.println("--------------------------------- POST INTEREST FOR RECURRING DEPOSIT --------------------------------");
LOG.info(
"--------------------------------- POST INTEREST FOR RECURRING DEPOSIT --------------------------------");
return (Integer) performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(POST_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId),
createRecurringDepositCalculateInterestURL(POST_INTEREST_RECURRING_DEPOSIT_COMMAND,
recurringDepositAccountId),
getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
}
public Integer depositToRecurringDepositAccount(final Integer recurringDepositAccountId, final Float depositAmount,
final String depositedOnDate) {
System.out.println("--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------");
LOG.info(
"--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------");
return (Integer) performRecurringDepositActions(
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) {
System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR RECURRING DEPOSIT ----------------------------");
public HashMap calculatePrematureAmountForRecurringDeposit(final Integer recurringDepositAccountId,
final String closedOnDate) {
LOG.info(
"--------------------- CALCULATING PREMATURE AMOUNT FOR RECURRING DEPOSIT ----------------------------");
return (HashMap) performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, recurringDepositAccountId),
createRecurringDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND,
recurringDepositAccountId),
getCalculatedPrematureAmountForRecurringDepositAccountAsJSON(closedOnDate), "");
}
public Object prematureCloseForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate,
final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) {
System.out.println("--------------------- PREMATURE CLOSE FOR RECURRING DEPOSIT ----------------------------");
LOG.info("--------------------- PREMATURE CLOSE FOR RECURRING DEPOSIT ----------------------------");
return performRecurringDepositActions(
createRecurringDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, recurringDepositAccountId),
getPrematureCloseForRecurringDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack);
getPrematureCloseForRecurringDepositAccountAsJSON(closedOnDate, closureType, toSavingsId),
jsonAttributeToGetBack);
}
private String getApproveRecurringDepositAccountAsJSON(final String approvedOnDate) {
@@ -351,7 +384,7 @@ public class RecurringDepositAccountHelper {
map.put("approvedOnDate", approvedOnDate);
map.put("note", "Approval NOTE");
String recurringDepositAccountApproveJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountApproveJson);
LOG.info(recurringDepositAccountApproveJson);
return recurringDepositAccountApproveJson;
}
@@ -362,7 +395,7 @@ public class RecurringDepositAccountHelper {
map.put("transactionDate", transactionDate);
map.put("transactionAmount", transactionAmount);
String updateTransactionJson = new Gson().toJson(map);
System.out.println(updateTransactionJson);
LOG.info(updateTransactionJson);
return updateTransactionJson;
}
@@ -373,7 +406,7 @@ public class RecurringDepositAccountHelper {
map.put("rejectedOnDate", rejectedOnDate);
map.put("note", "Rejected NOTE");
String recurringDepositAccountJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountJson);
LOG.info("{}", recurringDepositAccountJson);
return recurringDepositAccountJson;
}
@@ -384,7 +417,7 @@ public class RecurringDepositAccountHelper {
map.put("withdrawnOnDate", withdrawnApplicationOnDate);
map.put("note", "Withdraw NOTE");
String recurringDepositAccountJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountJson);
LOG.info("{}", recurringDepositAccountJson);
return recurringDepositAccountJson;
}
@@ -394,14 +427,14 @@ public class RecurringDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("activatedOnDate", activationDate);
String recurringDepositAccountActivateJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountActivateJson);
LOG.info(recurringDepositAccountActivateJson);
return recurringDepositAccountActivateJson;
}
private String getCalculatedInterestForRecurringDepositApplicationAsJSON() {
final HashMap<String, String> map = new HashMap<>();
String recurringDepositAccountCalculatedInterestJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountCalculatedInterestJson);
LOG.info(recurringDepositAccountCalculatedInterestJson);
return recurringDepositAccountCalculatedInterestJson;
}
@@ -411,7 +444,7 @@ public class RecurringDepositAccountHelper {
map.put("dateFormat", CommonConstants.dateFormat);
map.put("closedOnDate", closedOnDate);
String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountPrematureClosureJson);
LOG.info(recurringDepositAccountPrematureClosureJson);
return recurringDepositAccountPrematureClosureJson;
}
@@ -422,12 +455,12 @@ public class RecurringDepositAccountHelper {
map.put("transactionAmount", depositAmount);
map.put("transactionDate", depositedOnDate);
String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountPrematureClosureJson);
LOG.info(recurringDepositAccountPrematureClosureJson);
return recurringDepositAccountPrematureClosureJson;
}
private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate, final String closureType,
final Integer toSavingsId) {
private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate,
final String closureType, final Integer toSavingsId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("locale", CommonConstants.locale);
map.put("dateFormat", CommonConstants.dateFormat);
@@ -438,12 +471,13 @@ public class RecurringDepositAccountHelper {
map.put("transferDescription", "Transferring To Savings Account");
}
String recurringDepositAccountPrematureCloseJson = new Gson().toJson(map);
System.out.println(recurringDepositAccountPrematureCloseJson);
LOG.info(recurringDepositAccountPrematureCloseJson);
return recurringDepositAccountPrematureCloseJson;
}
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,
@@ -452,23 +486,26 @@ public class RecurringDepositAccountHelper {
jsonAttributeToGetBack);
}
private HashMap performRecurringDepositApplicationActions(final String postURLForRecurringDepositAction, final String jsonToBeSent) {
private HashMap performRecurringDepositApplicationActions(final String postURLForRecurringDepositAction,
final String jsonToBeSent) {
HashMap status = null;
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForRecurringDepositAction,
jsonToBeSent, CommonConstants.RESPONSE_CHANGES);
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec,
postURLForRecurringDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES);
if (response != null) {
status = (HashMap) response.get("status");
}
return status;
}
private String createRecurringDepositCalculateInterestURL(final String command, final Integer recurringDepositAccountID) {
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
private String createRecurringDepositCalculateInterestURL(final String command,
final Integer recurringDepositAccountID) {
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
}
private String createDepositToRecurringDepositURL(final String command, final Integer recurringDepositAccountID) {
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command + "&"
+ Utils.TENANT_IDENTIFIER;
return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command
+ "&" + Utils.TENANT_IDENTIFIER;
}
public RecurringDepositAccountHelper withSubmittedOnDate(final String recurringDepositApplicationSubmittedDate) {
@@ -476,7 +513,8 @@ public class RecurringDepositAccountHelper {
return this;
}
public RecurringDepositAccountHelper withExpectedFirstDepositOnDate(final String recurringDepositApplicationExpectedFirstDepositOnDate) {
public RecurringDepositAccountHelper withExpectedFirstDepositOnDate(
final String recurringDepositApplicationExpectedFirstDepositOnDate) {
this.expectedFirstDepositOnDate = recurringDepositApplicationExpectedFirstDepositOnDate;
return this;
}
@@ -491,7 +529,8 @@ public class RecurringDepositAccountHelper {
return this;
}
public RecurringDepositAccountHelper withInterestCompoundingPeriodType(final String interestCompoundingPeriodTypeId) {
public RecurringDepositAccountHelper withInterestCompoundingPeriodType(
final String interestCompoundingPeriodTypeId) {
this.interestCompoundingPeriodType = interestCompoundingPeriodTypeId;
return this;
}
@@ -25,53 +25,55 @@ import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
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";
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"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
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",
getStatus(recurringDepositStatusHashMap, "submittedAndPendingApproval"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
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"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
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"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
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"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
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"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
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"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
public static HashMap getStatusOfRecurringDepositAccount(final RequestSpecification requestSpec,
@@ -82,16 +84,16 @@ public class RecurringDepositAccountStatusChecker {
}
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",
getStatus(recurringDepositStatusHashMap, "prematureClosed"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
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"));
System.out.println(recurringDepositStatusHashMap);
LOG.info("{}",recurringDepositStatusHashMap.toString());
}
private static boolean getStatus(final HashMap recurringDepositStatusMap, final String recurringDepositStatusString) {
@@ -27,10 +27,12 @@ import java.util.List;
import java.util.Map;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.accounting.Account;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" })
public class RecurringDepositProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositProductHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -153,7 +155,7 @@ public class RecurringDepositProductHelper {
}
String RecurringDepositProductCreateJson = new Gson().toJson(map);
System.out.println(RecurringDepositProductCreateJson);
LOG.info("{}",RecurringDepositProductCreateJson);
return RecurringDepositProductCreateJson;
}
@@ -226,14 +228,14 @@ public class RecurringDepositProductHelper {
public static Integer createRecurringDepositProduct(final String recurrungDepositProductCreateJson,
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,
"resourceId");
}
public static ArrayList retrieveAllRecurringDepositProducts(final RequestSpecification requestSpec,
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 + "?"
+ Utils.TENANT_IDENTIFIER, "");
return response;
@@ -241,7 +243,7 @@ public class RecurringDepositProductHelper {
public static HashMap retrieveRecurringDepositProductById(final RequestSpecification requestSpec,
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 HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_RD_PRODUCT_BY_ID_URL, "");
return response;
@@ -249,7 +251,7 @@ public class RecurringDepositProductHelper {
public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec,
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,
"chartSlabs");
return response;
@@ -23,9 +23,11 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 LOAN_REFUND_BY_TRANSFER_URL = "/fineract-provider/api/v1/accounttransfers/refundByTransfer";
private static final String LOCALE = "en_GB";
@@ -45,8 +47,9 @@ public class AccountTransferHelper {
this.responseSpec = responseSpec;
}
public String build(final String fromAccountId, final String fromClientId, final String toAccountId, final String toClientId,
final String fromAccountType, final String toAccountType, final String transferAmount) {
public String build(final String fromAccountId, final String fromClientId, final String toAccountId,
final String toClientId, final String fromAccountType, final String toAccountType,
final String transferAmount) {
final HashMap<String, String> map = new HashMap<>();
map.put("dateFormat", "dd MMMM yyyy");
@@ -63,7 +66,7 @@ public class AccountTransferHelper {
map.put("transferAmount", transferAmount);
map.put("transferDescription", this.transferDescription);
String savingsApplicationJSON = new Gson().toJson(map);
System.out.println(savingsApplicationJSON);
LOG.info("{}", savingsApplicationJSON);
return savingsApplicationJSON;
}
@@ -73,24 +76,26 @@ public class AccountTransferHelper {
}
public Integer accountTransfer(final Integer fromClientId, final Integer fromAccountId, final Integer toClientId,
final Integer toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) {
System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------");
final Integer toAccountId, final String fromAccountType, final String toAccountType,
final String transferAmount) {
LOG.info("--------------------------------ACCOUNT TRANSFER--------------------------------");
final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) //
.withTransferOnDate(ACCOUNT_TRANSFER_DATE) //
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), fromAccountType,
toAccountType, transferAmount);
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER,
accountTransferJSON, "savingsId");
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(),
fromAccountType, toAccountType, transferAmount);
return Utils.performServerPost(this.requestSpec, this.responseSpec,
ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, accountTransferJSON, "savingsId");
}
public Integer refundLoanByTransfer(final String date, final Integer fromClientId, final Integer fromAccountId, final Integer toClientId,
final Integer toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) {
System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------");
public Integer refundLoanByTransfer(final String date, final Integer fromClientId, final Integer fromAccountId,
final Integer toClientId, final Integer toAccountId, final String fromAccountType,
final String toAccountType, final String transferAmount) {
LOG.info("--------------------------------ACCOUNT TRANSFER--------------------------------");
final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) //
.withTransferOnDate(date) //
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), fromAccountType,
toAccountType, transferAmount);
return Utils.performServerPost(this.requestSpec, this.responseSpec, LOAN_REFUND_BY_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER,
accountTransferJSON, "savingsId");
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(),
fromAccountType, toAccountType, transferAmount);
return Utils.performServerPost(this.requestSpec, this.responseSpec,
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 java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class SavingsStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(SavingsStatusChecker.class);
private static final String SAVINGS_ACCOUNT_URL = "/fineract-provider/api/v1/savingsaccounts";
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"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Status: {} \n", savingsStatusHashMap);
}
public static void verifySavingsIsPending(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS PENDING ------------------------------------");
assertTrue("SAVINGS ACCOUNT IS NOT IN PENDING STATE", getStatus(savingsStatusHashMap, "submittedAndPendingApproval"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS PENDING ------------------------------------");
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) {
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"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Status: {} \n", 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"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Status: {} \n", savingsStatusHashMap);
}
public static void verifySavingsIsWithdrawn(final HashMap savingsStatusHashMap) {
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------");
assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "withdrawnByApplicant"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------");
assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION",
getStatus(savingsStatusHashMap, "withdrawnByApplicant"));
LOG.info("Savings Application Status: {}", 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"));
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Status: {}", 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"));
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,
final Integer savingsID) {
final String url = SAVINGS_ACCOUNT_URL+"/" + savingsID + "?"+Utils.TENANT_IDENTIFIER;
public static HashMap getStatusOfSavings(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer savingsID) {
final String url = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, url, "status");
}
public static HashMap getSubStatusOfSavings(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer savingsID) {
final String url = SAVINGS_ACCOUNT_URL+"/" + savingsID + "?"+Utils.TENANT_IDENTIFIER;
public static HashMap getSubStatusOfSavings(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer savingsID) {
final String url = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?" + Utils.TENANT_IDENTIFIER;
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);
}
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"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
}
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"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
}
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"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
}
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"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
}
public static void verifySavingsSubStatusblock(HashMap savingsStatusHashMap) {
System.out.println(
LOG.info(
"\n-------------------------------------- VERIFYING SAVINGS ACCOUNT IS BLOCKED ------------------------------------");
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) {
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"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
}
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"));
System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n");
LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString());
}
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"));
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.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShareAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(ShareAccountHelper.class);
private static final String LOCALE = "en_GB";
private String clientId ;
@@ -96,7 +97,7 @@ public class ShareAccountHelper {
}
String shareAccountCreateJson = new Gson().toJson(map);
System.out.println(shareAccountCreateJson);
LOG.info("{}",shareAccountCreateJson);
return shareAccountCreateJson;
}
@@ -40,9 +40,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShareAccountIntegrationTests {
private final static Logger LOG = LoggerFactory.getLogger(ShareAccountIntegrationTests.class);
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
private ShareProductHelper shareProductHelper;
@@ -59,21 +61,21 @@ public class ShareAccountIntegrationTests {
public void testCreateShareProduct() {
// This method will check create share product, get share product,
// update share product.
System.out.println("------------------------------CREATING NEW SHARE PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW SHARE PRODUCT ---------------------------------------");
shareProductHelper = new ShareProductHelper();
final Integer shareProductId = createShareProduct();
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
.retrieveShareProduct(shareProductId, requestSpec, responseSpec);
Assert.assertNotNull(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<>();
@@ -90,7 +92,7 @@ public class ShareAccountIntegrationTests {
String updatedSharesIssued = String.valueOf(updatedShareProductData.get("totalSharesIssued"));
Assert.assertEquals("2000", updatedTotalShares);
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.joda.time.LocalDate;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShareProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(ShareProductHelper.class);
private static final String NONE = "1";
private static final String CASH_BASED = "2";
private static final String LOCALE = "en_GB";
@@ -94,7 +95,7 @@ public class ShareProductHelper {
}
String shareProductCreateJson = new Gson().toJson(map);
System.out.println(shareProductCreateJson);
LOG.info("{}",shareProductCreateJson);
return shareProductCreateJson;
}
@@ -23,9 +23,11 @@ import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AccountNumberPreferencesHelper {
private final static Logger LOG = LoggerFactory.getLogger(AccountNumberPreferencesHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -41,8 +43,7 @@ public class AccountNumberPreferencesHelper {
public Object createClientAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out
.println("---------------------------------CREATING CLIENT ACCOUNT NUMBER PREFERENCE------------------------------------------");
LOG.info("---------------------------------CREATING CLIENT ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder()
.clientBuild();
@@ -56,8 +57,7 @@ public class AccountNumberPreferencesHelper {
public Object createLoanAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out
.println("---------------------------------CREATING LOAN ACCOUNT NUMBER PREFERENCE------------------------------------------");
LOG.info("---------------------------------CREATING LOAN ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder()
.loanBuild();
@@ -70,8 +70,7 @@ public class AccountNumberPreferencesHelper {
public Object createSavingsAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out
.println("---------------------------------CREATING SAVINGS ACCOUNT NUMBER PREFERENCE------------------------------------------");
LOG.info("---------------------------------CREATING SAVINGS ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder()
.savingsBuild();
@@ -85,8 +84,7 @@ public class AccountNumberPreferencesHelper {
public Object createGroupsAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out
.println("---------------------------------CREATING GROUPS ACCOUNT NUMBER PREFERENCE------------------------------------------");
LOG.info("---------------------------------CREATING GROUPS ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder()
.groupsBuild();
@@ -100,8 +98,7 @@ public class AccountNumberPreferencesHelper {
public Object createCenterAccountNumberPreference(
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out
.println("---------------------------------CREATING CENTER ACCOUNT NUMBER PREFERENCE------------------------------------------");
LOG.info("---------------------------------CREATING CENTER ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String requestJSON = new AccountNumberPreferencesTestBuilder()
.centerBuild();
@@ -146,8 +143,7 @@ public class AccountNumberPreferencesHelper {
final Integer accountNumberFormatId,
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
System.out
.println("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE------------------------------------------");
LOG.info("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE------------------------------------------");
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
+ accountNumberFormatId + "?" + Utils.TENANT_IDENTIFIER;
@@ -27,9 +27,11 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DatatableHelper {
private final static Logger LOG = LoggerFactory.getLogger(DatatableHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -58,7 +60,7 @@ public class DatatableHelper {
public static void verifyDatatableCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
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 + "/"
+ generatedDatatableName + "?" + Utils.TENANT_IDENTIFIER, "registeredTableName");
assertEquals("ERROR IN CREATING THE DATATABLE", generatedDatatableName, responseRegisteredTableName);
@@ -76,7 +78,7 @@ public class DatatableHelper {
addDatatableColumns(datatableColumnsList, "Date of Approval", "Date", false, null);
map.put("columns", datatableColumnsList);
String requestJsonString = new Gson().toJson(map);
System.out.println("map : " + requestJsonString);
LOG.info("map : {}" , requestJsonString);
return requestJsonString;
}
@@ -45,9 +45,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GuarantorTest {
private final static Logger LOG = LoggerFactory.getLogger(GuarantorTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
@@ -146,7 +148,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_2, null);
Assert.assertNotNull(externalGuarantee_2);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -157,14 +159,14 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0));
verifySavingsOnHoldBalance(externalSavigsId_1, 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);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -172,7 +174,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, external1_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);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -303,7 +305,7 @@ public class GuarantorTest {
Assert.assertNotNull(externalGuarantee_2);
verifySavingsOnHoldBalance(externalSavigsId_2, null);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -314,14 +316,14 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0));
verifySavingsOnHoldBalance(externalSavigsId_1, 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);
LoanStatusChecker.verifyLoanIsApproved(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);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -457,7 +459,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, null);
Assert.assertNotNull(externalGuarantee_1);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -466,7 +468,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(selfSavigsId, self1_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);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -530,7 +532,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(externalSavigsId_1, null);
Assert.assertNotNull(externalGuarantee_1);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -539,7 +541,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(selfSavigsId, self1_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);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -599,7 +601,7 @@ public class GuarantorTest {
Assert.assertNotNull(externalGuarantee_1);
verifySavingsOnHoldBalance(externalSavigsId_1, null);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
@@ -608,7 +610,7 @@ public class GuarantorTest {
verifySavingsOnHoldBalance(selfSavigsId, self1_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);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -660,7 +662,7 @@ public class GuarantorTest {
private Integer createLoanProductWithHoldFunds(final String mandatoryGuarantee, final String minimumGuaranteeFromGuarantor,
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")
.withRepaymentAfterEvery("1").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance()
@@ -671,7 +673,7 @@ public class GuarantorTest {
}
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() //
.withPrincipal("10000.00") //
.withLoanTermFrequency("4") //
@@ -21,9 +21,11 @@ package org.apache.fineract.integrationtests.loanaccount.guarantor;
import com.google.gson.Gson;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GuarantorTestBuilder {
private final static Logger LOG = LoggerFactory.getLogger(GuarantorTestBuilder.class);
private static final String GUARANTOR_TYPE_CUSTOMER = "1";
@SuppressWarnings("unused")
private static final String GUARANTOR_TYPE_STAFF = "2";
@@ -57,7 +59,7 @@ public class GuarantorTestBuilder {
map.put("amount", guaranteeAmount);
map.put("savingsId", savingsId);
}
System.out.println("map : " + map);
LOG.info("map : {}" , 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.loans.LoanApplicationTestBuilder;
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"rawtypes", "unchecked"})
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) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") //
@@ -51,7 +53,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
}
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() //
.withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") //
@@ -69,7 +71,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
}
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() //
.withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") //
@@ -88,7 +90,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges,
final String savingsId, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) //
.withLoanTermFrequency("4") //
@@ -108,7 +110,7 @@ public class VariableInstallmentsDecliningBalanceHelper {
public static String applyForLoanApplicationWithEqualPrincipal(final Integer clientID, final Integer loanProductID, List<HashMap> charges,
final String savingsId, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) //
.withLoanTermFrequency("4") //
@@ -30,12 +30,14 @@ import java.util.Map;
import org.apache.fineract.integrationtests.common.accounting.Account;
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"rawtypes", "unchecked"})
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) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") //
@@ -55,7 +57,7 @@ public class VariableInstallmentsFlatHelper {
public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List<HashMap> charges,
final String savingsId, String principal) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal(principal) //
.withLoanTermFrequency("4") //
@@ -33,11 +33,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"rawtypes", "unchecked"})
public class VariableInstallmentsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(VariableInstallmentsIntegrationTest.class);
private static final String NONE = "1";
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
@@ -56,7 +57,7 @@ public class VariableInstallmentsIntegrationTest {
public void testVariableLoanProductCreation() {
final String json = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE);
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, "") ;
Assert.assertTrue((Boolean)loanProduct.get("allowVariableInstallments")) ;
Assert.assertEquals(Integer.valueOf(5), loanProduct.get("minimumGap")) ;
@@ -68,7 +69,7 @@ public class VariableInstallmentsIntegrationTest {
public void testLoanProductCreation() {
final String josn = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithoutVaribleConfig(false, NONE);
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, "") ;
Assert.assertTrue(!(Boolean)loanProduct.get("allowVariableInstallments")) ;
}
@@ -22,10 +22,13 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;
public abstract class ApplicationExitUtil {
public abstract class ApplicationExitUtil {
private final static Logger LOG = LoggerFactory.getLogger(ApplicationExitUtil.class);
private ApplicationExitUtil() {}
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
// mysqld won't be stopped, so:
// (@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:
// (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429)
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.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Exception with multiple root causes.
@@ -41,7 +43,7 @@ import java.util.List;
* @author Michael Vorburger.ch <mike@vorburger.ch>
*/
public class MultiException extends Exception {
private final static Logger LOG = LoggerFactory.getLogger(MultiException.class);
private final List<Throwable> throwables;
public MultiException(List<Throwable> problems) {
@@ -71,10 +73,10 @@ public class MultiException extends Exception {
@Override
public void printStackTrace() {
System.err.println(super.getMessage());
LOG.info("{}", super.getMessage());
int i = 0;
for (Throwable e : throwables) {
System.err.print(++i + ".");
LOG.info("{}.",++i);
e.printStackTrace();
}
}
@@ -30,7 +30,8 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import org.apache.commons.lang3.StringUtils;
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")
public class Utils {
private final static Logger LOG = LoggerFactory.getLogger(Utils.class);
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;
@@ -56,7 +57,7 @@ public class Utils {
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
try {
System.out.println("-----------------------------------LOGIN-----------------------------------------");
LOG.info("-----------------------------------LOGIN-----------------------------------------");
final String json = RestAssured.post(LOGIN_URL).asString();
assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false));
return JsonPath.with(json).get("base64EncodedAuthenticationKey");
@@ -43,12 +43,14 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@RunWith(MockitoJUnitRunner.class)
public class XBRLBuilderTest {
private final static Logger LOG = LoggerFactory.getLogger(XBRLBuilderTest.class);
@Mock
private NamespaceReadPlatformServiceImpl readNamespaceService;
@@ -58,8 +60,8 @@ public class XBRLBuilderTest {
@Before
public void setUp() {
this.readNamespaceService = Mockito.mock(NamespaceReadPlatformServiceImpl.class);
lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString())).thenReturn(
new NamespaceData(1l, "mockedprefix", "mockedurl"));
lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString()))
.thenReturn(new NamespaceData(1l, "mockedprefix", "mockedurl"));
}
@Test
@@ -68,10 +70,12 @@ public class XBRLBuilderTest {
final MixTaxonomyData data1 = Mockito.mock(MixTaxonomyData.class);
when(data1.getName()).thenReturn("Assets");
map.put(data1, new BigDecimal(10000));
final String result = this.xbrlBuilder.build(map, Date.valueOf("2005-11-11"), Date.valueOf("2013-07-17"), "USD");
System.out.println(result);
NodeList nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))).getElementsByTagName("Assets");
final String result = this.xbrlBuilder.build(map, Date.valueOf("2005-11-11"), Date.valueOf("2013-07-17"),
"USD");
LOG.info("{}", result);
NodeList nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8)))
.getElementsByTagName("Assets");
assertNotNull(nodes);
assertNotNull(nodes.item(0));
assertEquals("Assets", nodes.item(0).getNodeName());
@@ -22,13 +22,15 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.listener.SessionAwareMessageListener;
public class Listener implements SessionAwareMessageListener {
private final static Logger LOG = LoggerFactory.getLogger(Listener.class);
@Override
public void onMessage(Message message, Session session) throws JMSException {
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.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
@@ -36,7 +38,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
})
@RunWith(SpringJUnit4ClassRunner.class)
public class SenderTest {
private final static Logger LOG = LoggerFactory.getLogger(SenderTest.class);
@Autowired
private JmsTemplate jmsTemplate;
@@ -68,7 +70,7 @@ public class SenderTest {
jmsTemplate.send(mockQueue, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
System.out.println("Message send successfully");
LOG.info("Message send successfully");
return session.createObjectMessage(notificationData);
}
});