bulk auto reformat ca. 2900 files using ./gradlew :spotlessApply [FINERACT-1006]

This commit is contained in:
Michael Vorburger
2020-06-14 18:31:47 +02:00
committed by Michael Vorburger ⛑️
parent 89e321acaf
commit 9da5932307
2899 changed files with 44572 additions and 46101 deletions
+51 -51
View File
@@ -119,7 +119,7 @@ dependencyManagement {
// FINERACT-940 && FINERACT-966 https://github.com/spotbugs/spotbugs/issues/1128
exclude 'xpp3:xpp3'
exclude 'pull-parser:pull-parser'
}
}
dependencySet(group: 'com.sun.jersey', version: jerseyVersion) {
entry 'jersey-core'
@@ -156,8 +156,8 @@ project.ext.mysqlPassword='mysql'
group = 'org.apache.fineract'
buildDir = new File(rootProject.projectDir, "../build")
repositories {
jcenter()
// mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds)
jcenter()
// mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds)
}
// If we are running Gradle within Eclipse to enhance classes with OpenJPA,
@@ -167,7 +167,7 @@ if (project.hasProperty('env') && project.getProperty('env') == 'eclipse')
sourceSets.main.java.outputDir = new File(rootProject.projectDir, "bin/main")
}
eclipse
eclipse
{
project {
buildCommand([ LaunchConfigHandle: "<project>/.externalToolBuilders/OpenJPA Enhance Builder.launch" ], 'org.eclipse.ui.externaltools.ExternalToolBuilder')
@@ -206,12 +206,12 @@ spotless {
java {
importOrder() //sort imports alphabetically
removeUnusedImports()
removeUnusedImports()
eclipse().configFile '../config/fineractdev-formatter.xml'
endWithNewline()
trimTrailingWhitespace()
}
lineEndings 'UNIX'
}
@@ -299,25 +299,25 @@ rat {
}
configurations {
providedRuntime // needed for Spring Boot executable WAR
providedRuntime // needed for Spring Boot executable WAR
providedCompile
compile() {
exclude module: 'hibernate-entitymanager'
exclude module: 'hibernate-validator'
exclude module: 'activation'
exclude module: 'bcmail-jdk14'
exclude module: 'bcprov-jdk14'
exclude module: 'bctsp-jdk14'
exclude module: 'c3p0'
exclude module: 'stax-api'
exclude module: 'jaxb-api'
exclude module: 'jaxb-impl'
exclude module: 'jboss-logging'
exclude module: 'itext-rtf'
exclude module: 'classworlds'
}
runtime
all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord
compile() {
exclude module: 'hibernate-entitymanager'
exclude module: 'hibernate-validator'
exclude module: 'activation'
exclude module: 'bcmail-jdk14'
exclude module: 'bcprov-jdk14'
exclude module: 'bctsp-jdk14'
exclude module: 'c3p0'
exclude module: 'stax-api'
exclude module: 'jaxb-api'
exclude module: 'jaxb-impl'
exclude module: 'jboss-logging'
exclude module: 'itext-rtf'
exclude module: 'classworlds'
}
runtime
all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord
}
tasks.withType(JavaCompile) {
@@ -489,21 +489,21 @@ pmd {
*/
war {
from('../licenses/binary/') { // notice the parens
into "WEB-INF/licenses/binary/" // no leading slash
}
from('../LICENSE_RELEASE') { // notice the parens
into "WEB-INF/" // no leading slash
}
from('../NOTICE_RELEASE') { // notice the parens
into "WEB-INF/" // no leading slash
}
rename ('LICENSE_RELEASE', 'LICENSE')
rename ('NOTICE_RELEASE', 'NOTICE')
from('../licenses/binary/') { // notice the parens
into "WEB-INF/licenses/binary/" // no leading slash
}
from('../LICENSE_RELEASE') { // notice the parens
into "WEB-INF/" // no leading slash
}
from('../NOTICE_RELEASE') { // notice the parens
into "WEB-INF/" // no leading slash
}
rename ('LICENSE_RELEASE', 'LICENSE')
rename ('NOTICE_RELEASE', 'NOTICE')
from('../DISCLAIMER') { // notice the parens
into "WEB-INF/" // no leading slash
}
from('../DISCLAIMER') { // notice the parens
into "WEB-INF/" // no leading slash
}
war.finalizedBy(bootWar)
}
@@ -588,7 +588,7 @@ if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
sourceSets {
integrationTest {
compileClasspath += main.output + test.output
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
@@ -608,20 +608,20 @@ task integrationTest(type:Test) {
}
integrationTest {
useJUnitPlatform()
testLogging { // FINERACT-927
events "skipped", "failed"
showStandardStreams = false
exceptionFormat "full"
}
useJUnitPlatform()
testLogging { // FINERACT-927
events "skipped", "failed"
showStandardStreams = false
exceptionFormat "full"
}
}
test {
useJUnitPlatform()
testLogging { // FINERACT-927
events "skipped", "failed"
showStandardStreams = false
exceptionFormat "full"
}
useJUnitPlatform()
testLogging { // FINERACT-927
events "skipped", "failed"
showStandardStreams = false
exceptionFormat "full"
}
}
@@ -47,7 +47,7 @@
<property name="fileExtensions" value="java"/>
</module>
-->
<module name="TreeWalker">
<module name="SuppressWarningsHolder" />
<module name="RegexpSinglelineJava">
@@ -114,7 +114,7 @@
</module>
<module name="UpperEll"/>
<module name="NeedBraces"/>
<module name="ArrayTypeStyle"/>
<module name="ArrayTypeStyle"/>
<module name="NoLineWrap"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
@@ -144,14 +144,14 @@
<module name="MutableException"/>
<module name="com.github.sevntu.checkstyle.checks.coding.AvoidHidingCauseExceptionCheck" />
<module name="OuterTypeFilename"/>
<module name="LeftCurly" />
<module name="RightCurly">
<property name="option" value="alone"/>
@@ -168,12 +168,12 @@
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="ParenPad" />
<module name="MultipleVariableDeclarations"/>
<module name="MissingSwitchDefault"/>
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="EmptyLineSeparator">
@@ -211,7 +211,7 @@
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ConstantName" />
<module name="NoFinalizer"/>
<module name="GenericWhitespace">
+20 -20
View File
@@ -22,12 +22,12 @@ dependencies {
spotbugsPlugins "jp.skypencil.findbugs.slf4j:bug-pattern:1.5.0@jar"
spotbugs 'com.github.spotbugs:spotbugs:4.0.4'
// Never use "compile" scope, but make all dependencies either 'implementation', 'runtimeOnly' or 'testCompile'.
// Note that we never use 'api', because Fineract at least currently is a simple monolithic application ("WAR"), not a library.
// We also (normally should have) no need to ever use 'compileOnly'.
// Never use "compile" scope, but make all dependencies either 'implementation', 'runtimeOnly' or 'testCompile'.
// Note that we never use 'api', because Fineract at least currently is a simple monolithic application ("WAR"), not a library.
// We also (normally should have) no need to ever use 'compileOnly'.
// implementation dependencies are directly used (compiled against) in src/main (and src/test)
//
// implementation dependencies are directly used (compiled against) in src/main (and src/test)
//
implementation(
//'ch.vorburger.mariaDB4j:mariaDB4j:2.4.0',
@@ -79,50 +79,50 @@ dependencies {
'com.github.spotbugs:spotbugs-annotations',
)
implementation ('io.swagger:swagger-jersey-jaxrs') {
exclude group: 'javax.validation'
exclude group: 'javax.validation'
}
implementation ('org.apache.activemq:activemq-broker') {
exclude group: 'org.apache.geronimo.specs'
}
implementation ('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.hibernate'
exclude group: 'org.hibernate'
}
implementation ('org.apache.openjpa:openjpa') {
exclude group: 'org.eclipse.persistence'
exclude group: 'org.apache.geronimo.specs'
}
implementation ('org.apache.openjpa:openjpa') {
exclude group: 'org.eclipse.persistence'
exclude group: 'org.apache.geronimo.specs'
}
implementation ('org.quartz-scheduler:quartz') {
exclude group: 'com.zaxxer', module: 'HikariCP-java7'
}
implementation ('com.amazonaws:aws-java-sdk-s3') {
exclude group: 'commons-logging'
exclude group: 'commons-logging'
}
implementation ('org.mnode.ical4j:ical4j') {
exclude group: 'commons-logging'
exclude group: 'commons-logging'
}
implementation ('org.ehcache:ehcache') {
exclude group: 'org.glassfish.jaxb', module: 'jaxb-runtime'
}
// runtimeOnly dependencies are things that Fineract code has no direct compile time dependency on, but which must be present at run-time
runtimeOnly(
// runtimeOnly dependencies are things that Fineract code has no direct compile time dependency on, but which must be present at run-time
runtimeOnly(
'org.apache.bval:org.apache.bval.bundle',
'org.springframework.boot:spring-boot-starter-actuator',
// Although fineract (at the time of writing) doesn't have any compile time dep. on httpclient,
// it's useful to have this for the Spring Boot TestRestTemplate http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-rest-templates-test-utility
'org.apache.httpcomponents:httpclient',
)
)
// testCompile dependencies are ONLY used in src/test and/or src/integrationTest, not src/main.
// Do NOT repeat dependencies which are ALREADY in implementation or runtimeOnly!
//
// testCompile dependencies are ONLY used in src/test and/or src/integrationTest, not src/main.
// Do NOT repeat dependencies which are ALREADY in implementation or runtimeOnly!
//
testImplementation( 'org.mockito:mockito-core',
'org.mockito:mockito-junit-jupiter',
'org.junit.platform:junit-platform-runner', // required to be able to run tests directly under Eclipse, see FINERACT-943 & FINERACT-1021
'io.github.classgraph:classgraph',
'org.awaitility:awaitility'
)
)
testImplementation ('io.rest-assured:rest-assured') {
exclude group: 'commons-logging'
exclude group: 'org.apache.sling'
@@ -26,4 +26,4 @@ management.info.git.mode=FULL
# FINERACT-914
server.forward-headers-strategy=framework
spring.cache.jcache.config=classpath:/META-INF/spring/ehcache.xml
spring.cache.jcache.config=classpath:/META-INF/spring/ehcache.xml
@@ -152,10 +152,11 @@ public class AccountNumberPreferencesTest {
Integer id = (Integer) preferenceId.get("id");
HashMap<String, Object> delResponse = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(id, this.responseSpec,
"");
LOG.info("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 */
LOG.info("---------------------------------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, "");
@@ -180,25 +181,25 @@ public class AccountNumberPreferencesTest {
}
private void createAccountNumberPreference() {
this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference(
this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Client (ID: {})",this.clientAccountNumberPreferenceId);
this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
.createClientAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Client (ID: {})", this.clientAccountNumberPreferenceId);
this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createLoanAccountNumberPreference(
this.responseSpec, "resourceId");
this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
.createLoanAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Loan (ID: {} )", this.loanAccountNumberPreferenceId);
this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference(
this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Savings (ID: {})" , this.savingsAccountNumberPreferenceId);
this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
.createSavingsAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Savings (ID: {})", this.savingsAccountNumberPreferenceId);
this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference(
this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Groups (ID: {})" , this.groupsAccountNumberPreferenceId);
this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
.createGroupsAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Groups (ID: {})", this.groupsAccountNumberPreferenceId);
this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference(
this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Center (ID: {})" ,this.centerAccountNumberPreferenceId);
this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
.createCenterAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Center (ID: {})", this.centerAccountNumberPreferenceId);
this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId,
this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId,
@@ -211,10 +212,11 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) {
/* Creating account Preference with duplicate data should fail */
LOG.info("---------------------------------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, "");
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper
.createAccountNumberPreferenceWithInvalidData(this.responseForbiddenError, accountType, prefixType, "");
Assertions.assertEquals("error.msg.account.number.format.duplicate.account.type",
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -224,34 +226,36 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) {
/* Creating account Preference with invalid data should fail */
LOG.info("---------------------------------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, "");
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper
.createAccountNumberPreferenceWithInvalidData(this.responseValidationError, accountType, prefixType, "");
if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals(
"validation.msg.accountNumberFormat.accountType.is.not.within.expected.range")) {
if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)
.equals("validation.msg.accountNumberFormat.accountType.is.not.within.expected.range")) {
Assertions.assertEquals("validation.msg.accountNumberFormat.accountType.is.not.within.expected.range",
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} else if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals(
"validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations")) {
} else if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)
.equals("validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations")) {
Assertions.assertEquals("validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations",
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
}
}
private void updateAccountNumberPreference() {
HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference(
this.clientAccountNumberPreferenceId, "101", this.responseSpec, "");
HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper
.updateAccountNumberPreference(this.clientAccountNumberPreferenceId, "101", this.responseSpec, "");
LOG.info("--------------------------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 */
LOG.info("---------------------------------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",
@@ -260,8 +264,8 @@ public class AccountNumberPreferencesTest {
Assertions.assertEquals("error.msg.resource.not.found", updationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
}
/* Invalid Prefix Type */
HashMap<String, Object> updationError1 = this.accountNumberPreferencesHelper.updateAccountNumberPreference(
this.clientAccountNumberPreferenceId, "103", this.responseValidationError, "");
HashMap<String, Object> updationError1 = this.accountNumberPreferencesHelper
.updateAccountNumberPreference(this.clientAccountNumberPreferenceId, "103", this.responseValidationError, "");
Assertions.assertEquals("validation.msg.validation.errors.exist", updationError1.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -288,8 +292,8 @@ public class AccountNumberPreferencesTest {
this.groupAccountNo = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "accountNo");
if (isAccountPreferenceSetUp) {
String groupsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.groupsAccountNumberPreferenceId, "prefixType.value");
String groupsPrefixName = (String) this.accountNumberPreferencesHelper
.getAccountNumberPreference(this.groupsAccountNumberPreferenceId, "prefixType.value");
if (groupsPrefixName.equals(this.officeName)) {
@@ -313,8 +317,8 @@ public class AccountNumberPreferencesTest {
Assertions.assertTrue(center.getName().equals(name));
if (isAccountPreferenceSetUp) {
String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.centerAccountNumberPreferenceId, "prefixType.value");
String centerPrefixName = (String) this.accountNumberPreferencesHelper
.getAccountNumberPreference(this.centerAccountNumberPreferenceId, "prefixType.value");
final String CENTER_URL = "/fineract-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER;
if (centerPrefixName.equals(this.officeName)) {
@@ -326,7 +330,6 @@ public class AccountNumberPreferencesTest {
}
}
private void createAndValidateClientWithoutAccountPreference() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(this.clientId);
@@ -337,8 +340,8 @@ public class AccountNumberPreferencesTest {
private void createAndValidateClientBasedOnAccountPreference() {
final String codeName = "ClientType";
String clientAccountNo = null;
String clientPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.clientAccountNumberPreferenceId, "prefixType.value");
String clientPrefixName = (String) this.accountNumberPreferencesHelper
.getAccountNumberPreference(this.clientAccountNumberPreferenceId, "prefixType.value");
if (clientPrefixName.equals(this.clientTypeName)) {
/* Retrieve Code id for the Code "ClientType" */
@@ -390,7 +393,7 @@ public class AccountNumberPreferencesTest {
.withInterestRateFrequencyTypeAsYear().build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
LOG.info("Successfully created loan product (ID: {} )" , this.loanProductId);
LOG.info("Successfully created loan product (ID: {} )", this.loanProductId);
}
private void createAndValidateLoanEntity(Boolean isAccountPreferenceSetUp) {
@@ -405,15 +408,15 @@ public class AccountNumberPreferencesTest {
.withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2")
.build(this.clientId.toString(), this.loanProductId.toString(), null);
LOG.info("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,
"accountNo");
if (isAccountPreferenceSetUp) {
String loanPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.loanAccountNumberPreferenceId, "prefixType.value");
String loanPrefixName = (String) this.accountNumberPreferencesHelper
.getAccountNumberPreference(this.loanAccountNumberPreferenceId, "prefixType.value");
if (loanPrefixName.equals(this.officeName)) {
String loanOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "officeName");
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanOfficeName);
@@ -422,10 +425,10 @@ public class AccountNumberPreferencesTest {
this.loanProductId, "shortName");
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanShortName);
}
LOG.info("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);
LOG.info("SUCCESSFULLY CREATED LOAN APPLICATION (ID: {} )",loanId);
LOG.info("SUCCESSFULLY CREATED LOAN APPLICATION (ID: {} )", loanId);
}
}
@@ -449,7 +452,7 @@ public class AccountNumberPreferencesTest {
.withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance)
.withMinimumOpenningBalance(this.MINIMUM_OPENING_BALANCE).build();
this.savingsProductId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec);
LOG.info("Sucessfully created savings product (ID: {} )",this.savingsProductId);
LOG.info("Sucessfully created savings product (ID: {} )", this.savingsProductId);
}
@@ -458,14 +461,14 @@ public class AccountNumberPreferencesTest {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.savingsId = this.savingsAccountHelper
.applyForSavingsApplication(this.clientId, this.savingsProductId, ACCOUNT_TYPE_INDIVIDUAL);
this.savingsId = this.savingsAccountHelper.applyForSavingsApplication(this.clientId, this.savingsProductId,
ACCOUNT_TYPE_INDIVIDUAL);
String savingsAccountNo = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "accountNo");
if (isAccountPreferenceSetUp) {
String savingsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.savingsAccountNumberPreferenceId, "prefixType.value");
String savingsPrefixName = (String) this.accountNumberPreferencesHelper
.getAccountNumberPreference(this.savingsAccountNumberPreferenceId, "prefixType.value");
if (savingsPrefixName.equals(this.officeName)) {
String savingsOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(),
@@ -475,10 +478,10 @@ public class AccountNumberPreferencesTest {
String loanShortName = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "shortName");
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, loanShortName);
}
LOG.info("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);
LOG.info("SUCCESSFULLY CREATED SAVINGS APPLICATION (ID:{} )",this.savingsId);
LOG.info("SUCCESSFULLY CREATED SAVINGS APPLICATION (ID:{} )", this.savingsId);
}
}
}
@@ -127,8 +127,8 @@ public class AccountTransferTest {
*/
@AfterEach
public void tearDown() {
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount(
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper
.deleteFinancialActivityAccount(financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
}
@@ -214,10 +214,10 @@ public class AccountTransferTest {
HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsID);
assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"),
"Verifying To Savings Account Balance after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT),
JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT),
JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] office1LiabilityEntries = {
new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = {
new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -311,10 +311,10 @@ public class AccountTransferTest {
assertEquals(TRANSFER_AMOUNT_ADJUST, toLoanSummaryAfter.get("totalRepayment"),
"Verifying To Loan Repayment Amount after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST),
JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST),
JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] office1LiabilityEntries = {
new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = {
new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -432,10 +432,10 @@ public class AccountTransferTest {
assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"),
"Verifying From Savings Account Balance after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST),
JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST),
JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] office1LiabilityEntries = {
new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = {
new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -68,6 +68,7 @@ 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;
@@ -94,7 +95,8 @@ public class AccountingScenarioIntegrationTest {
Float SP_WITHDRAWAL_AMOUNT = Float.valueOf(WITHDRAWAL_AMOUNT);
Float SP_WITHDRAWAL_AMOUNT_ADJUSTED = Float.valueOf(WITHDRAWAL_AMOUNT_ADJUSTED);
private final String[] REPAYMENT_DATE = { "", "04 May 2011", "04 July 2011", "04 September 2011", "04 November 2011", "04 January 2012" };
private final String[] REPAYMENT_DATE = { "", "04 May 2011", "04 July 2011", "04 September 2011", "04 November 2011",
"04 January 2012" };
private final Float[] REPAYMENT_AMOUNT = { .0f, 2200.0f, 3000.0f, 900.0f, 2000.0f, 2500.0f };
private final Float AMOUNT_TO_BE_WAIVE = 400.0f;
@@ -274,8 +276,8 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountInitialEntry);
this.journalEntryHelper
.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, liablilityAccountInitialEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liablilityAccountInitialEntry);
// First Transaction-Deposit
this.savingsAccountHelper.depositToSavingsAccount(savingsID, DEPOSIT_AMOUNT, SavingsAccountHelper.TRANSACTION_DATE,
@@ -285,10 +287,10 @@ public class AccountingScenarioIntegrationTest {
assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after 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,
JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] assetAccountFirstTransactionEntry = {
new JournalEntry(this.SP_DEPOSIT_AMOUNT, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liabililityAccountFirstTransactionEntry = {
new JournalEntry(this.SP_DEPOSIT_AMOUNT, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountFirstTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liabililityAccountFirstTransactionEntry);
@@ -301,10 +303,10 @@ public class AccountingScenarioIntegrationTest {
assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after 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,
JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] assetAccountSecondTransactionEntry = {
new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] liabililityAccountSecondTransactionEntry = {
new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountSecondTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liabililityAccountSecondTransactionEntry);
@@ -322,16 +324,15 @@ public class AccountingScenarioIntegrationTest {
Float chargeAmount = (Float) paidCharge.get("amount");
// Withdrawal after adding Charge of type Withdrawal Fee
this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsID, WITHDRAWAL_AMOUNT_ADJUSTED,
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsID, WITHDRAWAL_AMOUNT_ADJUSTED, SavingsAccountHelper.TRANSACTION_DATE,
CommonConstants.RESPONSE_RESOURCE_ID);
summary = this.savingsAccountHelper.getSavingsSummary(savingsID);
balance = balance - SP_WITHDRAWAL_AMOUNT_ADJUSTED - chargeAmount;
final JournalEntry[] liabililityAccountThirdTransactionEntry = {
new JournalEntry(chargeAmount, JournalEntry.TransactionType.DEBIT),
final JournalEntry[] liabililityAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] assetAccountThirdTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED,
JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] assetAccountThirdTransactionEntry = {
new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] incomeAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountThirdTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
@@ -464,8 +465,8 @@ public class AccountingScenarioIntegrationTest {
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, RecurringDepositTest.WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
.getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -529,13 +530,14 @@ public class AccountingScenarioIntegrationTest {
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
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec);
return this.fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec,
this.responseSpec);
}
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) {
LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec,
this.responseSpec);
final String recurringDepositProductJSON = recurringDepositProductHelper //
.withPeriodRangeChart()//
.withAccountingRuleAsCashBased(accounts).build(validFrom, validTo);
@@ -554,7 +556,7 @@ public class AccountingScenarioIntegrationTest {
}
@Test
public void checkPeriodicAccrualAccountingFlow() throws InterruptedException,ParseException {
public void checkPeriodicAccrualAccountingFlow() throws InterruptedException, ParseException {
final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -667,7 +669,7 @@ public class AccountingScenarioIntegrationTest {
}
@Test
public void checkPeriodicAccrualAccountingFlow_OVER_PAYMENT() throws InterruptedException,ParseException {
public void checkPeriodicAccrualAccountingFlow_OVER_PAYMENT() throws InterruptedException, ParseException {
final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -715,14 +717,14 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountEntry = { new JournalEntry(15000f, JournalEntry.TransactionType.DEBIT),
new JournalEntry(11000f, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f,
JournalEntry.TransactionType.CREDIT));
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1],
new JournalEntry(4000f, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment Done......");
}
@Test
public void checkPeriodicAccrualAccountingTillCurrentDateFlow() throws InterruptedException,ParseException {
public void checkPeriodicAccrualAccountingTillCurrentDateFlow() throws InterruptedException, ParseException {
final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -738,8 +740,8 @@ public class AccountingScenarioIntegrationTest {
final float PENALTY_PORTION = 100.0f;
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -766,10 +768,8 @@ public class AccountingScenarioIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
this.loanTransactionHelper.addChargesForLoan(
loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
todayDate.add(Calendar.DATE, 1);
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION)));
@@ -814,7 +814,7 @@ public class AccountingScenarioIntegrationTest {
}
@Test
public void checkPeriodicAccrualAccountingAPIFlow() throws ParseException{
public void checkPeriodicAccrualAccountingAPIFlow() throws ParseException {
final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -833,11 +833,11 @@ public class AccountingScenarioIntegrationTest {
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
Integer flatNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_FEE_PORTION), false));
Integer flatNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_FEE_PORTION), false));
Integer flatSpecifiedDueDateNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_PENALTY_PORTION), true));
@@ -866,29 +866,20 @@ public class AccountingScenarioIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
this.loanTransactionHelper.addChargesForLoan(
loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
todayDate.add(Calendar.DATE, 1);
String runOndate = dateFormat.format(todayDate.getTime());
this.loanTransactionHelper
.addChargesForLoan(
loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), runOndate,
String.valueOf(FEE_PORTION)));
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), runOndate, String.valueOf(FEE_PORTION)));
todayDate.add(Calendar.DATE, 1);
this.loanTransactionHelper.addChargesForLoan(
loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDateNext),
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_PENALTY_PORTION)));
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
String.valueOf(flatSpecifiedDueDateNext), dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_PENALTY_PORTION)));
this.loanTransactionHelper.addChargesForLoan(
loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatNext),
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
String.valueOf(flatNext), dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
// CHECK ACCOUNT ENTRIES
LOG.info("Entries ......");
@@ -986,8 +977,8 @@ public class AccountingScenarioIntegrationTest {
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1], new JournalEntry(FIRST_INTEREST,
JournalEntry.TransactionType.CREDIT));
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1],
new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment 1 Done......");
// REPAYMENT 2
@@ -1001,8 +992,8 @@ public class AccountingScenarioIntegrationTest {
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2], new JournalEntry(
SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT));
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2],
new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST
@@ -1053,7 +1044,7 @@ public class AccountingScenarioIntegrationTest {
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
private LocalDate getDateAsLocalDate(String dateAsString) throws ParseException{
private LocalDate getDateAsLocalDate(String dateAsString) throws ParseException {
DateFormat df = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
LocalDate date = new LocalDate(df.parse(dateAsString));
@@ -33,9 +33,8 @@ public class ActuatorIntegrationTest {
@Test
public void testActuatorGitBuildInfo() {
Response response = RestAssured.given()
.headers("Content-Type", ContentType.JSON, "Accept", ContentType.JSON).when()
.get(INFO_URL).then().contentType(ContentType.JSON).extract().response();
Response response = RestAssured.given().headers("Content-Type", ContentType.JSON, "Accept", ContentType.JSON).when().get(INFO_URL)
.then().contentType(ContentType.JSON).extract().response();
Map<String, String> gitBuildInfo = response.jsonPath().getMap("git");
@@ -58,7 +58,8 @@ public class BatchApiTest {
/**
* Sets up the essential settings for the TEST like contentType,
* expectedStatusCode. It uses the '@BeforeEach' annotation provided by jUnit.
* expectedStatusCode. It uses the '@BeforeEach' annotation provided by
* jUnit.
*/
@BeforeEach
public void setup() {
@@ -333,10 +334,10 @@ public class BatchApiTest {
}
/**
* Tests that batch repayment for loans is happening properly.
* Collected properly 200(OK) status was returned for successful responses.
* It first creates a new loan and then makes two repayments for it
* and then verifies that 200(OK) is returned for the repayment requests.
* Tests that batch repayment for loans is happening properly. Collected
* properly 200(OK) status was returned for successful responses. It first
* creates a new loan and then makes two repayments for it and then verifies
* that 200(OK) is returned for the repayment requests.
*
* @see org.apache.fineract.batch.command.internal.RepayLoanCommandStrategy
*/
@@ -482,14 +483,15 @@ public class BatchApiTest {
}
/**
* Test for the successful create client, apply loan,approval and disbursal of a loan using
* Batch API with enclosingTransaction. A '200' status code is expected on successful activation.
* Test for the successful create client, apply loan,approval and disbursal
* of a loan using Batch API with enclosingTransaction. A '200' status code
* is expected on successful activation.
*
* @see org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy
* @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy
*/
@Test
public void shouldReturnOkStatusOnSuccessfulLoanApprovalAndDisburseWithTransaction(){
public void shouldReturnOkStatusOnSuccessfulLoanApprovalAndDisburseWithTransaction() {
final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("10000000.00") //
.withNumberOfRepayments("24") //
@@ -515,7 +517,7 @@ public class BatchApiTest {
// Create a disburseLoan Request
final BatchRequest br4 = BatchHelper.disburseLoanRequest(4744L, 4743L);
final List<BatchRequest> batchRequests = Arrays.asList(br1,br2,br3,br4);
final List<BatchRequest> batchRequests = Arrays.asList(br1, br2, br3, br4);
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
@@ -58,7 +58,8 @@ public class BatchRequestsIntegrationTest {
/**
* Sets up the essential settings for the TEST like contentType,
* expectedStatusCode. It uses the '@BeforeEach' annotation provided by jUnit.
* expectedStatusCode. It uses the '@BeforeEach' annotation provided by
* jUnit.
*/
@BeforeEach
public void setup() {
@@ -91,7 +92,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());
LOG.info("client {} has been added to the group {}",clientIDs[i] , 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
@@ -42,6 +42,7 @@ 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;
@@ -106,8 +107,8 @@ public class CenterIntegrationTest {
Assertions.assertNotNull(paginatedList);
Assertions.assertNotNull(list);
Assertions.assertTrue(Arrays.equals(paginatedList.toArray(new CenterDomain[paginatedList.size()]),
list.toArray(new CenterDomain[list.size()])));
Assertions.assertTrue(
Arrays.equals(paginatedList.toArray(new CenterDomain[paginatedList.size()]), list.toArray(new CenterDomain[list.size()])));
}
@Test
@@ -162,7 +163,7 @@ public class CenterIntegrationTest {
Assertions.assertNotNull(center);
Assertions.assertEquals(newName, center.getName());
Assertions.assertEquals(newExternalId, center.getExternalId());
Assertions.assertEquals((Integer)newStaffId, center.getStaffId());
Assertions.assertEquals((Integer) newStaffId, center.getStaffId());
Assertions.assertArrayEquals(newGroupMembers, center.getGroupMembers());
}
@@ -190,8 +191,8 @@ public class CenterIntegrationTest {
map.put("active", "true");
map.put("activationDate", "04 March 2011");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec, "/fineract-provider/api/v1/groups?"
+ Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec,
"/fineract-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
}
return groupMembers;
}
@@ -200,7 +201,7 @@ public class CenterIntegrationTest {
public void testStaffAssignmentDuringCenterCreation() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating first staff with id------------- {}" , staffId);
LOG.info("--------------creating first staff with id------------- {}", staffId);
Assertions.assertNotNull(staffId);
final int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId);
@@ -214,15 +215,14 @@ public class CenterIntegrationTest {
@Test
public void testAssignStaffToCenter() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating first staff with id------------- {}" , staffId);
LOG.info("--------------creating first staff with id------------- {}", staffId);
Assertions.assertNotNull(staffId);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec,
this.responseSpec, groupID.toString(),
staffId.longValue());
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec,
groupID.toString(), staffId.longValue());
assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent");
final CenterDomain center = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
@@ -235,24 +235,22 @@ public class CenterIntegrationTest {
@Test
public void testUnassignStaffToCenter() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating first staff with id------------- {}" , staffId);
LOG.info("--------------creating first staff with id------------- {}", staffId);
Assertions.assertNotNull(staffId);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec,
this.responseSpec, groupID.toString(),
staffId.longValue());
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec,
groupID.toString(), staffId.longValue());
assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent");
final CenterDomain centerWithStaffAssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
Assertions.assertNotNull(centerWithStaffAssigned);
Assertions.assertTrue(centerWithStaffAssigned.getId().intValue() == groupID);
Assertions.assertTrue(centerWithStaffAssigned.getStaffId().intValue() == staffId);
final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec,
this.responseSpec, groupID.toString(),
staffId.longValue());
final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec, this.responseSpec,
groupID.toString(), staffId.longValue());
assertEquals(unassignStaffToCenterResponseMap.get("staffId"), null, "Verify staffId is null after unassigning ");
final CenterDomain centerWithStaffUnssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
Assertions.assertNotNull(centerWithStaffUnssigned);
File diff suppressed because it is too large Load Diff
@@ -25,6 +25,7 @@ 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) {
@@ -32,36 +33,31 @@ public class ClientStatusChecker {
}
public static void verifyClientClosed(final HashMap<String, Object> clientStatusHashMap) {
LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
LOG.info("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
assertEquals(600, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap);
}
public static void verifyClientPending(final HashMap<String, Object> clientStatusHashMap) {
LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
LOG.info("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
assertEquals(100, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap);
}
public static void verifyClientRejected(final HashMap<String, Object> clientStatusHashMap) {
LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
LOG.info("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
assertEquals(700, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap);
}
public static void verifyClientActiavted(final HashMap<String, Object> clientStatusHashMap) {
LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
LOG.info("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
assertEquals(300, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap);
}
public static void verifyClientWithdrawn(final HashMap<String, Object> clientStatusHashMap) {
LOG.info(
"\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
LOG.info("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
assertEquals(800, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap);
}
@@ -53,8 +53,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
@@ -69,8 +68,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
@@ -93,8 +91,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
@@ -122,8 +119,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
@@ -152,8 +148,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
@@ -182,8 +177,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
@@ -207,8 +201,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
@@ -236,8 +229,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar todaysDate = Calendar.getInstance();
@@ -265,8 +257,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
@@ -297,16 +288,14 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
status = this.clientHelper.withdrawClient(clientId);
ClientStatusChecker.verifyClientWithdrawn(status);
status = this.clientHelper.undoWithdrawn(clientId);
ClientStatusChecker.verifyClientPending(status);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.activateClient(clientId,
CommonConstants.RESPONSE_ERROR);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.activateClient(clientId, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.clients.submittedOnDate.after.reopened.date",
clientErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -315,15 +304,15 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
@Test
public void testReopenedDate() {
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
//final ClientHelper validationErrorHelper = new ClientHelper(this.requestSpec, errorResponse);
// final ClientHelper validationErrorHelper = new
// ClientHelper(this.requestSpec, errorResponse);
// CREATE CLIENT
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId);
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
status = this.clientHelper.withdrawClient(clientId);
@@ -41,6 +41,7 @@ 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;
@@ -75,7 +76,7 @@ public class ConcurrencyIntegrationTest {
date.set(2011, 9, 20);
Float repaymentAmount = 100.0f;
for (int i = 0; i < 10; i++) {
LOG.info("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);
@@ -152,12 +153,13 @@ public class ConcurrencyIntegrationTest {
try {
this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId);
} catch (Exception e) {
LOG.info("Found an exception {}" , e.getMessage());
LOG.info("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);
}
LOG.info("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);
}
}
@@ -73,7 +73,6 @@ public class CurrenciesTest {
currenciestoUpdate.add("USD");
currenciestoUpdate.add("INR");
ArrayList<String> currenciesOutput = CurrenciesHelper.updateSelectedCurrencies(this.requestSpec, this.responseSpec,
currenciestoUpdate);
Assertions.assertNotNull(currenciesOutput);
@@ -92,4 +91,4 @@ public class CurrenciesTest {
Assertions.assertEquals(currenciesBeforeUpdate, currenciesAfterUpdate, "Verifying Do Selected Currencies Match after Updation");
}
}
}
@@ -33,7 +33,6 @@ public class CurrencyIntegrationTest {
private RequestSpecification requestSpec;
private SavingsAccountHelper savingsAccountHelper;
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
@@ -53,362 +53,352 @@ import org.junit.jupiter.api.Test;
@Disabled
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");
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
@BeforeEach
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));
}
@Test
public void testRescheduleJLGLoanSynk() {
// system.out.println("---------------------------------STARTING RESCHEDULE JLG
// LOAN TEST ------------------------------------------");
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
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 groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
final String disbursalDate = groupMeetingDate; // first meeting date
// after group creation
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
final String rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date());
final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
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 disbursalDate = groupMeetingDate; // first meeting date
// after group creation
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 rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date());
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 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 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);
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);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
// system.out.println("---------------------------------CREATING ENTITIES AND
// JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
// Test for loan account is created
Assertions.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
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);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
// 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);
// Test for loan account is created
Assertions.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec,
this.loanId);
// 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);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
// 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
// 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 loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec,
this.loanId);
// 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);
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(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY");
// 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
// system.out.println("---------------------------------CREATING LOAN
// RESCHEDULE
// REQUEST------------------------------------------");
ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
generalResponseSpec, this.loanId);
String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2").updateGraceOnPrincipal("2")
.updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate)
.updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString());
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(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY");
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
// system.out.println("---------------------------------CREATING LOAN RESCHEDULE
// REQUEST------------------------------------------");
String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2")
.updateGraceOnPrincipal("2").updateNewInterestRate(rescheduleInterestRate)
.updateRescheduleFromDate(rescheduleDate).updateSubmittedOnDate(rescheduleSubmittedDate)
.build(this.loanId.toString());
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper
.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
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(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(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT");
// system.out.println("Successfully created loan reschedule request (ID: " +
// this.loanRescheduleRequestId + ")");
// system.out.println("Successfully created loan reschedule request (ID:
// " +
// this.loanRescheduleRequestId + ")");
// system.out.println("-----------------------------APPROVING LOAN RESCHEDULE
// REQUEST--------------------------");
// system.out.println("-----------------------------APPROVING LOAN
// RESCHEDULE
// REQUEST--------------------------");
requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate)
.getApproveLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId,
requestJSON);
requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate)
.getApproveLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper
.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean) response.get("approved"));
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean) response.get("approved"));
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec,
generalResponseSpec, this.loanId);
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(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE");
// system.out.println("Successfully changed group meeting date (CAELNDAR ID: " +
// this.groupCalendarId
// + ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId +
// ")");
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2));
assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE");
// system.out.println("Successfully changed group meeting date (CAELNDAR
// ID: " +
// this.groupCalendarId
// + ") and rescheduled loan (RESCHEDULE ID: " +
// this.loanRescheduleRequestId +
// ")");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec,
this.responseSpecForStatusCode403);
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
}
@Test
public void testChangeGroupMeetingMaturedOnDate() {
// system.out
// .println("---------------------------------STARTING GROUP LOAN
// MEETING CHANGE
// DATE EXPECTED MATURED
// CHANGE------------------------------------------");
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));
}
@Test
public void testChangeGroupMeetingMaturedOnDate() {
// system.out
// .println("---------------------------------STARTING GROUP LOAN MEETING CHANGE
// DATE EXPECTED MATURED CHANGE------------------------------------------");
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
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 groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
final String disbursalDate = groupMeetingDate; // first meeting date
// after group creation
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
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.
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 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.
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);
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);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
// system.out.println("---------------------------------CREATING ENTITIES AND
// JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
// Test for loan account is created
Assertions.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
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);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
// 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);
// Test for loan account is created
Assertions.assertNotNull(this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec,
this.loanId);
// 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);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
// 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
// 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);
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 approved can be disbursed
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), (Integer) expectedMaturityDate.get(1) - 1,
(Integer) expectedMaturityDate.get(2));
// 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
assertEquals(3, expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY");
Calendar expectedMaturityCalendar = Calendar.getInstance();
expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY);
ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper
.getLoanDetail(requestSpec, generalResponseSpec, this.loanId, "timeline"))
.get("expectedMaturityDate"));
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
}
expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0),
(Integer) expectedMaturityDate.get(1) - 1, (Integer) expectedMaturityDate.get(2));
/**
* 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();
assertEquals(3, expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY");
}
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec,
this.responseSpecForStatusCode403);
}
/*
* Associate client to the group
*/
/**
* 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 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);
}
}
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);
/*
* Associate client to the group
*/
final String startDate = groupActivationDate;
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);
}
this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, startDate,
frequency, interval, repeatsOnDay));
}
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 client
**/
private void createClientEntity() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId);
}
final String startDate = groupActivationDate;
/**
* create a new loan product
**/
private void createLoanProductEntity() {
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear().build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
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;
}
}
public void setGroupCalendarId(Integer groupCalendarId) {
this.groupCalendarId = groupCalendarId;
}
}
@@ -35,6 +35,7 @@ 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;
@@ -65,11 +66,11 @@ public class ExternalServicesConfigurationTest {
String value = null;
if (name.equals(configName)) {
value = (String) externalServicesConfig.get(configIndex).get("value");
if(value == null){
if (value == null) {
value = "testnull";
}
String newValue = "test";
LOG.info( "{} : {}",name, value);
LOG.info("{} : {}", name, value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "S3", name, newValue);
Assertions.assertNotNull(arrayListValue.get("value"));
@@ -93,11 +94,11 @@ public class ExternalServicesConfigurationTest {
String value = null;
if (name.equals(configName)) {
value = (String) externalServicesConfig.get(configIndex).get("value");
if(value == null){
if (value == null) {
value = "testnull";
}
String newValue = "test";
LOG.info("{} : {}",name,value);
LOG.info("{} : {}", name, value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "SMTP", name, newValue);
Assertions.assertNotNull(arrayListValue.get("value"));
@@ -86,7 +86,8 @@ public class FinancialActivityAccountsTest {
* Fetch Created Financial Activity to Account Mapping and validate
* created values
**/
assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityTransferAccount);
assertFinancialActivityAccountCreation(financialActivityAccountId, LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID,
liabilityTransferAccount);
/**
* Update Existing Financial Activity to Account Mapping and assert
@@ -129,8 +130,8 @@ public class FinancialActivityAccountsTest {
invalidFinancialActivityAccountError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
/** Should be able to delete a Financial Activity to Account Mapping **/
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount(
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper
.deleteFinancialActivityAccount(financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
@@ -138,7 +139,8 @@ public class FinancialActivityAccountsTest {
financialActivityAccountHelper.getFinancialActivityAccount(deletedFinancialActivityAccountId, responseSpecForResourceNotFoundError);
}
private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId, Account glAccount) {
private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId,
Account glAccount) {
HashMap mappingDetails = financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId, responseSpec);
Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
Assertions.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id"));
@@ -152,8 +154,8 @@ public class FinancialActivityAccountsTest {
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
for (HashMap financialActivity : financialActivities) {
Integer financialActivityAccountId = (Integer) financialActivity.get("id");
Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper.deleteFinancialActivityAccount(
financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper
.deleteFinancialActivityAccount(financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
}
@@ -44,6 +44,7 @@ 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";
@@ -74,8 +75,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
final Integer savingsId = createSavingsAccount(clientID, startDate);
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate,
CommonConstants.RESPONSE_RESOURCE_ID);
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate, CommonConstants.RESPONSE_RESOURCE_ID);
/***
* Perform Post interest transaction and verify the posted transaction
@@ -85,8 +85,9 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
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())
{LOG.info("{} - {}",entry.getKey(), entry.getValue().toString());}
for (Entry<String, Object> entry : interestPostingTransaction.entrySet()) {
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
@@ -123,16 +124,16 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
if (!enabled.equals(periodEndEnable)) {
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
this.responseSpec, periodEndConfigId.toString(), periodEndEnable);
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
periodEndConfigId.toString(), periodEndEnable);
}
// Updating value for financial year beginning month
Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
Assertions.assertNotNull(financialYearBeginningConfigId);
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec,
this.responseSpec, financialYearBeginningConfigId.toString());
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
financialYearBeginningConfigId.toString());
Assertions.assertNotNull(financialYearBeginningConfigData);
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
@@ -57,10 +57,7 @@ public class FundsIntegrationTest {
@Test
public void testCreateFund() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -69,10 +66,7 @@ public class FundsIntegrationTest {
@Test
public void testCreateFundWithEmptyName() {
FundsHelper fh = FundsHelper
.create(null)
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(null).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -82,10 +76,7 @@ public class FundsIntegrationTest {
@Test
public void testCreateFundWithEmptyExternalId() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(null)
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(null).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -94,19 +85,13 @@ public class FundsIntegrationTest {
@Test
public void testCreateFundWithDuplicateName() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
Assertions.assertNotNull(fundID);
FundsHelper fh2 = FundsHelper
.create(fh.getName())
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh2 = FundsHelper.create(fh.getName()).externalId(Utils.randomNameGenerator("fund-", 5)).build();
jsonData = fh2.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
@@ -116,19 +101,13 @@ public class FundsIntegrationTest {
@Test
public void testCreateFundWithDuplicateExternalId() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
Assertions.assertNotNull(fundID);
FundsHelper fh2 = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(fh.getExternalId())
.build();
FundsHelper fh2 = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(fh.getExternalId()).build();
jsonData = fh2.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
@@ -138,10 +117,7 @@ public class FundsIntegrationTest {
@Test
public void testCreateFundWithInvalidName() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 120))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 120)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -151,10 +127,7 @@ public class FundsIntegrationTest {
@Test
public void testCreateFundWithInvalidExternalId() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 120))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 120)).build();
String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -164,10 +137,7 @@ public class FundsIntegrationTest {
@Test
public void testRetrieveFund() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -181,10 +151,7 @@ public class FundsIntegrationTest {
@Test
public void testRetrieveAllFunds() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -201,16 +168,13 @@ public class FundsIntegrationTest {
public void testRetrieveUnknownFund() {
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
String jsonData = FundsResourceHandler.retrieveFund(Long.MAX_VALUE, this.requestSpec, responseSpec);
HashMap<String, Object> map = new Gson().fromJson(jsonData, new TypeToken<HashMap<String, Object>>(){}.getType());
HashMap<String, Object> map = new Gson().fromJson(jsonData, new TypeToken<HashMap<String, Object>>() {}.getType());
assertEquals("error.msg.resource.not.found", map.get("userMessageGlobalisationCode"));
}
@Test
public void testUpdateFund() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -229,17 +193,13 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 10);
String newExternalId = Utils.randomNameGenerator("fund-", 5);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec,
responseSpec);
FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec, responseSpec);
Assertions.assertNull(fh);
}
@Test
public void testUpdateFundWithInvalidNewName() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -248,18 +208,14 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 120);
String newExternalId = Utils.randomNameGenerator("fund-", 5);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec,
responseSpec);
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, responseSpec);
Assertions.assertNull(fh2);
}
@Test
public void testUpdateFundWithNewExternalId() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -273,10 +229,7 @@ public class FundsIntegrationTest {
@Test
public void testUpdateFundWithInvalidNewExternalId() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -285,18 +238,14 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 10);
String newExternalId = Utils.randomNameGenerator("fund-", 120);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec,
responseSpec);
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, responseSpec);
Assertions.assertNull(fh2);
}
@Test
public void testUpdateFundWithNewName() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -310,10 +259,7 @@ public class FundsIntegrationTest {
@Test
public void testUpdateFundWithEmptyParams() {
FundsHelper fh = FundsHelper
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -333,9 +279,7 @@ public class FundsIntegrationTest {
Assertions.assertEquals(fh.getExternalId(), fh3.getExternalId());
}
private Long createFund(final String fundJSON,
final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
private Long createFund(final String fundJSON, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
String fundId = String.valueOf(FundsResourceHandler.createFund(fundJSON, requestSpec, responseSpec));
if (fundId.equals("null")) {
// Invalid JSON data parameters
@@ -32,7 +32,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
private ResponseSpecification responseSpec;
@@ -53,30 +52,27 @@ public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec);
}
@SuppressWarnings( {"static-access", "rawtypes", "unchecked"})
@SuppressWarnings({ "static-access", "rawtypes", "unchecked" })
@Test
public void testInterestChargedFromDateSameAsDisbursalDate(){
public void testInterestChargedFromDateSameAsDisbursalDate() {
this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
this.responseSpec);
Assertions.assertNotNull(globalConfig);
String configName = "interest-charged-from-date-same-as-disbursal-date";
boolean newBooleanValue = true;
for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) {
if (globalConfig.get(configIndex).get("name")
.equals(configName)) {
String configId = globalConfig.get(configIndex).get("id")
.toString();
Integer updateConfigId = this.globalConfigurationHelper
.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
configId.toString(), newBooleanValue);
Assertions.assertNotNull(updateConfigId);
break;
}
if (globalConfig.get(configIndex).get("name").equals(configName)) {
String configId = globalConfig.get(configIndex).get("id").toString();
Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
this.responseSpec, configId.toString(), newBooleanValue);
Assertions.assertNotNull(updateConfigId);
break;
}
}
}
@@ -137,8 +137,8 @@ public class GlobalConfigurationTest {
cacheTypeId -= 1;
}
HashMap changes = this.globalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec,
this.responseSpec, cacheTypeId.toString());
HashMap changes = this.globalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec, this.responseSpec,
cacheTypeId.toString());
Assertions.assertEquals(cacheTypeId, changes.get("cacheType"), "Verifying Is Cache Enabled Global Config after Updation");
}
}
@@ -147,8 +147,8 @@ public class GlobalConfigurationTest {
public void testGlobalConfigForcePasswordResetDays() {
// Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
this.responseSpec);
Assertions.assertNotNull(globalConfig);
String configName = "force-password-reset-days";
@@ -157,23 +157,18 @@ public class GlobalConfigurationTest {
for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) {
if (globalConfig.get(configIndex).get("name").equals(configName)) {
Integer configId = (Integer) globalConfig.get(configIndex).get(
"id");
Integer configId = (Integer) globalConfig.get(configIndex).get("id");
Assertions.assertNotNull(configId);
/*
* Update force-password-reset-days with value as 0 and Enable
* as true - failure case
*/
ArrayList error = (ArrayList) this.globalConfigurationHelper
.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.httpStatusForidden,
configId, newValue, newBooleanValue,
CommonConstants.RESPONSE_ERROR);
ArrayList error = (ArrayList) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(this.requestSpec,
this.httpStatusForidden, configId, newValue, newBooleanValue, CommonConstants.RESPONSE_ERROR);
HashMap hash = (HashMap) error.get(0);
Assertions.assertEquals(
"error.msg.password.reset.days.value.must.be.greater.than.zero",
Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero",
hash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"Force Password Reset days value must be greater than zero.");
@@ -181,27 +176,23 @@ public class GlobalConfigurationTest {
* Update force-password-reset-days with value as 50 and Enable
* as true - success case
*/
final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper
.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.responseSpec, configId,
"50", newBooleanValue, "changes");
final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.responseSpec, configId, "50", newBooleanValue, "changes");
Assertions.assertNotNull(updateSuccess);
/* Update with value as 0 and Enable as false - success case */
final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper
.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.responseSpec, configId,
newValue, "false", "changes");
final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.responseSpec, configId, newValue, "false", "changes");
Assertions.assertNotNull(updateSuccess1);
/* Update without sending value and Enable as true - failure case*/
ArrayList failure = (ArrayList) this.globalConfigurationHelper
.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.httpStatusForidden, configId,
null, newBooleanValue, CommonConstants.RESPONSE_ERROR);
/*
* Update without sending value and Enable as true - failure
* case
*/
ArrayList failure = (ArrayList) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.httpStatusForidden, configId, null, newBooleanValue, CommonConstants.RESPONSE_ERROR);
HashMap failureHash = (HashMap) failure.get(0);
Assertions.assertEquals(
"error.msg.password.reset.days.value.must.be.greater.than.zero",
Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero",
failureHash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"Force Password Reset days value must be greater than zero.");
@@ -211,13 +202,10 @@ public class GlobalConfigurationTest {
/* Update other global configuration property */
String otherConfigName = "maker-checker";
for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) {
if (globalConfig.get(configIndex).get("name")
.equals(otherConfigName)) {
String configId = globalConfig.get(configIndex).get("id")
.toString();
Integer updateConfigId = this.globalConfigurationHelper
.updateValueForGlobalConfiguration(this.requestSpec,
this.responseSpec, configId, newValue);
if (globalConfig.get(configIndex).get("name").equals(otherConfigName)) {
String configId = globalConfig.get(configIndex).get("id").toString();
Integer updateConfigId = this.globalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec,
this.responseSpec, configId, newValue);
Assertions.assertNotNull(updateConfigId);
break;
}
@@ -74,7 +74,7 @@ public class GroupLoanIntegrationTest {
final Integer loanProductID = createLoanProduct();
final Integer loanID = applyForLoanApplication(groupID, loanProductID);
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
loanID);
loanID);
verifyLoanRepaymentSchedule(loanSchedule);
}
@@ -86,20 +86,20 @@ public class GroupLoanIntegrationTest {
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
final Integer loanProductID = createLoanProduct();
HashMap<String,Integer> glim = applyForGlimApplication(clientID, groupID, loanProductID);
HashMap<String, Integer> glim = applyForGlimApplication(clientID, groupID, loanProductID);
LOG.info("Glim Loan Application: {} ", glim);
final Integer glimId=glim.get("glimId");
final Integer glimId = glim.get("glimId");
LOG.info("GlimId : {} ", glimId);
final Integer loanId=glim.get("loanId");
final Integer loanId = glim.get("loanId");
LOG.info("LoanId : {} ", loanId);
List<Map<String, Object>> approvalFormData = new ArrayList<>();
approvalFormData.add(approvalFormData(loanId,"22 September 2011"));
approvalFormData.add(approvalFormData(loanId, "22 September 2011"));
HashMap loanStatusHashMap = this.loanTransactionHelper.approveGlimAccount(this.requestSpec, this.responseSpec,
approvalFormData, glimId);
HashMap loanStatusHashMap = this.loanTransactionHelper.approveGlimAccount(this.requestSpec, this.responseSpec, approvalFormData,
glimId);
LOG.info("glim approval loanSchedule: {} ", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
@@ -115,7 +115,7 @@ public class GroupLoanIntegrationTest {
LOG.info("glim undoApproval loanSchedule: {} ", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.rejectGlimAccount("22 September 2011",glimId);
loanStatusHashMap = this.loanTransactionHelper.rejectGlimAccount("22 September 2011", glimId);
LOG.info("glim reject loanSchedule: {} ", loanStatusHashMap);
LoanStatusChecker.verifyLoanAccountRejected(loanStatusHashMap);
}
@@ -136,16 +136,16 @@ public class GroupLoanIntegrationTest {
final Integer loanProductID = createLoanProduct();
Assertions.assertNotNull(loanProductID);
HashMap<String,Integer> glim = applyForGlimApplication(clientID, groupID, loanProductID);
HashMap<String, Integer> glim = applyForGlimApplication(clientID, groupID, loanProductID);
LOG.info("Glim Loan Application: {} ", glim);
final Integer glimId=glim.get("glimId");
final Integer glimId = glim.get("glimId");
LOG.info("GlimId: {} ", glimId);
final Integer loanId=glim.get("loanId");
final Integer loanId = glim.get("loanId");
LOG.info("LoanId: {} ", loanId);
final List<String> retrievedGlimId=GroupHelper.verifyRetrieveGlimAccountsByGroupId(this.requestSpec, this.responseSpec, groupID);
final List<String> retrievedGlimId = GroupHelper.verifyRetrieveGlimAccountsByGroupId(this.requestSpec, this.responseSpec, groupID);
Assertions.assertNotNull(retrievedGlimId.toString());
}
@@ -165,16 +165,17 @@ public class GroupLoanIntegrationTest {
final Integer loanProductID = createLoanProduct();
Assertions.assertNotNull(loanProductID);
HashMap<String,Integer> glim = applyForGlimApplication(clientID, groupID, loanProductID);
HashMap<String, Integer> glim = applyForGlimApplication(clientID, groupID, loanProductID);
LOG.info("Glim Loan Application: {} ", glim);
final Integer glimId=glim.get("glimId");
final Integer glimId = glim.get("glimId");
LOG.info("GlimId: {} ", glimId);
final Integer loanId=glim.get("loanId");
final Integer loanId = glim.get("loanId");
LOG.info("LoanId: {} ", loanId);
final List<String> retrievedGlimAccountId=GroupHelper.verifyRetrieveGlimAccountsByGlimId(this.requestSpec, this.responseSpec, glimId);
final List<String> retrievedGlimAccountId = GroupHelper.verifyRetrieveGlimAccountsByGlimId(this.requestSpec, this.responseSpec,
glimId);
Assertions.assertNotNull(retrievedGlimAccountId);
}
@@ -222,7 +223,7 @@ public class GroupLoanIntegrationTest {
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
}
private HashMap<String,Integer> applyForGlimApplication(final Integer clientID, final Integer groupID, final Integer loanProductID) {
private HashMap<String, Integer> applyForGlimApplication(final Integer clientID, final Integer groupID, final Integer loanProductID) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String GlimApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("12,000.00") //
@@ -236,10 +237,8 @@ public class GroupLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
.withExpectedDisbursementDate("20 September 2011") //
.withSubmittedOnDate("20 September 2011")
.withLoanType("glim")
.withtotalLoan("10000")
.withParentAccount("1").build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
.withSubmittedOnDate("20 September 2011").withLoanType("glim").withtotalLoan("10000").withParentAccount("1")
.build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
LOG.info(GlimApplicationJSON);
return this.loanTransactionHelper.getGlimId(GlimApplicationJSON);
}
@@ -249,10 +248,8 @@ public class GroupLoanIntegrationTest {
assertEquals(new ArrayList<>(Arrays.asList(2011, 10, 20)), loanSchedule.get(1).get("dueDate"),
"Checking for Due Date for 1st Month");
assertEquals(Float.valueOf("2911.49"), loanSchedule.get(1).get("principalOriginalDue"),
"Checking for Principal Due for 1st Month");
assertEquals(Float.valueOf("240.00"), loanSchedule.get(1).get("interestOriginalDue"),
"Checking for Interest Due for 1st Month");
assertEquals(Float.valueOf("2911.49"), loanSchedule.get(1).get("principalOriginalDue"), "Checking for Principal Due for 1st Month");
assertEquals(Float.valueOf("240.00"), loanSchedule.get(1).get("interestOriginalDue"), "Checking for Interest Due for 1st Month");
assertEquals(new ArrayList<>(Arrays.asList(2011, 11, 20)), loanSchedule.get(2).get("dueDate"),
"Checking for Due Date for 2nd Month");
@@ -265,7 +262,7 @@ public class GroupLoanIntegrationTest {
assertEquals(Float.valueOf("122.38"), loanSchedule.get(3).get("interestOriginalDue"), "Checking for Interest Due for 3rd Month");
assertEquals(new ArrayList<>(Arrays.asList(2012, 1, 20)), loanSchedule.get(4).get("dueDate"),
"Checking for Due Date for 4th Month");
"Checking for Due Date for 4th Month");
assertEquals(Float.valueOf("3089.68"), loanSchedule.get(4).get("principalDue"), "Checking for Principal Due for 4th Month");
assertEquals(Float.valueOf("61.79"), loanSchedule.get(4).get("interestOriginalDue"), "Checking for Interest Due for 4th Month");
}
@@ -162,13 +162,13 @@ public class GroupSavingsIntegrationTest {
Calendar todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
.closeSavingsAccountAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
withdrawBalance = "true";
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId, withdrawBalance);
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId, withdrawBalance);
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
}
@@ -221,7 +221,7 @@ public class GroupSavingsIntegrationTest {
}
//gsimcommands testing
// gsimcommands testing
@SuppressWarnings("unchecked")
@Test
public void testGsimSavingsAccount_REJECT_APPLICATION() {
@@ -248,7 +248,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>();
clientArray.add(clientArray(clientID, groupID, savingsProductID,"08 January 2013"));
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
@@ -267,7 +267,8 @@ public class GroupSavingsIntegrationTest {
assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
error1 = savingsAccountHelperValidationError.rejectGsimApplicationWithErrorCode(gsimID, SavingsAccountHelper.CREATED_DATE_MINUS_ONE);
error1 = savingsAccountHelperValidationError.rejectGsimApplicationWithErrorCode(gsimID,
SavingsAccountHelper.CREATED_DATE_MINUS_ONE);
assertEquals("validation.msg.savingsaccount.reject.cannot.be.before.submittal.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -276,7 +277,7 @@ public class GroupSavingsIntegrationTest {
}
@Test
@Test
public void testGsimSavingsAccount_DEPOSIT_APPLICATION() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -298,7 +299,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>();
clientArray.add(clientArray(clientID, groupID, savingsProductID,"08 January 2013"));
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
LOG.info("client Array : {} ", clientArray);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
@@ -313,7 +314,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(paymentTypeId);
List<Map<String, Object>> savingsArray = new ArrayList<>();
final Integer transactionAmount=2500;
final Integer transactionAmount = 2500;
savingsArray.add(savingsArray(paymentTypeId, savingsId, transactionAmount, "10 March 2013"));
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
@@ -328,7 +329,7 @@ public class GroupSavingsIntegrationTest {
final Integer depositId = this.savingsAccountHelper.depositGsimApplication(savingsId, savingsArray);
Assertions.assertNotNull(depositId);
}
}
@SuppressWarnings("unchecked")
@Test
@@ -354,7 +355,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>();
clientArray.add(clientArray(clientID, groupID, savingsProductID,"08 January 2013"));
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
@@ -368,12 +369,13 @@ public class GroupSavingsIntegrationTest {
Calendar todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeGsimSavingsAccountAndGetBackRequiredField(gsimID, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
.closeGsimSavingsAccountAndGetBackRequiredField(gsimID, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
withdrawBalance = "true";
savingsStatusHashMap = this.savingsAccountHelper.closeGsimSavingsAccount(gsimID, withdrawBalance);
savingsStatusHashMap = this.savingsAccountHelper.closeGsimSavingsAccount(gsimID, withdrawBalance);
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
}
@@ -401,12 +403,12 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>();
clientArray.add(clientArray(clientID, groupID, savingsProductID,"08 January 2013"));
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
HashMap savingsStatusHashMap = this.savingsAccountHelper.updateGsimApplication(gsimID, clientID, groupID, savingsProductID);
LOG.info("savingsStatusHashMap: {} ",savingsStatusHashMap);
LOG.info("savingsStatusHashMap: {} ", savingsStatusHashMap);
Assertions.assertTrue(savingsStatusHashMap.containsKey("savingsId"));
}
@@ -434,12 +436,12 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>();
clientArray.add(clientArray(clientID, groupID, savingsProductID,"08 January 2013"));
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
final List<String> retrievedGsimId=GroupHelper.verifyRetrieveGsimAccounts(this.requestSpec, this.responseSpec, groupID);
final List<String> retrievedGsimId = GroupHelper.verifyRetrieveGsimAccounts(this.requestSpec, this.responseSpec, groupID);
Assertions.assertNotNull(retrievedGsimId.toString());
}
}
@SuppressWarnings("unchecked")
@Test
@@ -727,7 +729,8 @@ public class GroupSavingsIntegrationTest {
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsWeeklyFeeJSON());
final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getSavingsWeeklyFeeJSON());
Assertions.assertNotNull(weeklyFeeId);
this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId, true);
@@ -777,7 +780,8 @@ public class GroupSavingsIntegrationTest {
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
}
private Map<String, Object> clientArray(final Integer clientId, final Integer groupId, final Integer productId, final String submittedOnDate) {
private Map<String, Object> clientArray(final Integer clientId, final Integer groupId, final Integer productId,
final String submittedOnDate) {
Map<String, Object> map = new HashMap<>();
map.put("clientId", clientId);
map.put("groupId", groupId);
@@ -790,12 +794,13 @@ public class GroupSavingsIntegrationTest {
return map;
}
private Map<String, Object> savingsArray(final Integer paymentId, final Integer savingsId, final Integer transactionAmount, final String transactionDate) {
private Map<String, Object> savingsArray(final Integer paymentId, final Integer savingsId, final Integer transactionAmount,
final String transactionDate) {
Map<String, Object> map = new HashMap<>();
map.put("transactionDate", transactionDate);
map.put("dateFormat", CommonConstants.DATE_FORMAT);
map.put("locale", "en");
map.put("transactionAmount",transactionAmount);
map.put("transactionAmount", transactionAmount);
map.put("paymentTypeId", paymentId);
map.put("childAccountId", savingsId);
return map;
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
* Updating & Deletion
*/
public class GroupTest {
private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -109,11 +110,11 @@ public class GroupTest {
// create staff
Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating first staff with id------------- {}" , createStaffId1);
LOG.info("--------------creating first staff with id------------- {}", createStaffId1);
Assertions.assertNotNull(createStaffId1);
Integer createStaffId2 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating second staff with id------------- {}" , createStaffId2);
LOG.info("--------------creating second staff with id------------- {}", createStaffId2);
Assertions.assertNotNull(createStaffId2);
// assign staff "createStaffId1" to group
@@ -40,6 +40,7 @@ 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;
@@ -78,8 +79,8 @@ public class HookIntegrationTest {
final String json = RestAssured.get(payloadURL.replace("?", "")).asString();
final Integer notificationOfficeId = JsonPath.with(json).get("officeId");
Assertions.assertEquals(createdOfficeID, notificationOfficeId,
"Equality check for created officeId and hook received payload officeId");
LOG.info("Notification Office Id - {}" , notificationOfficeId);
"Equality check for created officeId and hook received payload officeId");
LOG.info("Notification Office Id - {}", notificationOfficeId);
i = 6;
} catch (Exception e) {
TimeUnit.SECONDS.sleep(3);
@@ -97,20 +98,20 @@ public class HookIntegrationTest {
}
@Test
public void createUpdateAndDeleteHook(){
public void createUpdateAndDeleteHook() {
final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?";
final String updateURL = "http://localhost";
Long hookId = this.hookHelper.createHook(payloadURL).longValue();
Assertions.assertNotNull(hookId);
this.hookHelper.verifyHookCreatedOnServer(hookId);
LOG.info("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK------------------------- {}",hookId);
LOG.info("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK------------------------- {}", hookId);
this.hookHelper.updateHook(updateURL, hookId);
this.hookHelper.verifyUpdateHook(updateURL, hookId);
LOG.info("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK------------------------- {}",hookId);
LOG.info("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK------------------------- {}", hookId);
this.hookHelper.deleteHook(hookId);
this.hookHelper.verifyDeleteHook(hookId);
LOG.info("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK------------------------- {}",hookId);
LOG.info("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK------------------------- {}", hookId);
}
}
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanApplicationApprovalTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class);
private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403;
@@ -130,14 +131,13 @@ public class LoanApplicationApprovalTest {
createTranches.add(createTrancheDetail("23 March 2014", "4000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------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));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
final Integer loanProductID = this.loanTransactionHelper
.getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
loanProductID);
this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
@@ -155,8 +155,7 @@ public class LoanApplicationApprovalTest {
approveTranches.add(createTrancheDetail("23 March 2014", "1000"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
, loanID);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -201,8 +200,7 @@ public class LoanApplicationApprovalTest {
approveTranche4.add(createTrancheDetail("24 March 2014", "100"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------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);
@@ -233,8 +231,8 @@ public class LoanApplicationApprovalTest {
/* No. of tranches exceeds the max tranche count at product level */
error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount3, loanID,
approveTranche3, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.disbursementData.exceeding.max.tranche.count", error.get(0)
.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
assertEquals("error.msg.disbursementData.exceeding.max.tranche.count",
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
/* If tranches are not specified for a multi-disburse loan */
/**
@@ -259,7 +257,7 @@ public class LoanApplicationApprovalTest {
List<HashMap> tranches) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
//
.withPrincipal(principal)
//
.withLoanTermFrequency("5")
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanApplicationUndoLastTrancheTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -67,15 +68,14 @@ public class LoanApplicationUndoLastTrancheTest {
// CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------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));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
final Integer loanProductID = this.loanTransactionHelper
.getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
loanProductID);
// CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>();
@@ -89,8 +89,7 @@ public class LoanApplicationUndoLastTrancheTest {
// APPLY FOR LOAN WITH TRANCHES
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------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
@@ -133,7 +132,7 @@ public class LoanApplicationUndoLastTrancheTest {
List<HashMap> tranches) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
//
.withPrincipal(principal)
//
.withLoanTermFrequency("5")
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanDisbursalDateValidationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -65,19 +66,17 @@ public class LoanDisbursalDateValidationTest {
// CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------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));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
// CREATE LOAN PRODUCT
final Integer loanProductID = this.loanTransactionHelper
.getLoanProductId(new LoanProductTestBuilder().withSyncExpectedWithDisbursementDate(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
loanProductID);
// APPLY FOR LOAN
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
LOG.info("-----------------------------------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
@@ -92,7 +91,8 @@ public class LoanDisbursalDateValidationTest {
// DISBURSE A LOAN
@SuppressWarnings("unchecked")
List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID, this.responseForbiddenError);
List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID,
this.responseForbiddenError);
Assertions.assertEquals(disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"error.msg.actual.disbursement.date.does.not.match.with.expected.disbursal.date");
@@ -100,18 +100,11 @@ public class LoanDisbursalDateValidationTest {
}
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) {
final String loanApplication = new LoanApplicationTestBuilder()
.withPrincipal(proposedAmount).withLoanTermFrequency("5")
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5")
.withRepaymentEveryAfter("1")
.withRepaymentFrequencyTypeAsMonths()
.withInterestRatePerPeriod("2")
.withExpectedDisbursementDate("1 March 2014")
.withSubmittedOnDate("26 February 2014").
build(clientID.toString(), loanProductID.toString(), null);
final String loanApplication = new LoanApplicationTestBuilder().withPrincipal(proposedAmount).withLoanTermFrequency("5")
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5").withRepaymentEveryAfter("1")
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("1 March 2014")
.withSubmittedOnDate("26 February 2014").build(clientID.toString(), loanProductID.toString(), null);
return this.loanTransactionHelper.getLoanId(loanApplication);
}
}
@@ -44,6 +44,7 @@ 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;
@@ -75,20 +76,19 @@ 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");
LOG.info("---------------------------------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));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
loanProductID);
final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
installmentAmount);
LOG.info("-----------------------------------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");
@@ -106,7 +106,8 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------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,8 +118,8 @@ public class LoanDisbursementDetailsIntegrationTest {
ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods");
assertEquals(15, periods1.size());
LOG.info("-----------------------------------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);
@@ -131,7 +132,8 @@ public class LoanDisbursementDetailsIntegrationTest {
loanIDWithoutEmi, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
LOG.info(
"-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
}
@@ -207,9 +209,9 @@ public class LoanDisbursementDetailsIntegrationTest {
assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate());
assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding());
LOG.info("{}",period.get("totalOriginalDueForPeriod").toString());
assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()), expectedRepaymentSchedule
.getTotalOriginalDueForPeriod().floatValue(), 0.0f);
LOG.info("{}", period.get("totalOriginalDueForPeriod").toString());
assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()),
expectedRepaymentSchedule.getTotalOriginalDueForPeriod().floatValue(), 0.0f);
assertEquals(Float.valueOf(period.get("totalOutstandingForPeriod").toString()).floatValue(),
expectedRepaymentSchedule.getTotalOutstandingForPeriod(), 0.0f);
@@ -220,7 +222,8 @@ public class LoanDisbursementDetailsIntegrationTest {
expectedRepaymentSchedule.getInterestOutstanding(), 0.0f);
assertEquals(Float.valueOf(period.get("principalOutstanding").toString()).floatValue(),
expectedRepaymentSchedule.getPrincipalOutstanding(), 0.0f);
assertEquals(Float.valueOf(period.get("principalDue").toString()).floatValue(), expectedRepaymentSchedule.getPrincipalDue(), 0.0f);
assertEquals(Float.valueOf(period.get("principalDue").toString()).floatValue(), expectedRepaymentSchedule.getPrincipalDue(),
0.0f);
assertEquals(Float.valueOf(period.get("principalOriginalDue").toString()).floatValue(),
expectedRepaymentSchedule.getPrincipalOriginalDue(), 0.0f);
assertEquals(period.get("fromDate").toString(), expectedRepaymentSchedule.getFromDate());
@@ -342,7 +345,7 @@ public class LoanDisbursementDetailsIntegrationTest {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
//
.withPrincipal(proposedAmount)
//
.withLoanTermFrequency("12")
@@ -364,25 +367,23 @@ public class LoanDisbursementDetailsIntegrationTest {
}
@Test
public void createApproveAndValidateMultiDisburseLoan() throws ParseException{
public void createApproveAndValidateMultiDisburseLoan() throws ParseException {
List<HashMap> createTranches = new ArrayList<>();
String id = null;
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------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));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}"
, loanProductID);
final Integer loanProductID = this.loanTransactionHelper
.getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
loanProductID);
this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}"
, loanID);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -423,7 +424,7 @@ public class LoanDisbursementDetailsIntegrationTest {
addTranches, "");
}
private void deleteDisbursmentDetails() throws ParseException{
private void deleteDisbursmentDetails() throws ParseException {
List<HashMap> deleteTranches = new ArrayList<>();
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper.getLoanDetail(this.requestSpec,
this.responseSpec, this.loanID, "disbursementDetails");
@@ -440,7 +441,7 @@ public class LoanDisbursementDetailsIntegrationTest {
deleteTranches, "");
}
private void editDateAndPrincipalOfExistingTranche() throws ParseException{
private void editDateAndPrincipalOfExistingTranche() throws ParseException {
String updatedExpectedDisbursementDate = "01 March 2014";
String updatedPrincipal = "900";
/* Update */
@@ -469,7 +470,7 @@ public class LoanDisbursementDetailsIntegrationTest {
List<HashMap> tranches) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
//
//
.withPrincipal(principal)
//
.withLoanTermFrequency("5")
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public class LoanRepaymentRescheduleAtDisbursementTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -65,7 +66,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
@SuppressWarnings("unchecked")
@Test
public void testLoanRepaymentRescheduleAtDisbursement(){
public void testLoanRepaymentRescheduleAtDisbursement() {
final String approvalAmount = "10000";
final String approveDate = "01 March 2015";
@@ -75,8 +76,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
// CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------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,
@@ -116,8 +116,9 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
this.loanTransactionHelper.disburseLoanWithRepaymentReschedule(disbursementDate, loanID, adjustRepaymentDate);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, loanID);
HashMap firstInstallement = loanRepaymnetSchedule.get(1);
ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec,
loanID);
HashMap firstInstallement = loanRepaymnetSchedule.get(1);
Map<String, Object> expectedvalues = new HashMap<>(3);
Calendar date = Calendar.getInstance(Utils.getTimeZoneOfTenant());
date.set(2015, Calendar.MARCH, 16);
@@ -170,17 +171,10 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) {
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder()
.withPrincipal("10000.00")
.withNumberOfRepayments("12")
.withRepaymentAfterEvery("2")
.withRepaymentTypeAsWeek()
.withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths()
.withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentStrategy(repaymentStrategy)
.withInterestTypeAsDecliningBalance()
LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("12")
.withRepaymentAfterEvery("2").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentStrategy(repaymentStrategy).withInterestTypeAsDecliningBalance()
.withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod,
preCloseInterestCalculationStrategy)
.withInterestRecalculationRestFrequencyDetails(recalculationRestFrequencyType, recalculationRestFrequencyInterval,
@@ -193,7 +187,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
}
if (isArrearsBasedOnOriginalSchedule) {
builder = builder.withArrearsConfiguration();
builder = builder.withArrearsConfiguration();
}
final String loanProductJSON = builder.build(chargeId);
@@ -221,8 +215,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
.withRepaymentFrequencyTypeAsWeeks() //
.withInterestRatePerPeriod("2") //
.withAmortizationTypeAsEqualInstallments() //
.withTranches(tranches)
.withFixedEmiAmount("") //
.withTranches(tranches).withFixedEmiAmount("") //
.withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeAsDays() //
.withInterestCalculationPeriodTypeAsDays() //
@@ -240,7 +233,6 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
private List getDateAsArray(Calendar date, int addvalue, int type) {
date.add(type, addvalue);
return new ArrayList<>(Arrays.asList(date.get(Calendar.YEAR), date.get(Calendar.MONTH) + 1,
date.get(Calendar.DAY_OF_MONTH)));
return new ArrayList<>(Arrays.asList(date.get(Calendar.YEAR), date.get(Calendar.MONTH) + 1, date.get(Calendar.DAY_OF_MONTH)));
}
}
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
**/
@SuppressWarnings({ "rawtypes" })
public class LoanRescheduleRequestTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class);
private ResponseSpecification responseSpec;
private ResponseSpecification generalResponseSpec;
@@ -98,15 +99,12 @@ public class LoanRescheduleRequestTest {
private void createLoanProductEntity() {
LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder()
.withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments)
.withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear()
.build(null);
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear().build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
LOG.info("Successfully created loan product (ID:{}) " , this.loanProductId);
LOG.info("Successfully created loan product (ID:{}) ", this.loanProductId);
}
/**
@@ -115,26 +113,16 @@ public class LoanRescheduleRequestTest {
private void createLoanEntity() {
LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
.withPrincipal(loanPrincipalAmount)
.withLoanTermFrequency(numberOfRepayments)
.withLoanTermFrequencyAsMonths()
.withNumberOfRepayments(numberOfRepayments)
.withRepaymentEveryAfter("1")
.withRepaymentFrequencyTypeAsMonths()
.withAmortizationTypeAsEqualInstallments()
.withInterestCalculationPeriodTypeAsDays()
.withInterestRatePerPeriod(interestRatePerPeriod)
.withLoanTermFrequencyAsMonths()
.withSubmittedOnDate(dateString)
.withExpectedDisbursementDate(dateString)
.withPrincipalGrace("2")
.withInterestGrace("2")
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
.withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsMonths().withNumberOfRepayments(numberOfRepayments)
.withRepaymentEveryAfter("1").withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments()
.withInterestCalculationPeriodTypeAsDays().withInterestRatePerPeriod(interestRatePerPeriod).withLoanTermFrequencyAsMonths()
.withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2")
.build(this.clientId.toString(), this.loanProductId.toString(), null);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
LOG.info("Sucessfully created loan (ID: {} )" , this.loanId);
LOG.info("Sucessfully created loan (ID: {} )", this.loanId);
this.approveLoanApplication();
this.disburseLoan();
@@ -145,9 +133,9 @@ public class LoanRescheduleRequestTest {
**/
private void approveLoanApplication() {
if(this.loanId != null) {
if (this.loanId != null) {
this.loanTransactionHelper.approveLoan(this.dateString, this.loanId);
LOG.info("Successfully approved loan (ID: {} )" , this.loanId);
LOG.info("Successfully approved loan (ID: {} )", this.loanId);
}
}
@@ -156,9 +144,9 @@ public class LoanRescheduleRequestTest {
**/
private void disburseLoan() {
if(this.loanId != null) {
if (this.loanId != null) {
this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId);
LOG.info("Successfully disbursed loan (ID: {} )" , this.loanId);
LOG.info("Successfully disbursed loan (ID: {} )", this.loanId);
}
}
@@ -173,7 +161,7 @@ public class LoanRescheduleRequestTest {
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
LOG.info("Successfully created loan reschedule request (ID: {} )" , this.loanRescheduleRequestId);
LOG.info("Successfully created loan reschedule request (ID: {} )", this.loanRescheduleRequestId);
}
@Test
@@ -191,9 +179,9 @@ public class LoanRescheduleRequestTest {
this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean)response.get("rejected"));
assertTrue((Boolean) response.get("rejected"));
LOG.info("Successfully rejected loan reschedule request (ID: {} )" , this.loanRescheduleRequestId);
LOG.info("Successfully rejected loan reschedule request (ID: {} )", this.loanRescheduleRequestId);
}
@Test
@@ -206,15 +194,16 @@ public class LoanRescheduleRequestTest {
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean)response.get("approved"));
assertTrue((Boolean) response.get("approved"));
final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId, "numberOfRepayments");
final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId,
"numberOfRepayments");
final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId);
final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment");
assertEquals(12, numberOfRepayments, "NUMBER OF REPAYMENTS is NOK");
assertEquals(118000, totalExpectedRepayment, "TOTAL EXPECTED REPAYMENT is NOK");
LOG.info("Successfully approved loan reschedule request (ID: {})" , this.loanRescheduleRequestId);
LOG.info("Successfully approved loan reschedule request (ID: {})", this.loanRescheduleRequestId);
}
}
@@ -18,7 +18,6 @@
*/
package org.apache.fineract.integrationtests;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.Gson;
@@ -56,6 +55,7 @@ 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;
@@ -114,8 +114,7 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan,
null, null);
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, null, null);
// APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION
final Integer loanId = applyForLoanApplicationForInterestRecalculation(clientId, groupId, calendarId, loanProductID, disbursalDate,
@@ -177,13 +176,13 @@ public class LoanReschedulingWithinCenterTest {
final String interval = "2"; // Every one week
Integer repeatsOnDay = today.get(Calendar.DAY_OF_WEEK) - 1;
if (repeatsOnDay.intValue() == 0){
if (repeatsOnDay.intValue() == 0) {
repeatsOnDay = 7;
}
Integer calendarId = CalendarHelper.createMeetingForGroup(this.requestSpec, this.responseSpec, centerId, startDate, frequency,
interval, repeatsOnDay.toString());
LOG.info("calendarId {}" , calendarId);
LOG.info("calendarId {}", calendarId);
return calendarId;
}
@@ -229,12 +228,11 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan,
null, null);
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, null, null);
Calendar seondTrancheDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
seondTrancheDate.add(Calendar.MONTH, 1);
String secondDisbursement = dateFormat.format(seondTrancheDate.getTime()) ;
String secondDisbursement = dateFormat.format(seondTrancheDate.getTime());
// CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>();
@@ -290,7 +288,8 @@ public class LoanReschedulingWithinCenterTest {
final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod,
final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval,
final String recalculationRestFrequencyDate, final String preCloseInterestCalculationStrategy, final Account[] accounts,
final boolean isMultiTrancheLoan, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) {
final boolean isMultiTrancheLoan, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) {
final String recalculationCompoundingFrequencyType = null;
final String recalculationCompoundingFrequencyInterval = null;
final String recalculationCompoundingFrequencyDate = null;
@@ -300,8 +299,8 @@ public class LoanReschedulingWithinCenterTest {
rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval,
recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval,
recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, isMultiTrancheLoan,
recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, recalculationRestFrequencyOnDayType,
recalculationRestFrequencyDayOfWeekType);
recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType,
recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType);
}
private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy,
@@ -311,20 +310,13 @@ public class LoanReschedulingWithinCenterTest {
final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate,
final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId,
boolean isArrearsBasedOnOriginalSchedule, final boolean isMultiTrancheLoan,
final Integer recalculationCompoundingFrequencyOnDayType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) {
final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType,
final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) {
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder()
.withPrincipal("10000.00")
.withNumberOfRepayments("12")
.withRepaymentAfterEvery("2")
.withRepaymentTypeAsWeek()
.withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths()
.withTranches(isMultiTrancheLoan)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentStrategy(repaymentStrategy)
LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("12")
.withRepaymentAfterEvery("2").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths().withTranches(isMultiTrancheLoan)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).withRepaymentStrategy(repaymentStrategy)
.withInterestTypeAsDecliningBalance()
.withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod,
preCloseInterestCalculationStrategy)
@@ -395,8 +387,8 @@ public class LoanReschedulingWithinCenterTest {
map.put("active", "true");
map.put("activationDate", "04 March 2011");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec, "/fineract-provider/api/v1/groups?"
+ Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec,
"/fineract-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
}
return groupMembers;
}
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
*/
@SuppressWarnings({ "rawtypes" })
public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class);
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -101,7 +102,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
LOG.info("DISBURSE {}" , loanStatusHashMap.toString());
LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// PERFORM REPAYMENTS AND CHECK LOAN STATUS
@@ -114,7 +115,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DIBURSE AGAIN
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
LOG.info("DISBURSE {}" , loanStatusHashMap);
LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS
@@ -160,7 +161,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
LOG.info("DISBURSE {}" , loanStatusHashMap);
LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS
@@ -174,17 +175,21 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
"Checking for Principal paid ");
Assertions.assertTrue(Float.valueOf("180.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestPaid")))) == 0,
"Checking for interestPaid paid ");
Assertions.assertTrue(Float.valueOf("680.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalRepayment")))) == 0,
Assertions.assertTrue(
Float.valueOf("680.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalRepayment")))) == 0,
"Checking for total paid ");
// WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED
LoanStatusChecker.verifyLoanAccountIsClosed(this.loanTransactionHelper.writeOffLoan("1 January 2011", loanID));
toLoanSummaryAfter = this.loanTransactionHelper.getLoanSummary(requestSpec, responseSpec, loanID);
Assertions.assertTrue(Float.valueOf("4000.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("principalWrittenOff")))) == 0,
Assertions.assertTrue(
Float.valueOf("4000.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("principalWrittenOff")))) == 0,
"Checking for Principal written off ");
Assertions.assertTrue(Float.valueOf("1440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestWrittenOff")))) == 0,
Assertions.assertTrue(
Float.valueOf("1440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestWrittenOff")))) == 0,
"Checking for interestPaid written off ");
Assertions.assertTrue(Float.valueOf("5440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalWrittenOff")))) == 0,
Assertions.assertTrue(
Float.valueOf("5440.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("totalWrittenOff")))) == 0,
"Checking for total written off ");
}
@@ -215,4 +215,4 @@ public class MinimumDaysBetweenDisbursalAndFirstRepaymentTest {
public void setGroupCalendarId(Integer groupCalendarId) {
this.groupCalendarId = groupCalendarId;
}
}
}
@@ -33,6 +33,7 @@ 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;
@@ -50,7 +51,7 @@ public class NotificationApiTest {
public void testNotificationRetrieval() {
HashMap<String, Object> response = (HashMap<String, Object>) NotificationHelper.getNotifications(this.requestSpec,
this.responseSpec, "");
LOG.info("Response : {}" , response.toString());
LOG.info("Response : {}", response.toString());
Assertions.assertNotNull(response);
}
}
@@ -38,14 +38,9 @@ public class OfficeIntegrationTest {
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(
ContentType.JSON).build();
this.requestSpec
.header("Authorization",
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
@@ -37,6 +37,7 @@ 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;
@@ -59,7 +60,7 @@ public class PasswordPreferencesIntegrationTest {
this.validateIfThePasswordIsUpdated(validationPolicyId);
}
private void validateIfThePasswordIsUpdated(String validationPolicyId){
private void validateIfThePasswordIsUpdated(String validationPolicyId) {
Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec);
assertEquals(validationPolicyId, id.toString());
LOG.info("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------");
@@ -69,8 +70,8 @@ public class PasswordPreferencesIntegrationTest {
@Test
public void updateWithInvalidPolicyId() {
String invalidValidationPolicyId = "2000";
final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec, invalidValidationPolicyId,
CommonConstants.RESPONSE_ERROR);
final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec,
invalidValidationPolicyId, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.password.validation.policy.id.invalid", error.get(0).get("userMessageGlobalisationCode"),
"Password Validation Policy with identifier 2000 does not exist");
}
@@ -31,43 +31,37 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@SuppressWarnings({"rawtypes"})
@SuppressWarnings({ "rawtypes" })
public class RatesTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
public void testRatesForLoans() {
@Test
public void testRatesForLoans() {
// Retrieving all Rates
ArrayList<HashMap> allRatesData = RatesHelper.getRates(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(allRatesData);
// Retrieving all Rates
ArrayList<HashMap> allRatesData = RatesHelper.getRates(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(allRatesData);
// Testing Creation and Update of Loan Rate
final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec,
RatesHelper.getLoanRateJSON());
Assertions.assertNotNull(loanRateId);
// Testing Creation and Update of Loan Rate
final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec, RatesHelper.getLoanRateJSON());
Assertions.assertNotNull(loanRateId);
//Update Rate percentage
HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId,
RatesHelper.getModifyRateJSON());
// Update Rate percentage
HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId, RatesHelper.getModifyRateJSON());
HashMap rateDataAfterChanges = RatesHelper
.getRateById(this.requestSpec, this.responseSpec, loanRateId);
Assertions.assertEquals(rateDataAfterChanges.get("percentage"),
changes.get("percentage"), "Verifying Rate after modification");
}
HashMap rateDataAfterChanges = RatesHelper.getRateById(this.requestSpec, this.responseSpec, loanRateId);
Assertions.assertEquals(rateDataAfterChanges.get("percentage"), changes.get("percentage"), "Verifying Rate after modification");
}
}
@@ -38,6 +38,7 @@ 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;
@@ -109,7 +110,7 @@ public class RolesTest {
assertEquals(enableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId);
assertEquals(false,(Boolean) role.get("disabled"));
assertEquals(false, (Boolean) role.get("disabled"));
}
@@ -67,12 +67,12 @@ public class SchedulerJobsTest {
@Test // FINERACT-926
public void testDateFormat() {
// must start scheduler and make job active to have nextRunTime (which is a
// 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"),
String nextRunTimeText = await().until(() -> (String) schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"),
nextRunTime -> nextRunTime != null);
DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText);
}
@@ -102,7 +102,8 @@ public class SchedulerJobsTest {
@Test
public void testFlippingJobsActiveStatus() throws InterruptedException {
// Stop the Scheduler while we test flapping jobs' active on/off, to avoid side
// Stop the Scheduler while we test flapping jobs' active on/off, to
// avoid side
// effects
schedulerJobHelper.updateSchedulerStatus(false);
@@ -131,4 +132,4 @@ public class SchedulerJobsTest {
schedulerJobHelper.executeAndAwaitJob(jobName);
}
}
}
}
@@ -45,6 +45,7 @@ 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;
@@ -56,8 +57,7 @@ public class SkipRepaymentOnMonthFirstTest {
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@@ -72,8 +72,8 @@ public class SkipRepaymentOnMonthFirstTest {
this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
this.responseSpec);
Assertions.assertNotNull(globalConfig);
String configName = "skip-repayment-on-first-day-of-month";
@@ -82,8 +82,8 @@ public class SkipRepaymentOnMonthFirstTest {
for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) {
if (globalConfig.get(configIndex).get("name").equals(configName)) {
String configId = globalConfig.get(configIndex).get("id").toString();
Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(
this.requestSpec, this.responseSpec, configId.toString(), newBooleanValue);
Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
this.responseSpec, configId.toString(), newBooleanValue);
Assertions.assertNotNull(updateConfigId);
break;
}
@@ -97,26 +97,23 @@ public class SkipRepaymentOnMonthFirstTest {
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(),
clientID.toString());
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
final String startDate = "15 September 2011";
final String frequency = "3"; // Monthly
final String interval = "1"; //Every One Moth
Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency,
interval, null);
LOG.info("caladerId -------------------- {}" , calendarID);
final String interval = "1"; // Every One Moth
Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency, interval, null);
LOG.info("caladerId -------------------- {}", calendarID);
final Integer loanProductID = createLoanProduct();
final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID);
LOG.info("loanID---- {}" , loanID);
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
this.responseSpec, loanID);
LOG.info("loanID---- {}", loanID);
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
loanID);
verifyLoanRepaymentSchedule(loanSchedule);
}
private Integer createLoanProduct() {
LOG.info(
"------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") //
.withNumberOfRepayments("4") //
@@ -130,10 +127,8 @@ public class SkipRepaymentOnMonthFirstTest {
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID,
Integer clientID) {
LOG.info(
"--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID, Integer clientID) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("12,000.00") //
.withLoanTermFrequency("4") //
@@ -157,19 +152,19 @@ public class SkipRepaymentOnMonthFirstTest {
LOG.info("--------------------VERIFYING THE REPAYMENT DATE--------------------------");
assertEquals(new ArrayList<>(Arrays.asList(2011, 10, 15)), loanSchedule.get(1).get("dueDate"),
"Checking for Repayment Date for 1st Month");
LOG.info("Repayment Date for 1st Month-- {}" , loanSchedule.get(1).get("dueDate"));
LOG.info("Repayment Date for 1st Month-- {}", loanSchedule.get(1).get("dueDate"));
assertEquals(new ArrayList<>(Arrays.asList(2011, 11, 15)), loanSchedule.get(2).get("dueDate"),
"Checking for Repayment Date for 2nd Month");
LOG.info("Repayment Date for 2nd Month-- {}" , loanSchedule.get(2).get("dueDate"));
LOG.info("Repayment Date for 2nd Month-- {}", loanSchedule.get(2).get("dueDate"));
assertEquals(new ArrayList<>(Arrays.asList(2011, 12, 15)), loanSchedule.get(3).get("dueDate"),
"Checking for Repayment Date for 3rd Month");
LOG.info("Repayment Date for 3rd Month-- {}" , loanSchedule.get(3).get("dueDate"));
LOG.info("Repayment Date for 3rd Month-- {}", loanSchedule.get(3).get("dueDate"));
assertEquals(new ArrayList<>(Arrays.asList(2012, 1, 15)), loanSchedule.get(4).get("dueDate"),
"Checking for Repayment Date for 4th Month");
LOG.info("Repayment Date for 4th Month-- {}" , loanSchedule.get(4).get("dueDate"));
LOG.info("Repayment Date for 4th Month-- {}", loanSchedule.get(4).get("dueDate"));
}
}
@@ -53,7 +53,7 @@ public class StaffImageApiTest {
}
@Test
public void getStaffImage(){
public void getStaffImage() {
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
assertNotNull(imageId, "Image id should not be null");
@@ -63,7 +63,7 @@ public class StaffImageApiTest {
}
@Test
public void getStaffImageAsBinary(){
public void getStaffImageAsBinary() {
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
assertNotNull(imageId, "Image id should not be null");
@@ -84,7 +84,7 @@ public class StaffTest {
/** Long lastname test */
map.put("lastname", Utils.randomNameGenerator("Doe_", 47));
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map));
map.put("lastname", Utils.randomNameGenerator("Doe_",4));
map.put("lastname", Utils.randomNameGenerator("Doe_", 4));
/** Long mobileNo test */
map.put("mobileNo", Utils.randomNameGenerator("num_", 47));
@@ -136,7 +136,7 @@ public class StaffTest {
@Test
public void testStaffListStatusActive() {
List<Map<String, Object>> responseActive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active");
for(final Map<String, Object> staff : responseActive) {
for (final Map<String, Object> staff : responseActive) {
Assertions.assertNotNull(staff.get("id"));
Assertions.assertEquals(true, staff.get("isActive"));
}
@@ -145,7 +145,7 @@ public class StaffTest {
@Test
public void testStaffListStatusInactive() {
List<Map<String, Object>> responseInactive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive");
for(final Map<String, Object> staff : responseInactive) {
for (final Map<String, Object> staff : responseInactive) {
Assertions.assertNotNull(staff.get("id"));
Assertions.assertEquals(false, staff.get("isActive"));
}
@@ -46,4 +46,4 @@ public class SurveyIntegrationTest {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
}
}
@@ -90,8 +90,8 @@ public class SystemCodeTest {
assertEquals(createResponseId, deleteResponseId, "Verify code deleted");
// verify code deleted
final HashMap deletedCodeValues = (HashMap) CodeHelper
.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId, "");
final HashMap deletedCodeValues = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId,
"");
Assertions.assertNotNull(deletedCodeValues);
assertNull(deletedCodeValues.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId");
@@ -132,8 +132,8 @@ public class SystemCodeTest {
assertEquals(createResponseId, deleteResponseId, "Verify code deleted");
// verify code deleted
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec,
deleteResponseId, "");
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId,
"");
Assertions.assertNotNull(deletedCodeAttributes);
assertNull(deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId");
@@ -206,11 +206,10 @@ public class SystemCodeTest {
createCodeResponseId, createCodeValueResponseId1, "");
Assertions.assertNotNull(codeValuesAttributes1);
assertEquals(createCodeValueResponseId1,
codeValuesAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME), "Verify value of codeValueId");
assertEquals(createCodeValueResponseId1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME),
"Verify value of codeValueId");
assertEquals(codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME),
"Verify value of code name");
assertEquals(codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME), "Verify value of code name");
assertEquals(codeDescription1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME),
"Verify value of code description");
@@ -64,11 +64,13 @@ public class TemplateIntegrationTest {
ArrayList<?> get = Utils.performServerGet(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, "");
final int entriesBeforeTest = get.size();
final Integer id = Utils.performServerPost(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, new Gson().toJson(map), "resourceId");
final Integer id = Utils.performServerPost(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, new Gson().toJson(map),
"resourceId");
final String templateUrlForId = String.format(this.GET_TEMPLATE_ID_URL, id);
final String getrequest2 = Utils.performServerGet(this.requestSpec, this.responseSpec, templateUrlForId, this.RESPONSE_ATTRIBUTE_NAME);
final String getrequest2 = Utils.performServerGet(this.requestSpec, this.responseSpec, templateUrlForId,
this.RESPONSE_ATTRIBUTE_NAME);
Assertions.assertTrue(getrequest2.equals("foo"));
@@ -40,6 +40,7 @@ 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;
@@ -59,7 +60,7 @@ public class UserAdministrationTest {
@AfterEach
public void tearDown() {
for(Integer userId : this.transientUsers) {
for (Integer userId : this.transientUsers) {
UserHelper.deleteUser(this.requestSpec, this.responseSpec, userId);
}
this.transientUsers.clear();
@@ -74,14 +75,15 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId);
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet", "resourceId");
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet",
"resourceId");
Assertions.assertNotNull(userId);
this.transientUsers.add(userId);
final List errors = (List) UserHelper.createUser(this.requestSpec, expectStatusCode(403), roleId, staffId, "alphabet", "errors");
Map reason = (Map) errors.get(0);
LOG.info("Reason: {}" , reason.get("defaultUserMessage"));
LOG.info("Code: {}" , reason.get("userMessageGlobalisationCode"));
LOG.info("Reason: {}", reason.get("defaultUserMessage"));
LOG.info("Code: {}", reason.get("userMessageGlobalisationCode"));
Assertions.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage"));
Assertions.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode"));
}
@@ -94,7 +96,8 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId);
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet", "resourceId");
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet",
"resourceId");
Assertions.assertNotNull(userId);
this.transientUsers.add(userId);
@@ -113,11 +116,13 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId);
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet", "resourceId");
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "alphabet",
"resourceId");
Assertions.assertNotNull(userId);
this.transientUsers.add(userId);
final Integer userId2 = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "bilingual", "resourceId");
final Integer userId2 = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId, "bilingual",
"resourceId");
Assertions.assertNotNull(userId2);
this.transientUsers.add(userId2);
@@ -126,6 +131,7 @@ public class UserAdministrationTest {
Assertions.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage"));
Assertions.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode"));
}
@Test
public void testCreateNewUserBlocksDuplicateClientId() {
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
@@ -137,13 +143,16 @@ public class UserAdministrationTest {
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId);
final Integer userId = (Integer) UserHelper.createUserForSelfService(this.requestSpec, this.responseSpec, roleId, staffId, clientId, "resourceId");
final Integer userId = (Integer) UserHelper.createUserForSelfService(this.requestSpec, this.responseSpec, roleId, staffId, clientId,
"resourceId");
Assertions.assertNotNull(userId);
this.transientUsers.add(userId);
final List errors = (List) UserHelper.createUserForSelfService(this.requestSpec, expectStatusCode(403), roleId, staffId, clientId, "errors");
final List errors = (List) UserHelper.createUserForSelfService(this.requestSpec, expectStatusCode(403), roleId, staffId, clientId,
"errors");
Map reason = (Map) errors.get(0);
Assertions.assertEquals("Self Service User Id is already created. Go to Admin->Users to edit or delete the self-service user.", reason.get("defaultUserMessage"));
Assertions.assertEquals("Self Service User Id is already created. Go to Admin->Users to edit or delete the self-service user.",
reason.get("defaultUserMessage"));
}
}
@@ -36,6 +36,7 @@ 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;
@@ -52,6 +52,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ClientEntityImportHandlerTest {
private final static Logger LOG = LoggerFactory.getLogger(ClientEntityImportHandlerTest.class);
private ResponseSpecification responseSpec;
@@ -68,85 +69,90 @@ public class ClientEntityImportHandlerTest {
@Test
public void testClientImport() throws InterruptedException, IOException, ParseException {
//in order to populate helper sheets
// in order to populate helper sheets
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
Integer outcome_staff_creation = StaffHelper.createStaff(requestSpec,responseSpec);
Integer outcome_staff_creation = StaffHelper.createStaff(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
//in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec,responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
// in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
//in order to populate helper columns in client entity sheet
//create constitution
CodeHelper.retrieveOrCreateCodeValue(24,requestSpec,responseSpec);
//create client classification
CodeHelper.retrieveOrCreateCodeValue(17,requestSpec,responseSpec);
//create client types
CodeHelper.retrieveOrCreateCodeValue(16,requestSpec,responseSpec);
//create Address types
CodeHelper.retrieveOrCreateCodeValue(29,requestSpec,responseSpec);
//create State
CodeHelper.retrieveOrCreateCodeValue(27,requestSpec,responseSpec);
//create Country
CodeHelper.retrieveOrCreateCodeValue(28,requestSpec,responseSpec);
//create Main business line
CodeHelper.retrieveOrCreateCodeValue(25,requestSpec,responseSpec);
// in order to populate helper columns in client entity sheet
// create constitution
CodeHelper.retrieveOrCreateCodeValue(24, requestSpec, responseSpec);
// create client classification
CodeHelper.retrieveOrCreateCodeValue(17, requestSpec, responseSpec);
// create client types
CodeHelper.retrieveOrCreateCodeValue(16, requestSpec, responseSpec);
// create Address types
CodeHelper.retrieveOrCreateCodeValue(29, requestSpec, responseSpec);
// create State
CodeHelper.retrieveOrCreateCodeValue(27, requestSpec, responseSpec);
// create Country
CodeHelper.retrieveOrCreateCodeValue(28, requestSpec, responseSpec);
// create Main business line
CodeHelper.retrieveOrCreateCodeValue(25, requestSpec, responseSpec);
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
Workbook workbook=clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY,"dd MMMM yyyy");
ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Workbook workbook = clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY, "dd MMMM yyyy");
//insert dummy data into client entity sheet
// insert dummy data into client entity sheet
Sheet clientEntitySheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
Row firstClientRow=clientEntitySheet.getRow(1);
firstClientRow.createCell(ClientEntityConstants.NAME_COL).setCellValue(Utils.randomNameGenerator("C_E_",6));
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstClientRow = clientEntitySheet.getRow(1);
firstClientRow.createCell(ClientEntityConstants.NAME_COL).setCellValue(Utils.randomNameGenerator("C_E_", 6));
Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
firstClientRow.createCell(ClientEntityConstants.OFFICE_NAME_COL).setCellValue(staffSheet.getRow(1).getCell(0).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.STAFF_NAME_COL).setCellValue(staffSheet.getRow(1).getCell(1).getStringCellValue());
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy");
Date incoporationDate=simpleDateFormat.parse("14 May 2001");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date incoporationDate = simpleDateFormat.parse("14 May 2001");
firstClientRow.createCell(ClientEntityConstants.INCOPORATION_DATE_COL).setCellValue(incoporationDate);
Date validTill=simpleDateFormat.parse("14 May 2019");
Date validTill = simpleDateFormat.parse("14 May 2019");
firstClientRow.createCell(ClientEntityConstants.INCOPORATION_VALID_TILL_COL).setCellValue(validTill);
firstClientRow.createCell(ClientEntityConstants.MOBILE_NO_COL).setCellValue(Utils.randomNumberGenerator(7));
firstClientRow.createCell(ClientEntityConstants.CLIENT_TYPE_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_TYPES).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.CLIENT_CLASSIFICATION_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_CLASSIFICATION).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.CLIENT_TYPE_COL)
.setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_TYPES).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.CLIENT_CLASSIFICATION_COL)
.setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_CLASSIFICATION).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.INCOPORATION_NUMBER_COL).setCellValue(Utils.randomNumberGenerator(6));
firstClientRow.createCell(ClientEntityConstants.MAIN_BUSINESS_LINE).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_MAIN_BUSINESS_LINE).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.CONSTITUTION_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CONSTITUTION_COL).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.MAIN_BUSINESS_LINE)
.setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_MAIN_BUSINESS_LINE).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.CONSTITUTION_COL)
.setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CONSTITUTION_COL).getStringCellValue());
firstClientRow.createCell(ClientEntityConstants.ACTIVE_COL).setCellValue("False");
Date submittedDate=simpleDateFormat.parse("28 September 2017");
Date submittedDate = simpleDateFormat.parse("28 September 2017");
firstClientRow.createCell(ClientEntityConstants.SUBMITTED_ON_COL).setCellValue(submittedDate);
firstClientRow.createCell(ClientEntityConstants.ADDRESS_ENABLED).setCellValue("False");
File directory=new File(System.getProperty("user.home")+File.separator+"Fineract"+File.separator+"bulkimport"+File.separator+"integration_tests"+File.separator+"importhandler"+File.separator+"client") ;
File directory = new File(System.getProperty("user.home") + File.separator + "Fineract" + File.separator + "bulkimport"
+ File.separator + "integration_tests" + File.separator + "importhandler" + File.separator + "client");
if (!directory.exists()) {
directory.mkdirs();
}
File file= new File(directory+File.separator+"ClientEntity.xls");
OutputStream outputStream=new FileOutputStream(file);
File file = new File(directory + File.separator + "ClientEntity.xls");
OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream);
outputStream.close();
String importDocumentId=clientHelper.importClientEntityTemplate(file);
String importDocumentId = clientHelper.importClientEntityTemplate(file);
file.delete();
Assertions.assertNotNull(importDocumentId);
//Wait for the creation of output excel
// Wait for the creation of output excel
Thread.sleep(10000);
//check status column of output excel
String location=clientHelper.getOutputTemplateLocation(importDocumentId);
// check status column of output excel
String location = clientHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location);
Workbook outputWorkbook=new HSSFWorkbook(fileInputStream);
Workbook outputWorkbook = new HSSFWorkbook(fileInputStream);
Sheet outputClientEntitySheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
Row row= outputClientEntitySheet.getRow(1);
Row row = outputClientEntitySheet.getRow(1);
LOG.info("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(ClientEntityConstants.STATUS_COL).getStringCellValue());
Assertions.assertEquals("Imported",row.getCell(ClientEntityConstants.STATUS_COL).getStringCellValue());
Assertions.assertEquals("Imported", row.getCell(ClientEntityConstants.STATUS_COL).getStringCellValue());
outputWorkbook.close();
}
}
@@ -80,9 +80,9 @@ public class LoanImportHandlerTest {
public void testLoanImport() throws InterruptedException, IOException, ParseException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
// in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
OfficeDomain office = officeHelper.retrieveOfficeByID(outcome_office_creation);
@@ -102,55 +102,57 @@ public class LoanImportHandlerTest {
clientMap.put("active", "true");
clientMap.put("activationDate", "04 March 2011");
Integer outcome_client_creation= Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
Integer outcome_client_creation = Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
new Gson().toJson(clientMap), "clientId");
Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets
Integer outcome_group_creation = GroupHelper.createGroup(requestSpec,responseSpec,true);
// in order to populate helper sheets
Integer outcome_group_creation = GroupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets
Integer outcome_staff_creation = StaffHelper.createStaff(requestSpec,responseSpec);
// in order to populate helper sheets
Integer outcome_staff_creation = StaffHelper.createStaff(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
Map<String, Object> staffMap = StaffHelper.getStaff(requestSpec, responseSpec, outcome_staff_creation);
Assertions.assertNotNull(staffMap, "Could not retrieve created staff");
LoanTransactionHelper ltHelper=new LoanTransactionHelper(requestSpec,responseSpec);
LoanProductTestBuilder loanProductTestBuilder=new LoanProductTestBuilder();
String jsonLoanProduct=loanProductTestBuilder.build(null);
Integer outcome_lp_creation=ltHelper.getLoanProductId(jsonLoanProduct);
LoanTransactionHelper ltHelper = new LoanTransactionHelper(requestSpec, responseSpec);
LoanProductTestBuilder loanProductTestBuilder = new LoanProductTestBuilder();
String jsonLoanProduct = loanProductTestBuilder.build(null);
Integer outcome_lp_creation = ltHelper.getLoanProductId(jsonLoanProduct);
Assertions.assertNotNull(outcome_lp_creation, "Could not create Loan Product");
String loanProductStr = ltHelper.getLoanProductDetails(requestSpec, responseSpec, outcome_lp_creation);
Assertions.assertNotNull("Could not get created Loan Product" , loanProductStr);
Assertions.assertNotNull("Could not get created Loan Product", loanProductStr);
JsonPath loanProductJson = JsonPath.from(loanProductStr);
String fundName = Utils.randomNameGenerator("",9);
String fundName = Utils.randomNameGenerator("", 9);
FundsHelper fh = FundsHelper.create(fundName).externalId("fund-" + fundName).build();
Integer outcome_fund_creation= FundsResourceHandler.createFund(new Gson().toJson(fh),requestSpec,responseSpec);
Integer outcome_fund_creation = FundsResourceHandler.createFund(new Gson().toJson(fh), requestSpec, responseSpec);
Assertions.assertNotNull(outcome_fund_creation, "Could not create Fund");
String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5);
String paymentTypeDescription = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15);
Integer outcome_payment_creation= PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, paymentTypeName, paymentTypeDescription, true,1);
Integer outcome_payment_creation = PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, paymentTypeName,
paymentTypeDescription, true, 1);
Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
LoanTransactionHelper loanTransactionHelper=new LoanTransactionHelper(requestSpec,responseSpec);
Workbook workbook=loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy");
LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
Workbook workbook = loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy");
//insert dummy data into loan Sheet
// insert dummy data into loan Sheet
Sheet loanSheet = workbook.getSheet(TemplatePopulateImportConstants.LOANS_SHEET_NAME);
Row firstLoanRow=loanSheet.getRow(1);
Row firstLoanRow = loanSheet.getRow(1);
firstLoanRow.createCell(LoanConstants.OFFICE_NAME_COL).setCellValue(office.getName());
firstLoanRow.createCell(LoanConstants.LOAN_TYPE_COL).setCellValue("Individual");
firstLoanRow.createCell(LoanConstants.CLIENT_NAME_COL).setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
firstLoanRow.createCell(LoanConstants.CLIENT_NAME_COL)
.setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
firstLoanRow.createCell(LoanConstants.CLIENT_EXTERNAL_ID).setCellValue(externalId);
firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name"));
firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy");
Date date=simpleDateFormat.parse("13 May 2017");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date date = simpleDateFormat.parse("13 May 2017");
firstLoanRow.createCell(LoanConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
firstLoanRow.createCell(LoanConstants.APPROVED_DATE_COL).setCellValue(date);
firstLoanRow.createCell(LoanConstants.DISBURSED_DATE_COL).setCellValue(date);
@@ -159,16 +161,22 @@ public class LoanImportHandlerTest {
firstLoanRow.createCell(LoanConstants.PRINCIPAL_COL).setCellValue(loanProductJson.getFloat("principal"));
firstLoanRow.createCell(LoanConstants.NO_OF_REPAYMENTS_COL).setCellValue(loanProductJson.getInt("numberOfRepayments"));
firstLoanRow.createCell(LoanConstants.REPAID_EVERY_COL).setCellValue(loanProductJson.getInt("repaymentEvery"));
firstLoanRow.createCell(LoanConstants.REPAID_EVERY_FREQUENCY_COL).setCellValue(loanProductJson.getString("repaymentFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.LOAN_TERM_COL).setCellValue(loanProductJson.getInt("repaymentEvery") * loanProductJson.getInt("numberOfRepayments"));
firstLoanRow.createCell(LoanConstants.LOAN_TERM_FREQUENCY_COL).setCellValue(loanProductJson.getString("repaymentFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.REPAID_EVERY_FREQUENCY_COL)
.setCellValue(loanProductJson.getString("repaymentFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.LOAN_TERM_COL)
.setCellValue(loanProductJson.getInt("repaymentEvery") * loanProductJson.getInt("numberOfRepayments"));
firstLoanRow.createCell(LoanConstants.LOAN_TERM_FREQUENCY_COL)
.setCellValue(loanProductJson.getString("repaymentFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.NOMINAL_INTEREST_RATE_COL).setCellValue(loanProductJson.getDouble("interestRatePerPeriod"));
firstLoanRow.createCell(LoanConstants.NOMINAL_INTEREST_RATE_FREQUENCY_COL).setCellValue(loanProductJson.getString("interestRateFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.NOMINAL_INTEREST_RATE_FREQUENCY_COL)
.setCellValue(loanProductJson.getString("interestRateFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.AMORTIZATION_COL).setCellValue(loanProductJson.getString("amortizationType.value"));
firstLoanRow.createCell(LoanConstants.INTEREST_METHOD_COL).setCellValue(loanProductJson.getString("interestType.value"));
firstLoanRow.createCell(LoanConstants.INTEREST_CALCULATION_PERIOD_COL).setCellValue(loanProductJson.getString("interestCalculationPeriodType.value"));
firstLoanRow.createCell(LoanConstants.INTEREST_CALCULATION_PERIOD_COL)
.setCellValue(loanProductJson.getString("interestCalculationPeriodType.value"));
firstLoanRow.createCell(LoanConstants.ARREARS_TOLERANCE_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.REPAYMENT_STRATEGY_COL).setCellValue(loanProductJson.getString("transactionProcessingStrategyName"));
firstLoanRow.createCell(LoanConstants.REPAYMENT_STRATEGY_COL)
.setCellValue(loanProductJson.getString("transactionProcessingStrategyName"));
firstLoanRow.createCell(LoanConstants.GRACE_ON_PRINCIPAL_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_CHARGED_COL).setCellValue(0);
@@ -178,34 +186,34 @@ public class LoanImportHandlerTest {
firstLoanRow.createCell(LoanConstants.REPAYMENT_TYPE_COL).setCellValue(paymentTypeName);
String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"loan") ;
File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
+ "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "loan");
if (!directory.exists()) {
directory.mkdirs();
}
File file= new File(directory+File.separator+"Loan.xls");
OutputStream outputStream=new FileOutputStream(file);
File file = new File(directory + File.separator + "Loan.xls");
OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream);
outputStream.close();
String importDocumentId=loanTransactionHelper.importLoanTemplate(file);
String importDocumentId = loanTransactionHelper.importLoanTemplate(file);
file.delete();
Assertions.assertNotNull(importDocumentId);
//Wait for the creation of output excel
// Wait for the creation of output excel
Thread.sleep(10000);
//check status column of output excel
String location=loanTransactionHelper.getOutputTemplateLocation(importDocumentId);
// check status column of output excel
String location = loanTransactionHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location);
Workbook outputworkbook=new HSSFWorkbook(fileInputStream);
Workbook outputworkbook = new HSSFWorkbook(fileInputStream);
Sheet outputLoanSheet = outputworkbook.getSheet(TemplatePopulateImportConstants.LOANS_SHEET_NAME);
Row row= outputLoanSheet.getRow(1);
Row row = outputLoanSheet.getRow(1);
LOG.info("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(LoanConstants.FAILURE_REPORT_COL).getStringCellValue());
Assertions.assertEquals("Imported",row.getCell(LoanConstants.STATUS_COL).getStringCellValue());
Assertions.assertEquals("Imported", row.getCell(LoanConstants.STATUS_COL).getStringCellValue());
outputworkbook.close();
}
}
@@ -52,56 +52,54 @@ public class OfficeImportHandlerTest {
private RequestSpecification requestSpec;
@BeforeEach
public void setup(){
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec=new RequestSpecBuilder().build();
this.requestSpec
.header("Authorization",
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
public void testOfficeImport() throws IOException, InterruptedException, NoSuchFieldException, ParseException {
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Workbook workbook=officeHelper.getOfficeWorkBook("dd MMMM yyyy");
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Workbook workbook = officeHelper.getOfficeWorkBook("dd MMMM yyyy");
//insert dummy data into excel
Sheet sheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow= sheet.getRow(1);
firstOfficeRow.createCell(OfficeConstants.OFFICE_NAME_COL).setCellValue(Utils.randomNameGenerator("Test_Off_",6));
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_NAME_COL).setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue());
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_ID_COL).setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_ID_COL).getNumericCellValue());
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy");
Date date=simpleDateFormat.parse("14 May 2001");
// insert dummy data into excel
Sheet sheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow = sheet.getRow(1);
firstOfficeRow.createCell(OfficeConstants.OFFICE_NAME_COL).setCellValue(Utils.randomNameGenerator("Test_Off_", 6));
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_NAME_COL)
.setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue());
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_ID_COL)
.setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_ID_COL).getNumericCellValue());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date date = simpleDateFormat.parse("14 May 2001");
firstOfficeRow.createCell(OfficeConstants.OPENED_ON_COL).setCellValue(date);
String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"office");
File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
+ "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "office");
if (!directory.exists()) {
directory.mkdirs();
}
File file= new File(directory+File.separator+"Office.xls");
OutputStream outputStream=new FileOutputStream(file);
File file = new File(directory + File.separator + "Office.xls");
OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream);
outputStream.close();
String importDocumentId=officeHelper.importOfficeTemplate(file);
String importDocumentId = officeHelper.importOfficeTemplate(file);
file.delete();
Assertions.assertNotNull(importDocumentId);
// Wait for the creation of output excel
Thread.sleep(10000);
//check status column of output excel
String location=officeHelper.getOutputTemplateLocation(importDocumentId);
// check status column of output excel
String location = officeHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location);
Workbook outputWorkbook=new HSSFWorkbook(fileInputStream);
Workbook outputWorkbook = new HSSFWorkbook(fileInputStream);
Sheet officeSheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row row= officeSheet.getRow(1);
Row row = officeSheet.getRow(1);
LOG.info("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(OfficeConstants.STATUS_COL).getStringCellValue());
@@ -77,9 +77,9 @@ public class SavingsImportHandlerTest {
public void testSavingsImport() throws InterruptedException, IOException, ParseException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
// in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
OfficeDomain office = officeHelper.retrieveOfficeByID(outcome_office_creation);
@@ -99,87 +99,98 @@ public class SavingsImportHandlerTest {
clientMap.put("active", "true");
clientMap.put("activationDate", "04 March 2011");
Integer outcome_client_creation= Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
Integer outcome_client_creation = Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
new Gson().toJson(clientMap), "clientId");
Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets
Integer outcome_group_creation=GroupHelper.createGroup(requestSpec,responseSpec,true);
// in order to populate helper sheets
Integer outcome_group_creation = GroupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets
Integer outcome_staff_creation =StaffHelper.createStaff(requestSpec,responseSpec);
// in order to populate helper sheets
Integer outcome_staff_creation = StaffHelper.createStaff(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
Map<String, Object> staffMap = StaffHelper.getStaff(requestSpec, responseSpec, outcome_staff_creation);
Assertions.assertNotNull(staffMap, "Could not retrieve created staff");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
String jsonSavingsProduct=savingsProductHelper.build();
Integer outcome_sp_creaction=SavingsProductHelper.createSavingsProduct(jsonSavingsProduct,requestSpec,responseSpec);
String jsonSavingsProduct = savingsProductHelper.build();
Integer outcome_sp_creaction = SavingsProductHelper.createSavingsProduct(jsonSavingsProduct, requestSpec, responseSpec);
Assertions.assertNotNull(outcome_sp_creaction, "Could not create Savings product");
SavingsAccountHelper savingsAccountHelper=new SavingsAccountHelper(requestSpec,responseSpec);
Workbook workbook=savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy");
SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
Workbook workbook = savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy");
//insert dummy data into Savings sheet
// insert dummy data into Savings sheet
Sheet savingsSheet = workbook.getSheet(TemplatePopulateImportConstants.SAVINGS_ACCOUNTS_SHEET_NAME);
Row firstSavingsRow=savingsSheet.getRow(1);
Row firstSavingsRow = savingsSheet.getRow(1);
firstSavingsRow.createCell(SavingsConstants.OFFICE_NAME_COL).setCellValue(office.getName());
firstSavingsRow.createCell(SavingsConstants.SAVINGS_TYPE_COL).setCellValue("Individual");
firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL).setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
Sheet savingsProductSheet=workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
firstSavingsRow.createCell(SavingsConstants.PRODUCT_COL).setCellValue(savingsProductSheet.getRow(1).getCell(1).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL)
.setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
Sheet savingsProductSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
firstSavingsRow.createCell(SavingsConstants.PRODUCT_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(1).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.FIELD_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy");
Date date=simpleDateFormat.parse("13 May 2017");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date date = simpleDateFormat.parse("13 May 2017");
firstSavingsRow.createCell(SavingsConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.APPROVED_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.ACTIVATION_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.CURRENCY_COL).setCellValue(savingsProductSheet.getRow(1).getCell(10).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.DECIMAL_PLACES_COL).setCellValue(savingsProductSheet.getRow(1).getCell(11).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.IN_MULTIPLES_OF_COL).setCellValue(savingsProductSheet.getRow(1).getCell(12).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.NOMINAL_ANNUAL_INTEREST_RATE_COL).setCellValue(savingsProductSheet.getRow(1).getCell(2).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_COMPOUNDING_PERIOD_COL).setCellValue(savingsProductSheet.getRow(1).getCell(3).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_POSTING_PERIOD_COL).setCellValue(savingsProductSheet.getRow(1).getCell(4).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_COL).setCellValue(savingsProductSheet.getRow(1).getCell(5).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_DAYS_IN_YEAR_COL).setCellValue(savingsProductSheet.getRow(1).getCell(6).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.CURRENCY_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(10).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.DECIMAL_PLACES_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(11).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.IN_MULTIPLES_OF_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(12).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.NOMINAL_ANNUAL_INTEREST_RATE_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(2).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_COMPOUNDING_PERIOD_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(3).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_POSTING_PERIOD_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(4).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(5).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_DAYS_IN_YEAR_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(6).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.MIN_OPENING_BALANCE_COL).setCellValue(1000.0);
firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_COL).setCellValue(1);
firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_FREQUENCY_COL).setCellValue("Weeks");
firstSavingsRow.createCell(SavingsConstants.APPLY_WITHDRAWAL_FEE_FOR_TRANSFERS).setCellValue("False");
firstSavingsRow.createCell(SavingsConstants.ALLOW_OVER_DRAFT_COL).setCellValue("False");
firstSavingsRow.createCell(SavingsConstants.OVER_DRAFT_LIMIT_COL).setCellValue(savingsProductSheet.getRow(1).getCell(15).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.OVER_DRAFT_LIMIT_COL)
.setCellValue(savingsProductSheet.getRow(1).getCell(15).getNumericCellValue());
String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"savings") ;
File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
+ "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "savings");
if (!directory.exists()) {
directory.mkdirs();
}
File file= new File(directory+File.separator+"Savings.xls");
OutputStream outputStream=new FileOutputStream(file);
File file = new File(directory + File.separator + "Savings.xls");
OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream);
outputStream.close();
String importDocumentId=savingsAccountHelper.importSavingsTemplate(file);
String importDocumentId = savingsAccountHelper.importSavingsTemplate(file);
file.delete();
Assertions.assertNotNull(importDocumentId);
//Wait for the creation of output excel
// Wait for the creation of output excel
Thread.sleep(10000);
//check status column of output excel
String location=savingsAccountHelper.getOutputTemplateLocation(importDocumentId);
// check status column of output excel
String location = savingsAccountHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location);
Workbook Outputworkbook=new HSSFWorkbook(fileInputStream);
Workbook Outputworkbook = new HSSFWorkbook(fileInputStream);
Sheet OutputSavingsSheet = Outputworkbook.getSheet(TemplatePopulateImportConstants.SAVINGS_ACCOUNTS_SHEET_NAME);
Row row= OutputSavingsSheet.getRow(1);
Row row = OutputSavingsSheet.getRow(1);
LOG.info("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(SavingsConstants.STATUS_COL).getStringCellValue());
Assertions.assertEquals("Imported",row.getCell(SavingsConstants.STATUS_COL).getStringCellValue());
Assertions.assertEquals("Imported", row.getCell(SavingsConstants.STATUS_COL).getStringCellValue());
Outputworkbook.close();
}
}
@@ -44,39 +44,34 @@ public class ClientEntityWorkbookPopulatorTest {
private RequestSpecification requestSpec;
@BeforeEach
public void setup(){
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec=new RequestSpecBuilder().build();
this.requestSpec
.header("Authorization",
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
public void testClientEntityWorkbookPopulate() throws IOException {
//in order to populate helper sheets
StaffHelper staffHelper=new StaffHelper();
// in order to populate helper sheets
StaffHelper staffHelper = new StaffHelper();
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
Integer outcome_staff_creation = staffHelper.createStaff(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
//in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
// in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
Workbook workbook=clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY,"dd MMMM yyyy");
Sheet officeSheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow=officeSheet.getRow(1);
ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Workbook workbook = clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY, "dd MMMM yyyy");
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found for given OfficeId ");
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow=staffSheet.getRow(1);
Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow = staffSheet.getRow(1);
Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found for given staffId");
}
}
@@ -49,80 +49,80 @@ public class LoanWorkbookPopulatorTest {
private RequestSpecification requestSpec;
@BeforeEach
public void setup(){
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
public void testLoanWorkbookPopulate() throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
// in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
//in order to populate helper sheets
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec);
// in order to populate helper sheets
ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Integer outcome_client_creation = clientHelper.createClient(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets
GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec);
Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true);
// in order to populate helper sheets
GroupHelper groupHelper = new GroupHelper(requestSpec, responseSpec);
Integer outcome_group_creation = groupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets
StaffHelper staffHelper=new StaffHelper();
Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
// in order to populate helper sheets
StaffHelper staffHelper = new StaffHelper();
Integer outcome_staff_creation = staffHelper.createStaff(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
LoanTransactionHelper loanTransactionHelper=new LoanTransactionHelper(requestSpec,responseSpec);
LoanProductTestBuilder loanProductTestBuilder=new LoanProductTestBuilder();
String jsonLoanProduct=loanProductTestBuilder.build(null);
Integer outcome_lp_creaion=loanTransactionHelper.getLoanProductId(jsonLoanProduct);
LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
LoanProductTestBuilder loanProductTestBuilder = new LoanProductTestBuilder();
String jsonLoanProduct = loanProductTestBuilder.build(null);
Integer outcome_lp_creaion = loanTransactionHelper.getLoanProductId(jsonLoanProduct);
Assertions.assertNotNull(outcome_lp_creaion, "Could not create Loan Product");
FundsResourceHandler fundsResourceHandler=new FundsResourceHandler();
String jsonFund="{\n" +
"\t\"name\": \""+Utils.randomNameGenerator("Fund_Name",9)+"\"\n" +
"}";
Integer outcome_fund_creation=fundsResourceHandler.createFund(jsonFund,requestSpec,responseSpec);
FundsResourceHandler fundsResourceHandler = new FundsResourceHandler();
String jsonFund = "{\n" + "\t\"name\": \"" + Utils.randomNameGenerator("Fund_Name", 9) + "\"\n" + "}";
Integer outcome_fund_creation = fundsResourceHandler.createFund(jsonFund, requestSpec, responseSpec);
Assertions.assertNotNull(outcome_fund_creation, "Could not create Fund");
PaymentTypeHelper paymentTypeHelper=new PaymentTypeHelper();
PaymentTypeHelper paymentTypeHelper = new PaymentTypeHelper();
String name = PaymentTypeHelper.randomNameGenerator("P_T", 5);
String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15);
Boolean isCashPayment = true;
Integer position = 1;
Integer outcome_payment_creation= paymentTypeHelper.createPaymentType(requestSpec, responseSpec,name,description,isCashPayment,position);
Integer outcome_payment_creation = paymentTypeHelper.createPaymentType(requestSpec, responseSpec, name, description, isCashPayment,
position);
Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
Workbook workbook=loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy");
Workbook workbook = loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy");
Sheet officeSheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow=officeSheet.getRow(1);
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found ");
Sheet clientSheet=workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME);
Row firstClientRow=clientSheet.getRow(1);
Sheet clientSheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME);
Row firstClientRow = clientSheet.getRow(1);
Assertions.assertNotNull(firstClientRow.getCell(1), "No clients found ");
Sheet groupSheet=workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME);
Row firstGroupRow=groupSheet.getRow(1);
Sheet groupSheet = workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME);
Row firstGroupRow = groupSheet.getRow(1);
Assertions.assertNotNull(firstGroupRow.getCell(1), "No groups found ");
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow=staffSheet.getRow(1);
Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow = staffSheet.getRow(1);
Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found ");
Sheet productSheet=workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
Row firstProductRow=productSheet.getRow(1);
Sheet productSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
Row firstProductRow = productSheet.getRow(1);
Assertions.assertNotNull(firstProductRow.getCell(1), "No products found ");
Sheet extrasSheet=workbook.getSheet(TemplatePopulateImportConstants.EXTRAS_SHEET_NAME);
Row firstExtrasRow=extrasSheet.getRow(1);
Sheet extrasSheet = workbook.getSheet(TemplatePopulateImportConstants.EXTRAS_SHEET_NAME);
Row firstExtrasRow = extrasSheet.getRow(1);
Assertions.assertNotNull(firstExtrasRow.getCell(1), "No Extras found ");
}
}
@@ -35,27 +35,24 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class OfficeWorkBookPopulatorTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@BeforeEach
public void setup(){
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec=new RequestSpecBuilder().build();
this.requestSpec
.header("Authorization",
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
public void testOfficeWorkbookPopulate() throws IOException {
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Workbook workbook=officeHelper.getOfficeWorkBook("dd MMMM yyyy");
Sheet sheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstRow= sheet.getRow(1);
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Workbook workbook = officeHelper.getOfficeWorkBook("dd MMMM yyyy");
Sheet sheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstRow = sheet.getRow(1);
Assertions.assertNotNull("No parent offices found", firstRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue());
Assertions.assertEquals(1, firstRow.getCell(OfficeConstants.LOOKUP_OFFICE_ID_COL).getNumericCellValue(), 0.0);
@@ -42,11 +42,12 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class SavingsWorkbookPopulateTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@BeforeEach
public void setup(){
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
@@ -56,52 +57,52 @@ public class SavingsWorkbookPopulateTest {
@Test
public void testSavingsWorkbookPopulate() throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
// in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
//in order to populate helper sheets
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec);
// in order to populate helper sheets
ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Integer outcome_client_creation = clientHelper.createClient(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets
GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec);
Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true);
// in order to populate helper sheets
GroupHelper groupHelper = new GroupHelper(requestSpec, responseSpec);
Integer outcome_group_creation = groupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets
StaffHelper staffHelper=new StaffHelper();
Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
// in order to populate helper sheets
StaffHelper staffHelper = new StaffHelper();
Integer outcome_staff_creation = staffHelper.createStaff(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
SavingsProductHelper savingsProductHelper=new SavingsProductHelper();
String jsonSavingsProduct=savingsProductHelper.build();
Integer outcome_sp_creaction=savingsProductHelper.createSavingsProduct(jsonSavingsProduct,requestSpec,responseSpec);
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
String jsonSavingsProduct = savingsProductHelper.build();
Integer outcome_sp_creaction = savingsProductHelper.createSavingsProduct(jsonSavingsProduct, requestSpec, responseSpec);
Assertions.assertNotNull(outcome_sp_creaction, "Could not create Savings product");
SavingsAccountHelper savingsAccountHelper=new SavingsAccountHelper(requestSpec,responseSpec);
Workbook workbook=savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy");
SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
Workbook workbook = savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy");
Sheet officeSheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow=officeSheet.getRow(1);
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found ");
Sheet clientSheet=workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME);
Row firstClientRow=clientSheet.getRow(1);
Sheet clientSheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME);
Row firstClientRow = clientSheet.getRow(1);
Assertions.assertNotNull(firstClientRow.getCell(1), "No clients found ");
Sheet groupSheet=workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME);
Row firstGroupRow=groupSheet.getRow(1);
Sheet groupSheet = workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME);
Row firstGroupRow = groupSheet.getRow(1);
Assertions.assertNotNull(firstGroupRow.getCell(1), "No groups found ");
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow=staffSheet.getRow(1);
Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow = staffSheet.getRow(1);
Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found ");
Sheet productSheet=workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
Row firstProductRow=productSheet.getRow(1);
Sheet productSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
Row firstProductRow = productSheet.getRow(1);
Assertions.assertNotNull(firstProductRow.getCell(1), "No products found ");
}
@@ -32,15 +32,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It
* takes care of creation of {@code BatchRequest} list and posting this list to
* the server.
* Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}.
* It takes care of creation of {@code BatchRequest} list and posting this list
* to the server.
*
* @author Rishabh Shukla
*
* @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";
@@ -190,14 +191,14 @@ public class BatchHelper {
}
final String body = "{ \"officeId\": 1, \"firstname\": \"Petra\", \"lastname\": \"Yton\"," + "\"externalId\": \"" + externalId
+ "\", \"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en\"," + "\"active\": true, \"activationDate\": \"04 March 2010\", \"submittedOnDate\": \"04 March 2010\"}";
+ "\", \"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en\","
+ "\"active\": true, \"activationDate\": \"04 March 2010\", \"submittedOnDate\": \"04 March 2010\"}";
br.setBody(body);
return br;
}
/**
* Creates and returns a
* {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy}
@@ -408,8 +409,8 @@ public class BatchHelper {
br.setReference(reference);
br.setRelativeUrl("loans/$.loanId/transactions?command=repayment");
br.setMethod("POST");
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", " +
"\"transactionDate\": \"15 September 2013\", \"transactionAmount\": 500}");
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", "
+ "\"transactionDate\": \"15 September 2013\", \"transactionAmount\": 500}");
return br;
}
@@ -29,6 +29,7 @@ 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/";
@@ -43,7 +44,7 @@ public class CalendarHelper {
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL);
LOG.info("{}", CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -57,7 +58,7 @@ public class CalendarHelper {
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "/" + calendarID;
LOG.info("{}",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");
@@ -76,7 +77,7 @@ public class CalendarHelper {
map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4));
map.put("typeId", "1");
map.put("startDate", startDate);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -87,17 +88,17 @@ public class CalendarHelper {
final String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL,
"collectionMeetingCalendar");
final Integer responseCalendarId = from(responseCalendarDetailsinJSON).get("id");
assertEquals( generatedCalendarId, responseCalendarId, "ERROR IN CREATING THE CALENDAR");
assertEquals(generatedCalendarId, responseCalendarId, "ERROR IN CREATING THE CALENDAR");
}
public static Integer createMeetingForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) {
final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) {
LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL);
LOG.info("{}", CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -111,7 +112,7 @@ public class CalendarHelper {
final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + centerId + ENITY_NAME + "/" + calendarID + "?"
+ Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL);
LOG.info("{}", CALENDAR_RESOURCE_URL);
return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarMeetingAsJSON(oldDate, startDate),
"resourceId");
@@ -128,4 +129,4 @@ public class CalendarHelper {
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
}
}
@@ -26,7 +26,9 @@ 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 final Integer id;
@@ -84,9 +86,9 @@ public class CenterDomain implements Comparable<CenterDomain> {
/* super(); */
}
private CenterDomain(final Integer id, final String accountNo, final Integer statusid, final String statuscode, final String statusvalue, final boolean active,
final String name, final String externalId, final Integer staffId, final Integer officeId, final String officeName,
final String hierarchy, final ArrayList<HashMap> groupMembers) {
private CenterDomain(final Integer id, final String accountNo, final Integer statusid, final String statuscode,
final String statusvalue, final boolean active, final String name, final String externalId, final Integer staffId,
final Integer officeId, final String officeName, final String hierarchy, final ArrayList<HashMap> groupMembers) {
this.id = id;
this.accountNo = accountNo;
this.status = new HashMap<>();
@@ -163,7 +165,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
if (groupMembers != null) {
map.put("groupMembers", groupMembers);
}
LOG.info("{}",map.toString());
LOG.info("{}", map.toString());
return new Gson().toJson(map);
}
@@ -211,7 +213,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
return this.hierarchy;
}
public String getAccountNo(){
public String getAccountNo() {
return this.accountNo;
}
@@ -256,15 +258,11 @@ public class CenterDomain implements Comparable<CenterDomain> {
public boolean equals(Object obj) {
if (obj == this) { return true; }
if (!(obj instanceof CenterDomain)) {
return false;
}
if (!(obj instanceof CenterDomain)) { return false; }
CenterDomain cd = (CenterDomain) obj;
if (this.hashCode() == cd.hashCode()) {
return true;
}
if (this.hashCode() == cd.hashCode()) { return true; }
return false;
}
@@ -32,6 +32,7 @@ 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";
@@ -40,7 +41,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;
LOG.info("------------------------ 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());
@@ -110,7 +111,7 @@ public class CenterHelper {
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;
LOG.info("---------------------------------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;
@@ -121,10 +122,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);
LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------",id);
HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL,
new Gson().toJson(groupMemberHashMap), "changes");
LOG.info("{}",hash.toString());
LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------", id);
HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL, new Gson().toJson(groupMemberHashMap),
"changes");
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++) {
@@ -135,7 +136,7 @@ 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;
LOG.info("---------------------------------DELETING CENTER AT {}--------------------------------------------",id);
LOG.info("---------------------------------DELETING CENTER AT {}--------------------------------------------", id);
Utils.performServerDelete(requestSpec, responseSpec, DELETE_CENTER_URL, "");
}
@@ -182,7 +183,8 @@ 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;
final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&"
+ Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------ACTIVATE A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId");
}
@@ -201,7 +203,7 @@ public class CenterHelper {
int[] groupMembers = null;
String submittedDate = null;
return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate,submittedDate,name,
return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate, submittedDate, name,
externalId, staffId, officeID, officeName, hierarchy, groupMembers);
}
@@ -220,7 +222,7 @@ public class CenterHelper {
final int[] groupMembers = null;
String submittedDate = null;
return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate,submittedDate,name,
return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate, submittedDate, name,
externalId, staffId, officeID, officeName, hierarchy, groupMembers);
}
@@ -228,14 +230,14 @@ public class CenterHelper {
public static String assignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId);
LOG.info("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);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -249,7 +251,7 @@ public class CenterHelper {
map.put("activationDate", "CREATED_DATE");
LOG.info("defaulting to fixed date: CREATED_DATE");
}
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -257,8 +259,8 @@ public class CenterHelper {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
}
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final Long staffId) {
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,
final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
LOG.info("---------------------------------Assign Staff---------------------------------------------");
@@ -96,8 +96,8 @@ public class ClientChargesTest {
* Revert the paid client charge transaction by passing the
* clientChargePaidTransactionId and ensure the same is reverted.
*/
final Integer undoTrxnId = ClientHelper.revertClientChargeTransaction(this.requestSpec, this.responseSpec,
clientId.toString(), clientChargePaidTransactionId);
final Integer undoTrxnId = ClientHelper.revertClientChargeTransaction(this.requestSpec, this.responseSpec, clientId.toString(),
clientChargePaidTransactionId);
Assertions.assertNotNull(undoTrxnId);
isReversedTransaction(clientId.toString(), undoTrxnId.toString());
/**
@@ -40,6 +40,7 @@ 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;
@@ -69,8 +70,7 @@ 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");
}
@@ -82,79 +82,72 @@ public class ClientHelper {
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) {
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestClientAsJSON(activationDate, officeId), "clientId");
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) {
LOG.info(
"---------------------------------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) {
LOG.info(
"---------------------------------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) {
LOG.info(
"-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------");
public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String registeredTableName) {
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) {
LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestPersonClientAsJSON(activationDate, officeId), "clientId");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId),
"clientId");
}
public static Integer createClientAsEntity(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
}
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")
Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec)
.get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper
.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
@@ -162,29 +155,27 @@ public class ClientHelper {
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";
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";
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL,
assignStaffToClientAsJson(staffId), "changes");
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes");
}
public static Integer getClientsStaffId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String clientId) {
public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId) {
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
}
@@ -283,8 +274,7 @@ public class ClientHelper {
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));
@@ -306,17 +296,16 @@ public class ClientHelper {
return new Gson().toJson(map);
}
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer generatedClientID) {
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 String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT");
}
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;
LOG.info("---------------------------------GET A CLIENT---------------------------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn);
@@ -325,8 +314,8 @@ public class ClientHelper {
/* 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");
}
@@ -343,8 +332,7 @@ 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());
@@ -399,8 +387,8 @@ public class ClientHelper {
Integer clientRejectionReasonCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientRejectReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId,
this.requestSpec, this.responseSpec);
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId, this.requestSpec,
this.responseSpec);
Integer rejectionReasonId = (Integer) codeValue.get("id");
map.put("locale", CommonConstants.LOCALE);
@@ -431,8 +419,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);
@@ -479,20 +467,17 @@ public class ClientHelper {
public HashMap<String, Object> closeClient(final Integer clientId) {
LOG.info("--------------------------------- CLOSE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(),
clientId);
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
}
public HashMap<String, Object> reactivateClient(final Integer clientId) {
LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId),
getReactivateClientAsJSON(), clientId);
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
}
public HashMap<String, Object> rejectClient(final Integer clientId) {
LOG.info("--------------------------------- REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(),
clientId);
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
}
public HashMap<String, Object> activateClient(final Integer clientId) {
@@ -503,8 +488,7 @@ public class ClientHelper {
public HashMap<String, Object> withdrawClient(final Integer clientId) {
LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId),
getWithdrawClientAsJSON(), clientId);
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
}
private String createClientOperationURL(final String command, final Integer clientId) {
@@ -523,113 +507,102 @@ public class ClientHelper {
getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId);
}
public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId,
final String jsonAttributeToGetBack, final String rejectedDate) {
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) {
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),
return performClientActionsWithValidationErrors(createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack);
}
public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId,
final String jsonAttributeToGetBack) {
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) {
public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId, final String activationDate) {
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(activationDate), clientId);
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(activationDate),
clientId);
}
private ArrayList<HashMap<String, Object>> performClientActionsWithValidationErrors(final String postURLForClient,
final String jsonToBeSent, final String jsonAttributeToGetBack) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent,
jsonAttributeToGetBack);
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, 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) {
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 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) {
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 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) {
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 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) {
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 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) {
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) {
LOG.info(
"---------------------------------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);
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;
@@ -638,8 +611,7 @@ public class ClientHelper {
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);
"/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
}
public String importClientEntityTemplate(File file) {
@@ -647,8 +619,7 @@ public class ClientHelper {
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);
}
}
@@ -18,7 +18,6 @@
*/
package org.apache.fineract.integrationtests.common;
public interface CommonConstants {
public final static String LOCALE = "en";
@@ -29,6 +29,7 @@ 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";
@@ -57,9 +58,7 @@ public class CurrenciesHelper {
final String code) {
ArrayList<CurrencyDomain> currenciesList = getAllCurrencies(requestSpec, responseSpec);
for (CurrencyDomain e : currenciesList) {
if (e.getCode().equals(code)) {
return e;
}
if (e.getCode().equals(code)) { return e; }
}
return null;
}
@@ -75,7 +74,7 @@ public class CurrenciesHelper {
private static String currenciesToJSON(final ArrayList<String> currencies) {
HashMap map = new HashMap<>();
map.put("currencies", currencies);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
}
@@ -57,8 +57,8 @@ public class CurrencyDomain implements Comparable<CurrencyDomain> {
super();
}
private CurrencyDomain(final String code, final String name, final int decimalPlaces, final String displaySymbol,
final String nameCode, final String displayLabel) {
private CurrencyDomain(final String code, final String name, final int decimalPlaces, final String displaySymbol, final String nameCode,
final String displayLabel) {
super();
this.code = code;
this.name = name;
@@ -135,9 +135,7 @@ public class CurrencyDomain implements Comparable<CurrencyDomain> {
public boolean equals(Object obj) {
if (obj == this) { return true; }
if (!(obj instanceof CurrencyDomain)) {
return false;
}
if (!(obj instanceof CurrencyDomain)) { return false; }
CurrencyDomain cd = (CurrencyDomain) obj;
@@ -29,27 +29,27 @@ 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
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
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), "");
@@ -29,6 +29,7 @@ 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,11 +39,13 @@ public class GlobalConfigurationHelper {
this.responseSpec = responseSpec;
}
public static ArrayList<HashMap> getAllGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
public static ArrayList<HashMap> getAllGlobalConfigurations(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------");
final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, "");
return response.get("globalConfiguration");
final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL,
"");
return response.get("globalConfiguration");
}
public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@@ -52,30 +55,35 @@ public class GlobalConfigurationHelper {
return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, "");
}
public static void resetAllDefaultGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
public static void resetAllDefaultGlobalConfigurations(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
final ArrayList<HashMap> defaults = getAllDefaultGlobalConfigurations();
for (HashMap configDefault : defaults) {
/**
* Cannot update trapDoor global configurations because
* {@link org.apache.fineract.infrastructure.configuration.exception.GlobalConfigurationPropertyCannotBeModfied}
* {@link org.apache.fineract.infrastructure.configuration.exception.GlobalConfigurationPropertyCannotBeModfied}
* will be thrown.
*/
if ((Boolean)configDefault.get("trapDoor")) {
if ((Boolean) configDefault.get("trapDoor")) {
continue;
}
// Currently only values and enabled flags are modified by the integration test suite.
// If any other column is modified by the integration test suite in the future, it needs to be reset here.
final Integer configDefaultId = (Integer)configDefault.get("id");
final Integer configDefaultValue = (Integer)configDefault.get("value");
// Currently only values and enabled flags are modified by the
// integration test suite.
// If any other column is modified by the integration test suite in
// the future, it needs to be reset here.
final Integer configDefaultId = (Integer) configDefault.get("id");
final Integer configDefaultValue = (Integer) configDefault.get("value");
updateValueForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), configDefaultValue.toString());
updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), (Boolean)configDefault.get("enabled"));
updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(),
(Boolean) configDefault.get("enabled"));
}
}
public static void verifyAllDefaultGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
public static void verifyAllDefaultGlobalConfigurations(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
ArrayList<HashMap> expectedGlobalConfigurations = getAllDefaultGlobalConfigurations();
ArrayList<HashMap> actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec);
@@ -92,19 +100,26 @@ public class GlobalConfigurationHelper {
Assertions.assertEquals(expectedGlobalConfiguration.get("id"), actualGlobalConfiguration.get("id"));
final String assertionFailedMessage = "Assertion failed for configID:<" + expectedGlobalConfiguration.get("id") + ">";
Assertions.assertEquals(expectedGlobalConfiguration.get("name"), actualGlobalConfiguration.get("name"), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.get("value"), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.get("enabled"), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.get("trapDoor"), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.get("value"),
assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.get("enabled"),
assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.get("trapDoor"),
assertionFailedMessage);
}
}
/**
* Helper method to get the current default instance data of the /configurations endpoint.
* Used to reset and verify that no global configuration affects state between integration tests.
* @see <a href="https://issues.apache.org/jira/browse/FINERACT-722">FINERACT-722</a>
* This is a quick, fail fast and early implementation to resolve this issue.
* TODO: A more robust future solution would be isolating all integration test state using Spring Framework's
* integration test infrastructure for transaction commits and rollbacks.
* Helper method to get the current default instance data of the
* /configurations endpoint. Used to reset and verify that no global
* configuration affects state between integration tests.
*
* @see <a href=
* "https://issues.apache.org/jira/browse/FINERACT-722">FINERACT-722</a>
* This is a quick, fail fast and early implementation to resolve this
* issue. TODO: A more robust future solution would be isolating all
* integration test state using Spring Framework's integration test
* infrastructure for transaction commits and rollbacks.
*/
private static ArrayList<HashMap> getAllDefaultGlobalConfigurations() {
@@ -370,41 +385,42 @@ 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 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;
LOG.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL,
updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack);
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, updatePasswordResetDaysGlobalConfigAsJSON(value, enabled),
jsonAttributeToGetBack);
}
public static String updateGlobalConfigUpdateValueAsJSON(final String value) {
final HashMap<String, String> map = new HashMap<>();
map.put("value", value);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
public static String updatePasswordResetDaysGlobalConfigAsJSON(final String value, final String enabled) {
final HashMap<String, String> map = new HashMap<>();
if(value != null){
if (value != null) {
map.put("value", value);
}
map.put("enabled", enabled);
LOG.info("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);
LOG.info("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);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -70,25 +70,25 @@ public class GroupHelper {
jsonAttributeToGetBack);
}
public static Integer createGroupPendingWithDatatable(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String registeredTableName) {
public static Integer createGroupPendingWithDatatable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String registeredTableName) {
LOG.info("-------------------------- CREATING A GROUP WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL,
getTestGroupWithDatatableAsJson(registeredTableName), "groupId");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL, getTestGroupWithDatatableAsJson(registeredTableName),
"groupId");
}
public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final String clientMember) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId
+ "?command=associateClients&" + Utils.TENANT_IDENTIFIER;
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?command=associateClients&"
+ Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------Associate Client To A GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
}
public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final String clientMember) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId
+ "?command=disassociateClients&" + Utils.TENANT_IDENTIFIER;
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?command=disassociateClients&"
+ Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------Disassociate Client To A GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
}
@@ -107,23 +107,29 @@ public class GroupHelper {
return Utils.performServerPut(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, updateGroupAsJSON(name), "groupId");
}
public static Integer deleteGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId) {
public static Integer deleteGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId");
}
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,final Long staffId){
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff";
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,
final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,assignStaffAsJSON(staffId),"changes");
}
public static Object assignStaffInheritStaffForClientAccounts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,final String staffId){
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff";
LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,assignStaffAndInheritStaffForClientAccountsAsJSON(staffId),"changes");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, assignStaffAsJSON(staffId), "changes");
}
public static Object assignStaffInheritStaffForClientAccounts(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String groupId, final String staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,
assignStaffAndInheritStaffForClientAccountsAsJSON(staffId), "changes");
}
public static String getTestGroupAsJSON(final boolean active, final String activationDate) {
final HashMap<String, String> map = new HashMap<>();
@@ -173,21 +179,22 @@ public class GroupHelper {
LOG.debug("map : {}", map);
return new Gson().toJson(map);
}
public static String assignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId);
LOG.debug("map : {}", map);
return new Gson().toJson(map);
}
public static String assignStaffAndInheritStaffForClientAccountsAsJSON(final String staffId) {
final HashMap<String, String> map = new HashMap<>();
map.put("staffId", staffId);
map.put("inheritStaffForClientAccounts","true");
map.put("inheritStaffForClientAccounts", "true");
LOG.debug("map : {}", map);
return new Gson().toJson(map);
}
public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedGroupID) {
LOG.info("------------------------------CHECK GROUP DETAILS------------------------------------\n");
@@ -216,8 +223,8 @@ public class GroupHelper {
final Integer generatedGroupID, final Integer groupMember) {
List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP MEMBERS------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER;
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&"
+ Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
LOG.debug("the list of verifyEmptyGroupMembers : {} ", list);
assertTrue(list.toString().contains("id=" + groupMember.toString()), "ERROR IN GROUP MEMBER");
@@ -227,8 +234,8 @@ public class GroupHelper {
final Integer generatedGroupID) {
List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER;
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&"
+ Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
LOG.debug("the list of verifyEmptyGroupMembers : {} ", list);
assertEquals(list, null, "GROUP MEMBER LIST NOT EMPTY");
@@ -243,22 +250,22 @@ public class GroupHelper {
assertFalse(list.toString().contains("id=" + generatedGroupID.toString()), "GROUP NOT DELETED");
}
//Glim_Gsim_testing
public static List<String> verifyRetrieveGlimAccountsByGroupId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer groupID) {
// Glim_Gsim_testing
public static List<String> verifyRetrieveGlimAccountsByGroupId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer groupID) {
List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/"+groupID+"/glimaccounts?" + Utils.TENANT_IDENTIFIER;
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + groupID + "/glimaccounts?" + Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "glimId");
LOG.debug("GlimId of Retrieved Account : {} ", list);
return list;
}
public static List<String> verifyRetrieveGlimAccountsByGlimId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer glimId) {
public static List<String> verifyRetrieveGlimAccountsByGlimId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer glimId) {
List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/loans/glimAccount/"+glimId+"?"+ Utils.TENANT_IDENTIFIER;
final String GROUP_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" + Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "glimId");
LOG.debug("GlimId of Retrieved Account: {} ", list);
return list;
@@ -268,7 +275,7 @@ public class GroupHelper {
final Integer groupID) {
List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/"+groupID+"/gsimaccounts?" + Utils.TENANT_IDENTIFIER;
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + groupID + "/gsimaccounts?" + Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "gsimId");
LOG.debug("GsimId Retrieved Accounts: {} ", list);
return list;
@@ -312,4 +319,4 @@ public class GroupHelper {
map.put("datatables", datatablesListMap);
return new Gson().toJson(map);
}
}
}
@@ -29,6 +29,7 @@ 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;
@@ -59,14 +60,14 @@ public class HolidayHelper {
map.put("repaymentsRescheduledTo", "08 April 2013");
map.put("reschedulingType", 2);
String HolidayCreateJson = new Gson().toJson(map);
LOG.info("{}",HolidayCreateJson);
LOG.info("{}", HolidayCreateJson);
return HolidayCreateJson;
}
public static String getActivateHolidayDataAsJSON() {
final HashMap<String, String> map = new HashMap<>();
String activateHoliday = new Gson().toJson(map);
LOG.info("{}",activateHoliday);
LOG.info("{}", activateHoliday);
return activateHoliday;
}
@@ -74,7 +75,8 @@ public class HolidayHelper {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOLIDAY_URL, getCreateHolidayDataAsJSON(), "resourceId");
}
public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String holidayID) {
public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String holidayID) {
final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId");
}
@@ -87,4 +89,4 @@ public class HolidayHelper {
return response;
}
}
}
@@ -30,6 +30,7 @@ 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;
@@ -43,8 +44,7 @@ public class HookHelper {
public Integer createHook(final String payloadURL) {
LOG.info("---------------------------------CREATING A HOOK---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL),
"resourceId");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId");
}
public String getTestHookAsJson(final String payloadURL) {
@@ -62,7 +62,7 @@ public class HookHelper {
createOfficeEvent.put("entityName", "OFFICE");
events.add(createOfficeEvent);
map.put("events", events);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -88,8 +88,9 @@ public class HookHelper {
public void verifyUpdateHook(final String updateURL, final Long hookId) {
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 = map.get(1);
ArrayList<HashMap<String, String>> map = Utils.<ArrayList<HashMap<String, String>>> performServerGet(this.requestSpec,
this.responseSpec, GET_URL, "config");
HashMap<String, String> hash = map.get(1);
assertEquals(updateURL, hash.get("fieldValue"));
}
@@ -97,8 +98,9 @@ public class HookHelper {
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");
ArrayList<HashMap<String, String>> array = Utils.<ArrayList<HashMap<String, String>>> performServerGet(this.requestSpec,
responseSpec404, GET_URL, "errors");
HashMap<String, String> map = array.get(0);
assertEquals("error.msg.hook.identifier.not.found",map.get("userMessageGlobalisationCode"));
assertEquals("error.msg.hook.identifier.not.found", map.get("userMessageGlobalisationCode"));
}
}
@@ -25,6 +25,7 @@ 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";
@@ -59,7 +60,8 @@ public class ImageHelper {
return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL);
}
public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) {
public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer staffId) {
LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId");
@@ -24,6 +24,7 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
public class LoanRescheduleRequestHelper {
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
@@ -24,6 +24,7 @@ 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 +37,7 @@ public class NotificationHelper {
}
public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String jsonReturn) {
final String jsonReturn) {
final String GET_NOTIFICATIONS_URL = NOTIFICATION_API_URL;
LOG.info("-----------------------------GET NOTIFICATIONS-----------------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_NOTIFICATIONS_URL, "");
@@ -32,9 +32,8 @@ public class OfficeDomain {
private String[] openingDate;
private String hierarchy;
private Builder(final int id, final String name,
final String nameDecorated, final String externalId,
final String[] openingDate, final String hierarchy) {
private Builder(final int id, final String name, final String nameDecorated, final String externalId, final String[] openingDate,
final String hierarchy) {
this.id = id;
this.name = name;
this.nameDecorated = nameDecorated;
@@ -44,8 +43,7 @@ public class OfficeDomain {
}
public OfficeDomain build() {
return new OfficeDomain(this.id, this.name, this.nameDecorated,
this.externalId, this.openingDate, this.hierarchy);
return new OfficeDomain(this.id, this.name, this.nameDecorated, this.externalId, this.openingDate, this.hierarchy);
}
}
@@ -60,9 +58,8 @@ public class OfficeDomain {
super();
}
private OfficeDomain(final int id, final String name,
final String nameDecorated, final String externalId,
final String[] openingDate, final String hierarchy) {
private OfficeDomain(final int id, final String name, final String nameDecorated, final String externalId, final String[] openingDate,
final String hierarchy) {
super();
this.id = id;
this.name = name;
@@ -80,11 +77,9 @@ public class OfficeDomain {
return new Gson().fromJson(jsonData, OfficeDomain.class);
}
public static Builder create(final int id, final String name,
final String nameDecorated, final String externalId,
public static Builder create(final int id, final String name, final String nameDecorated, final String externalId,
final String[] openingDate, final String hierarchy) {
return new Builder(id, name, nameDecorated, externalId, openingDate,
hierarchy);
return new Builder(id, name, nameDecorated, externalId, openingDate, hierarchy);
}
public int getId() {
@@ -139,20 +134,14 @@ public class OfficeDomain {
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == this) { return true; }
if (!(obj instanceof OfficeDomain)) {
return false;
}
if (!(obj instanceof OfficeDomain)) { return false; }
OfficeDomain od = (OfficeDomain) obj;
if (this.id == od.getId() && this.name.equals(od.getName())
&& this.nameDecorated.equals(od.getName())
&& this.externalId.equals(od.getExternalId())
&& Arrays.equals(this.openingDate, od.getOpeningDate())
if (this.id == od.getId() && this.name.equals(od.getName()) && this.nameDecorated.equals(od.getName())
&& this.externalId.equals(od.getExternalId()) && Arrays.equals(this.openingDate, od.getOpeningDate())
&& this.hierarchy.equals(od.getHierarchy())) {
return true;
}
@@ -35,30 +35,26 @@ 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;
public OfficeHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
public OfficeHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
}
public OfficeDomain retrieveOfficeByID(int id) {
Object get = Utils.performServerGet(
requestSpec, responseSpec, OFFICE_URL + "/" + id + "?"
+ Utils.TENANT_IDENTIFIER, "");
Object get = Utils.performServerGet(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER, "");
final String json = new Gson().toJson(get);
return new Gson().fromJson(json, new TypeToken<OfficeDomain>() {
}.getType());
return new Gson().fromJson(json, new TypeToken<OfficeDomain>() {}.getType());
}
public Integer createOffice(final String openingDate) {
String json = getAsJSON(openingDate);
return Utils.performServerPost(this.requestSpec, this.responseSpec,
OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
return Utils.performServerPost(this.requestSpec, this.responseSpec, OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
CommonConstants.RESPONSE_RESOURCE_ID);
}
@@ -69,10 +65,9 @@ public class OfficeHelper {
map.put("locale", "en");
map.put("openingDate", openingDate);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL
+ "/" + id + "?" + Utils.TENANT_IDENTIFIER,
return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER,
new Gson().toJson(map), "resourceId");
}
@@ -83,30 +78,31 @@ public class OfficeHelper {
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en");
map.put("openingDate", openingDate);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
public String importOfficeTemplate(File file){
String locale="en";
String dateFormat="dd MMMM yyyy";
public String importOfficeTemplate(File file) {
String locale = "en";
String dateFormat = "dd MMMM yyyy";
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec,responseSpec,OFFICE_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER,
null,file,locale,dateFormat);
return Utils.performServerTemplatePost(requestSpec, responseSpec, OFFICE_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
null, 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);
}
public Workbook getOfficeWorkBook(final String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel");
byte[] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,OFFICE_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,
OFFICE_URL + "/downloadtemplate" + "?" + Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook = new HSSFWorkbook(inputStream);
return workbook;
}
}
@@ -27,8 +27,8 @@ 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---------------------------------------------");
@@ -37,12 +37,14 @@ public class PasswordPreferencesHelper {
}
public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,String invalidValidationPolicyId, String jsonAttributeToGetback) {
final ResponseSpecification responseSpec, String invalidValidationPolicyId, String jsonAttributeToGetback) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
//system.out
//.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId),
jsonAttributeToGetback);
// system.out
// .println("---------------------------------UPDATE PASSWORD
// PREFERENCES WITH INVALID
// ID-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL,
updatePreferencesWithInvalidId(invalidValidationPolicyId), jsonAttributeToGetback);
}
public static String updatePreferencesAsJson(String validationPolicyId) {
@@ -57,17 +59,15 @@ 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) {
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,21 +29,20 @@ 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
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) {
@@ -59,14 +58,12 @@ public class PaymentTypeHelper {
return new Gson().toJson(hm);
}
public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer generatedPaymentTypeID) {
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");
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER;
final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id");
assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN CREATING THE PAYMENT TYPE");
}
@@ -77,25 +74,26 @@ public class PaymentTypeHelper {
// 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 " +
// system.out.println("---------------------------------UPDATE PAYMENT
// TYPE " +
// id + "---------------------------------------------");
HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL,
new Gson().toJson(request), "changes");
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) {
final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------DELETING PAYMENT TYPE "
// system.out.println("---------------------------------DELETING PAYMENT
// TYPE "
// + id + "--------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId");
}
@@ -49,6 +49,7 @@ 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;
@@ -59,7 +60,7 @@ public class ProvisioningIntegrationTest {
private LoanTransactionHelper loanTransactionHelper;
@BeforeEach
public void setup() throws ParseException{
public void setup() throws ParseException {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
@@ -94,33 +95,33 @@ public class ProvisioningIntegrationTest {
}
ArrayList categories = transactionHelper.retrieveAllProvisioningCategories();
Assertions.assertTrue(categories.size() > 0) ;
Account liability = accountHelper.createLiabilityAccount() ;
Account expense = accountHelper.createExpenseAccount() ;
Assertions.assertTrue(categories.size() > 0);
Account liability = accountHelper.createLiabilityAccount();
Account expense = accountHelper.createExpenseAccount();
Map requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense);
String provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria);
Integer criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson);
Assertions.assertNotNull(criteriaId);
Map newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId) ;
validateProvisioningCriteria(requestCriteria, newCriteria) ;
Map newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId);
validateProvisioningCriteria(requestCriteria, newCriteria);
ArrayList definitions = (ArrayList)newCriteria.get("definitions") ;
for(int i = 0 ; i < definitions.size(); i++) {
Map criteriadefinition = (Map) definitions.get(i) ;
criteriadefinition.put("provisioningPercentage", Float.valueOf((float)20.0)) ;
ArrayList definitions = (ArrayList) newCriteria.get("definitions");
for (int i = 0; i < definitions.size(); i++) {
Map criteriadefinition = (Map) definitions.get(i);
criteriadefinition.put("provisioningPercentage", Float.valueOf((float) 20.0));
}
newCriteria.put("locale", "en");
String updateCriteriaString = new Gson().toJson(newCriteria) ;
Integer criteriaId1 = transactionHelper.updateProvisioningCriteria(criteriaId, updateCriteriaString) ;
Map updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1) ;
validateProvisioningCriteria(newCriteria, updatedCriteria) ;
String updateCriteriaString = new Gson().toJson(newCriteria);
Integer criteriaId1 = transactionHelper.updateProvisioningCriteria(criteriaId, updateCriteriaString);
Map updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1);
validateProvisioningCriteria(newCriteria, updatedCriteria);
transactionHelper.deleteProvisioningCriteria(criteriaId1) ;
transactionHelper.deleteProvisioningCriteria(criteriaId1);
categories = transactionHelper.retrieveAllProvisioningCategories();
liability = accountHelper.createLiabilityAccount() ;
expense = accountHelper.createExpenseAccount() ;
liability = accountHelper.createLiabilityAccount();
expense = accountHelper.createExpenseAccount();
requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense);
provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria);
criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson);
@@ -130,58 +131,58 @@ public class ProvisioningIntegrationTest {
Integer provisioningEntryId = transactionHelper.createProvisioningEntries(provisioningEntryJson);
Assertions.assertNotNull(provisioningEntryId);
transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, "") ;
transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, "") ;
Map entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId) ;
Assertions.assertTrue((Boolean)entry.get("journalEntry")) ;
Map provisioningEntry = transactionHelper.retrieveProvisioningEntries(provisioningEntryId) ;
Assertions.assertTrue(((ArrayList)provisioningEntry.get("pageItems")).size() > 0) ;
transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, "");
transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, "");
Map entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId);
Assertions.assertTrue((Boolean) entry.get("journalEntry"));
Map provisioningEntry = transactionHelper.retrieveProvisioningEntries(provisioningEntryId);
Assertions.assertTrue(((ArrayList) provisioningEntry.get("pageItems")).size() > 0);
}
private void validateProvisioningCriteria(Map requestCriteria, Map newCriteria) {
//criteria name validation
String requestCriteriaName = (String)requestCriteria.get("criteriaName") ;
String criteriaName = (String)newCriteria.get("criteriaName") ;
Assertions.assertEquals(criteriaName, requestCriteriaName) ;
// criteria name validation
String requestCriteriaName = (String) requestCriteria.get("criteriaName");
String criteriaName = (String) newCriteria.get("criteriaName");
Assertions.assertEquals(criteriaName, requestCriteriaName);
//loan products validation
ArrayList requestProducts = (ArrayList)requestCriteria.get("loanProducts") ;
ArrayList products = (ArrayList)newCriteria.get("loanProducts") ;
Assertions.assertEquals(products.size(), requestProducts.size()) ;
// loan products validation
ArrayList requestProducts = (ArrayList) requestCriteria.get("loanProducts");
ArrayList products = (ArrayList) newCriteria.get("loanProducts");
Assertions.assertEquals(products.size(), requestProducts.size());
ArrayList requestedDefinitions = (ArrayList)requestCriteria.get("definitions") ;
ArrayList newdefintions = (ArrayList) newCriteria.get("definitions") ;
Assertions.assertEquals(newdefintions.size(), requestedDefinitions.size()) ;
for(int i = 0 ; i < newdefintions.size() ; i++) {
Map requestedMap = (Map)requestedDefinitions.get(i) ;
Object requestedCategoryId = requestedMap.get("categoryId") ;
boolean found = false ;
for(int j = 0 ; j < newdefintions.size(); j++) {
Map newMap = (Map)newdefintions.get(j) ;
Object newCategoryId = newMap.get("categoryId") ;
if(requestedCategoryId.equals(newCategoryId)) {
found = true ;
checkProperty("categoryId", requestedMap, newMap) ;
checkProperty("categoryName", requestedMap, newMap) ;
checkProperty("minAge", requestedMap, newMap) ;
checkProperty("maxAge", requestedMap, newMap) ;
checkProperty("provisioningPercentage", requestedMap, newMap) ;
checkProperty("liabilityAccount", requestedMap, newMap) ;
checkProperty("expenseAccount", requestedMap, newMap) ;
break ; //internal loop
ArrayList requestedDefinitions = (ArrayList) requestCriteria.get("definitions");
ArrayList newdefintions = (ArrayList) newCriteria.get("definitions");
Assertions.assertEquals(newdefintions.size(), requestedDefinitions.size());
for (int i = 0; i < newdefintions.size(); i++) {
Map requestedMap = (Map) requestedDefinitions.get(i);
Object requestedCategoryId = requestedMap.get("categoryId");
boolean found = false;
for (int j = 0; j < newdefintions.size(); j++) {
Map newMap = (Map) newdefintions.get(j);
Object newCategoryId = newMap.get("categoryId");
if (requestedCategoryId.equals(newCategoryId)) {
found = true;
checkProperty("categoryId", requestedMap, newMap);
checkProperty("categoryName", requestedMap, newMap);
checkProperty("minAge", requestedMap, newMap);
checkProperty("maxAge", requestedMap, newMap);
checkProperty("provisioningPercentage", requestedMap, newMap);
checkProperty("liabilityAccount", requestedMap, newMap);
checkProperty("expenseAccount", requestedMap, newMap);
break; // internal loop
}
}
if(!found) {
if (!found) {
Assertions.fail("No Category found with Id:" + requestedCategoryId);
}
}
}
private void checkProperty(String propertyName, Map requestMap, Map newMap) {
Object requested = requestMap.get(propertyName) ;
Object modified = newMap.get(propertyName) ;
Assertions.assertEquals(requested, modified) ;
Object requested = requestMap.get(propertyName);
Object modified = newMap.get(propertyName);
Assertions.assertEquals(requested, modified);
}
private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
@@ -227,19 +228,19 @@ public class ProvisioningIntegrationTest {
private boolean isAlreadyProvisioningEntriesCreated() throws ParseException {
ProvisioningTransactionHelper transactionHelper = new ProvisioningTransactionHelper(requestSpec, responseSpec);
Map entries = transactionHelper.retrieveAllProvisioningEntries() ;
ArrayList<Map> pageItems = (ArrayList)entries.get("pageItems") ;
boolean provisioningetryAlreadyCreated = false ;
if(pageItems != null) {
for(Map item: pageItems) {
String date = (String)item.get("createdDate") ;
Map entries = transactionHelper.retrieveAllProvisioningEntries();
ArrayList<Map> pageItems = (ArrayList) entries.get("pageItems");
boolean provisioningetryAlreadyCreated = false;
if (pageItems != null) {
for (Map item : pageItems) {
String date = (String) item.get("createdDate");
DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy");
Date date1 = formatter.parse(date) ;
Date date1 = formatter.parse(date);
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy");
String formattedString = simple.format(Utils.getLocalDateOfTenant().toDate());
Date currentDate = simple.parse(formattedString) ;
if(date1.getTime() == currentDate.getTime()) {
provisioningetryAlreadyCreated = true ;
Date currentDate = simple.parse(formattedString);
if (date1.getTime() == currentDate.getTime()) {
provisioningetryAlreadyCreated = true;
break;
}
}
@@ -43,6 +43,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SchedulerJobHelper {
private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class);
private final RequestSpecification requestSpec;
private final ResponseSpecification response200Spec;
@@ -78,7 +79,7 @@ public class SchedulerJobHelper {
final String GET_SCHEDULER_JOB_BY_ID_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------");
final Map<String, Object> response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_JOB_BY_ID_URL, "");
LOG.info("{}",response.toString());
LOG.info("{}", response.toString());
assertNotNull(response);
return response;
}
@@ -108,7 +109,7 @@ public class SchedulerJobHelper {
private static String updateSchedulerJobAsJSON(final boolean active) {
final Map<String, String> map = new HashMap<>();
map.put("active", Boolean.toString(active));
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -133,12 +134,17 @@ public class SchedulerJobHelper {
return (Integer) allSchedulerJobsData.get(jobIndex).get("jobId");
}
}
throw new IllegalArgumentException("No such named Job (see org.apache.fineract.infrastructure.jobs.service.JobName enum):" + jobName);
throw new IllegalArgumentException(
"No such named Job (see org.apache.fineract.infrastructure.jobs.service.JobName enum):" + jobName);
}
/**
* Launches a Job and awaits its completion.
* @param jobName displayName (see {@link org.apache.fineract.infrastructure.jobs.service.JobName}) of Scheduler Job
*
* @param jobName
* displayName (see
* {@link org.apache.fineract.infrastructure.jobs.service.JobName})
* of Scheduler Job
*
* @author Michael Vorburger.ch
*/
@@ -148,53 +154,54 @@ public class SchedulerJobHelper {
DateTimeFormatter df = DateTimeFormatter.ISO_INSTANT; // FINERACT-926
Instant beforeExecuteTime = now().truncatedTo(ChronoUnit.SECONDS);
// Stop the Scheduler while we manually trigger execution of job, to avoid side effects and simplify debugging when readings logs
// Stop the Scheduler while we manually trigger execution of job, to
// avoid side effects and simplify debugging when readings logs
updateSchedulerStatus(false);
// Executing Scheduler Job
int jobId = getSchedulerJobIdByName(jobName);
runSchedulerJob(jobId);
// Await JobDetailData.lastRunHistory [JobDetailHistoryData] jobRunStartTime >= beforeExecuteTime (or timeout)
// Await JobDetailData.lastRunHistory [JobDetailHistoryData]
// jobRunStartTime >= beforeExecuteTime (or timeout)
await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> {
String jobRunStartText = lastRunHistory.get("jobRunStartTime");
if (jobRunStartText == null) {
return false;
}
if (jobRunStartText == null) { return false; }
Instant jobRunStartTime = df.parse(jobRunStartText, Instant::from);
return jobRunStartTime.equals(beforeExecuteTime) || jobRunStartTime.isAfter(beforeExecuteTime);
});
// Await JobDetailData.lastRunHistory [JobDetailHistoryData] jobRunEndTime to be both set and >= jobRunStartTime (or timeout)
Map<String, String> finalLastRunHistory = await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> {
String jobRunEndText = lastRunHistory.get("jobRunEndTime");
if (jobRunEndText == null) {
return false;
}
Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from);
Instant jobRunStartTime = df.parse(lastRunHistory.get("jobRunStartTime"), Instant::from);
return jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime);
});
// Await JobDetailData.lastRunHistory [JobDetailHistoryData]
// jobRunEndTime to be both set and >= jobRunStartTime (or timeout)
Map<String, String> finalLastRunHistory = await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId),
lastRunHistory -> {
String jobRunEndText = lastRunHistory.get("jobRunEndTime");
if (jobRunEndText == null) { return false; }
Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from);
Instant jobRunStartTime = df.parse(lastRunHistory.get("jobRunStartTime"), Instant::from);
return jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime);
});
// Verify triggerType
assertThat(finalLastRunHistory.get("triggerType"), is("application"));
// Verify status & propagate jobRunErrorMessage and/or jobRunErrorLog (if any)
// Verify status & propagate jobRunErrorMessage and/or jobRunErrorLog
// (if any)
String status = finalLastRunHistory.get("status");
if (!status.equals("success")) {
fail("Job status is not success: " + finalLastRunHistory.toString());
}
// PS: Checking getSchedulerJobHistory() [/runhistory] is pointless, because the lastRunHistory JobDetailHistoryData is already part of JobDetailData anyway.
// PS: Checking getSchedulerJobHistory() [/runhistory] is pointless,
// because the lastRunHistory JobDetailHistoryData is already part of
// JobDetailData anyway.
}
@SuppressWarnings("unchecked")
private Callable<Map<String, String>> jobLastRunHistorySupplier(int jobId) {
return () -> {
Map<String, Object> job = getSchedulerJobById(jobId);
if (job == null) {
return null;
}
if (job == null) { return null; }
return (Map<String, String>) job.get("lastRunHistory");
};
}
@@ -26,8 +26,9 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"unused", "rawtypes", "unchecked" })
@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";
@@ -90,7 +91,7 @@ public class StandingInstructionsHelper {
map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS);
map.put("recurrenceOnMonthDay", monthDay);
String savingsApplicationJSON = new Gson().toJson(map);
LOG.info("{}",savingsApplicationJSON);
LOG.info("{}", savingsApplicationJSON);
return savingsApplicationJSON;
}
@@ -113,13 +114,14 @@ public class StandingInstructionsHelper {
return response;
}
public List<HashMap> getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, Integer fromClientId, Integer transferType) {
public List<HashMap> getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, Integer fromClientId,
Integer transferType) {
final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId
+ "&transferType=" + transferType;
LOG.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}",STANDING_INSTRUCTIONS_HISTORY_URL);
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&transferType="
+ transferType;
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;
}
}
}
@@ -28,6 +28,7 @@ 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;
@@ -38,16 +39,16 @@ public class SurveyHelper {
public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate) {
LOG.info("---------------------------------FULFIL PPI ---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec,FULFIL_SURVEY_URL, getTestPPIAsJSON(), "clientId");
return Utils.performServerPost(requestSpec, responseSpec, FULFIL_SURVEY_URL, getTestPPIAsJSON(), "clientId");
}
public static String getTestPPIAsJSON() {
final HashMap<String, String> map = new HashMap<>();
map.put("date", "2014-05-19 00:00:00");
map.put("ppi_household_members_cd_q1_householdmembers","107");
map.put("ppi_highestschool_cd_q2_highestschool","112");
map.put("ppi_businessoccupation_cd_q3_businessoccupation","116");
map.put("ppi_household_members_cd_q1_householdmembers", "107");
map.put("ppi_highestschool_cd_q2_highestschool", "112");
map.put("ppi_businessoccupation_cd_q3_businessoccupation", "116");
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en");
map.put("ppi_habitablerooms_cd_q4_habitablerooms", "120");
@@ -59,17 +60,17 @@ public class SurveyHelper {
map.put("ppi_towels_cd_q9_towels", "134");
map.put("ppi_fryingpans_cd_q10_fryingpans", "138");
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedClientID) {
LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?"
+ Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id");
assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT");
}
}
}
@@ -27,6 +27,7 @@ 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;
@@ -43,7 +44,7 @@ public class TaxComponentHelper {
map.put("creditAccountType", Account.AccountType.LIABILITY.toString());
map.put("creditAcountId", String.valueOf(creditAccountId));
}
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -61,4 +62,4 @@ public class TaxComponentHelper {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
}
}
}
@@ -29,13 +29,15 @@ 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) {
LOG.info("---------------------------------CREATING A TAX GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds), "resourceId");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds),
"resourceId");
}
public static String getTaxGroupAsJSON(final Collection<Integer> taxComponentIds) {
@@ -66,4 +68,4 @@ public class TaxGroupHelper {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
}
}
}
@@ -83,13 +83,11 @@ public class Utils {
LOG.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL);
return;
} else {
LOG.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL,
healthHttpStatus, attempt++);
LOG.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, healthHttpStatus, attempt++);
sleep(3);
}
} catch (Exception e) {
LOG.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(),
attempt++);
LOG.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), attempt++);
lastException = e;
sleep(3);
}
@@ -99,8 +97,7 @@ public class Utils {
LOG.error("{} still not reachable, giving up", HEALTH_URL, lastException);
throw new AssertionError(HEALTH_URL + " not reachable", lastException);
} else {
LOG.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL,
response.prettyPrint());
LOG.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, response.prettyPrint());
fail(HEALTH_URL + " returned " + response.prettyPrint());
}
}
@@ -119,9 +116,8 @@ public class Utils {
try {
LOG.info("Logging in, for integration test...");
// system.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.given().contentType(ContentType.JSON)
.body("{\"username\":\"mifos\", \"password\":\"password\"}").expect().log().ifError().when()
.post(LOGIN_URL).asString();
String json = RestAssured.given().contentType(ContentType.JSON).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));
@@ -136,63 +132,53 @@ 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)
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)
.andReturn().asString();
if (jsonAttributeToGetBack == null) {
return (T) json;
}
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()
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();
}
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 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()
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) 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));
}
public static String convertDateToURLFormat(final String dateToBeConvert) throws ParseException{
public static String convertDateToURLFormat(final String dateToBeConvert) throws ParseException {
final SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy", Locale.US);
final SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
String reformattedStr = "";
@@ -250,20 +236,19 @@ 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();
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);
}
}
@@ -27,6 +27,7 @@ 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";
@@ -50,7 +51,7 @@ public class WorkingDaysHelper {
map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -60,7 +61,7 @@ public class WorkingDaysHelper {
map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false);
LOG.info("map : {}" , map);
LOG.info("map : {}", map);
return new Gson().toJson(map);
}
@@ -69,7 +70,8 @@ public class WorkingDaysHelper {
return (int) workingDays.get("id");
}
public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER, "");
@@ -21,6 +21,7 @@ package org.apache.fineract.integrationtests.common.accounting;
public class Account {
public enum AccountType {
ASSET("1"), INCOME("4"), EXPENSE("5"), LIABILITY("2"), EQUITY("3");
private final String accountValue;
@@ -40,22 +40,22 @@ public class AccountHelper {
public Account createAssetAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsAsset().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.ASSET);
}
public Account createIncomeAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsIncome().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.INCOME);
}
public Account createExpenseAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsExpense().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.EXPENSE);
}
@@ -68,7 +68,8 @@ public class AccountHelper {
public ArrayList getAccountingWithRunningBalances() {
final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts?fetchRunningBalance=true";
final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_RUNNING_BALANCE_URL, "");
final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec,
GET_RUNNING_BALANCE_URL, "");
return accountRunningBalance;
}
@@ -37,18 +37,19 @@ public class FinancialActivityAccountHelper {
public Object createFinancialActivityAccount(Integer financialActivityId, Integer glAccountId,
final ResponseSpecification responseSpecification, String jsonBack) {
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
return Utils.performServerPost(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?"
+ Utils.TENANT_IDENTIFIER, json, jsonBack);
return Utils.performServerPost(this.requestSpec, responseSpecification,
FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack);
}
public Object updateFinancialActivityAccount(Integer financialActivityAccountId, Integer financialActivityId, Integer glAccountId,
final ResponseSpecification responseSpecification, String jsonBack) {
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
return Utils.performServerPut(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/"
+ financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack);
return Utils.performServerPut(this.requestSpec, responseSpecification,
FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack);
}
public HashMap getFinancialActivityAccount(final Integer financialActivityAccountId, final ResponseSpecification responseSpecification) {
public HashMap getFinancialActivityAccount(final Integer financialActivityAccountId,
final ResponseSpecification responseSpecification) {
final String url = FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpecification, url, "");
}
@@ -21,6 +21,7 @@ package org.apache.fineract.integrationtests.common.accounting;
public class JournalEntry {
public enum TransactionType {
CREDIT("CREDIT"), DEBIT("DEBIT");
private TransactionType(final String type) {
@@ -31,6 +31,7 @@ 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;
@@ -168,14 +169,11 @@ 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);
@@ -187,18 +185,15 @@ public class ChargesHelper {
}
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);
@@ -211,25 +206,22 @@ public class ChargesHelper {
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(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, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
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,
boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
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) {
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);
@@ -242,15 +234,13 @@ public class ChargesHelper {
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() {
@@ -365,40 +355,36 @@ public class ChargesHelper {
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() {
@@ -496,10 +482,9 @@ public class ChargesHelper {
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");
}
}
}
@@ -31,6 +31,7 @@ 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;
@@ -41,8 +42,7 @@ 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";
@@ -135,17 +135,16 @@ public class FixedDepositAccountHelper {
return fixedDepositAccountJson;
}
public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
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);
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;
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, "");
}
@@ -179,8 +178,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;
@@ -209,23 +208,22 @@ 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);
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) //
@@ -236,63 +234,51 @@ public class FixedDepositAccountHelper {
.build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON,
CommonConstants.RESPONSE_CHANGES);
}
public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) {
LOG.info(
"--------------------------------- 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) {
LOG.info(
"--------------------------------- 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) {
LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
return performFixedDepositApplicationActions(createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getRejectedFixedDepositAsJSON(rejectedOnDate));
}
public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) {
LOG.info(
"--------------------------------- 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) {
LOG.info(
"---------------------------------- 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) {
LOG.info(
"---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
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);
FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
}
public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) {
LOG.info(
"--------------------------------- 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);
@@ -305,21 +291,18 @@ public class FixedDepositAccountHelper {
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
}
public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId,
final String closedOnDate) {
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) {
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);
return performFixedDepositActions(createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId),
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack);
}
private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) {
@@ -399,21 +382,18 @@ public class FixedDepositAccountHelper {
}
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");
}
@@ -421,8 +401,7 @@ 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,
@@ -486,14 +465,12 @@ public class FixedDepositAccountHelper {
}
private String getDepositAmount() {
if (this.newDepositAmount == null) {
return DEPOSIT_AMOUNT;
}
if (this.newDepositAmount == null) { return DEPOSIT_AMOUNT; }
return this.newDepositAmount;
}
public FixedDepositAccountHelper withMaturityInstructionId(Integer maturityInstructionId){
public FixedDepositAccountHelper withMaturityInstructionId(Integer maturityInstructionId) {
this.maturityInstructionId = maturityInstructionId;
return this;
}
}
}
@@ -30,6 +30,7 @@ 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";
@@ -41,8 +42,7 @@ public class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"),
"FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE");
assertTrue(getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"), "FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE");
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
@@ -54,15 +54,13 @@ public class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "rejected"),
"ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION");
assertTrue(getStatus(fixedDepositStatusHashMap, "rejected"), "ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) {
LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"),
"ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION");
assertTrue(getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"), "ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
@@ -78,28 +76,26 @@ public class FixedDepositAccountStatusChecker {
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) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "prematureClosed"),
"ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT");
assertTrue(getStatus(fixedDepositStatusHashMap, "prematureClosed"), "ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "matured"),
"ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT");
assertTrue(getStatus(fixedDepositStatusHashMap, "matured"), "ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString());
}
private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) {
return (Boolean) fixedDepositStatusMap.get(fixedDepositStatusString);
}
}
}
@@ -33,6 +33,7 @@ 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;
@@ -70,7 +71,6 @@ public class FixedDepositProductHelper {
private static final String WHOLE_TERM = "1";
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6);
private String shortName = Utils.randomNameGenerator("", 4);
private String description = Utils.randomNameGenerator("", 20);
@@ -142,14 +142,12 @@ public class FixedDepositProductHelper {
map.put("taxGroupId", taxGroupId);
}
if (this.accountingRule.equals(CASH_BASED)) {
map.putAll(getAccountMappingForCashBased());
}
String FixedDepositProductCreateJson = new Gson().toJson(map);
LOG.info("{}",FixedDepositProductCreateJson);
LOG.info("{}", FixedDepositProductCreateJson);
return FixedDepositProductCreateJson;
}
@@ -393,7 +391,6 @@ public class FixedDepositProductHelper {
return this;
}
private Map<String, String> getAccountMappingForCashBased() {
final Map<String, String> map = new HashMap<>();
if (accountList != null) {
@@ -428,10 +425,11 @@ public class FixedDepositProductHelper {
CommonConstants.RESPONSE_RESOURCE_ID);
}
public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_PRODUCT_URL + "?"
+ Utils.TENANT_IDENTIFIER, "");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec,
FIXED_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER, "");
return response;
}
@@ -451,4 +449,4 @@ public class FixedDepositProductHelper {
return response;
}
}
}

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