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 // FINERACT-940 && FINERACT-966 https://github.com/spotbugs/spotbugs/issues/1128
exclude 'xpp3:xpp3' exclude 'xpp3:xpp3'
exclude 'pull-parser:pull-parser' exclude 'pull-parser:pull-parser'
} }
dependencySet(group: 'com.sun.jersey', version: jerseyVersion) { dependencySet(group: 'com.sun.jersey', version: jerseyVersion) {
entry 'jersey-core' entry 'jersey-core'
@@ -156,8 +156,8 @@ project.ext.mysqlPassword='mysql'
group = 'org.apache.fineract' group = 'org.apache.fineract'
buildDir = new File(rootProject.projectDir, "../build") buildDir = new File(rootProject.projectDir, "../build")
repositories { repositories {
jcenter() jcenter()
// mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds) // 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, // 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") sourceSets.main.java.outputDir = new File(rootProject.projectDir, "bin/main")
} }
eclipse eclipse
{ {
project { project {
buildCommand([ LaunchConfigHandle: "<project>/.externalToolBuilders/OpenJPA Enhance Builder.launch" ], 'org.eclipse.ui.externaltools.ExternalToolBuilder') buildCommand([ LaunchConfigHandle: "<project>/.externalToolBuilders/OpenJPA Enhance Builder.launch" ], 'org.eclipse.ui.externaltools.ExternalToolBuilder')
@@ -206,12 +206,12 @@ spotless {
java { java {
importOrder() //sort imports alphabetically importOrder() //sort imports alphabetically
removeUnusedImports() removeUnusedImports()
eclipse().configFile '../config/fineractdev-formatter.xml' eclipse().configFile '../config/fineractdev-formatter.xml'
endWithNewline() endWithNewline()
trimTrailingWhitespace() trimTrailingWhitespace()
} }
lineEndings 'UNIX' lineEndings 'UNIX'
} }
@@ -299,25 +299,25 @@ rat {
} }
configurations { configurations {
providedRuntime // needed for Spring Boot executable WAR providedRuntime // needed for Spring Boot executable WAR
providedCompile providedCompile
compile() { compile() {
exclude module: 'hibernate-entitymanager' exclude module: 'hibernate-entitymanager'
exclude module: 'hibernate-validator' exclude module: 'hibernate-validator'
exclude module: 'activation' exclude module: 'activation'
exclude module: 'bcmail-jdk14' exclude module: 'bcmail-jdk14'
exclude module: 'bcprov-jdk14' exclude module: 'bcprov-jdk14'
exclude module: 'bctsp-jdk14' exclude module: 'bctsp-jdk14'
exclude module: 'c3p0' exclude module: 'c3p0'
exclude module: 'stax-api' exclude module: 'stax-api'
exclude module: 'jaxb-api' exclude module: 'jaxb-api'
exclude module: 'jaxb-impl' exclude module: 'jaxb-impl'
exclude module: 'jboss-logging' exclude module: 'jboss-logging'
exclude module: 'itext-rtf' exclude module: 'itext-rtf'
exclude module: 'classworlds' exclude module: 'classworlds'
} }
runtime runtime
all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
@@ -489,21 +489,21 @@ pmd {
*/ */
war { war {
from('../licenses/binary/') { // notice the parens from('../licenses/binary/') { // notice the parens
into "WEB-INF/licenses/binary/" // no leading slash into "WEB-INF/licenses/binary/" // no leading slash
} }
from('../LICENSE_RELEASE') { // notice the parens from('../LICENSE_RELEASE') { // notice the parens
into "WEB-INF/" // no leading slash into "WEB-INF/" // no leading slash
} }
from('../NOTICE_RELEASE') { // notice the parens from('../NOTICE_RELEASE') { // notice the parens
into "WEB-INF/" // no leading slash into "WEB-INF/" // no leading slash
} }
rename ('LICENSE_RELEASE', 'LICENSE') rename ('LICENSE_RELEASE', 'LICENSE')
rename ('NOTICE_RELEASE', 'NOTICE') rename ('NOTICE_RELEASE', 'NOTICE')
from('../DISCLAIMER') { // notice the parens from('../DISCLAIMER') { // notice the parens
into "WEB-INF/" // no leading slash into "WEB-INF/" // no leading slash
} }
war.finalizedBy(bootWar) war.finalizedBy(bootWar)
} }
@@ -588,7 +588,7 @@ if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
sourceSets { sourceSets {
integrationTest { integrationTest {
compileClasspath += main.output + test.output compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output runtimeClasspath += main.output + test.output
} }
} }
@@ -608,20 +608,20 @@ task integrationTest(type:Test) {
} }
integrationTest { integrationTest {
useJUnitPlatform() useJUnitPlatform()
testLogging { // FINERACT-927 testLogging { // FINERACT-927
events "skipped", "failed" events "skipped", "failed"
showStandardStreams = false showStandardStreams = false
exceptionFormat "full" exceptionFormat "full"
} }
} }
test { test {
useJUnitPlatform() useJUnitPlatform()
testLogging { // FINERACT-927 testLogging { // FINERACT-927
events "skipped", "failed" events "skipped", "failed"
showStandardStreams = false showStandardStreams = false
exceptionFormat "full" exceptionFormat "full"
} }
} }
@@ -47,7 +47,7 @@
<property name="fileExtensions" value="java"/> <property name="fileExtensions" value="java"/>
</module> </module>
--> -->
<module name="TreeWalker"> <module name="TreeWalker">
<module name="SuppressWarningsHolder" /> <module name="SuppressWarningsHolder" />
<module name="RegexpSinglelineJava"> <module name="RegexpSinglelineJava">
@@ -114,7 +114,7 @@
</module> </module>
<module name="UpperEll"/> <module name="UpperEll"/>
<module name="NeedBraces"/> <module name="NeedBraces"/>
<module name="ArrayTypeStyle"/> <module name="ArrayTypeStyle"/>
<module name="NoLineWrap"/> <module name="NoLineWrap"/>
<module name="IllegalTokenText"> <module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/> <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
@@ -144,14 +144,14 @@
<module name="MutableException"/> <module name="MutableException"/>
<module name="com.github.sevntu.checkstyle.checks.coding.AvoidHidingCauseExceptionCheck" /> <module name="com.github.sevntu.checkstyle.checks.coding.AvoidHidingCauseExceptionCheck" />
<module name="OuterTypeFilename"/> <module name="OuterTypeFilename"/>
<module name="LeftCurly" /> <module name="LeftCurly" />
<module name="RightCurly"> <module name="RightCurly">
<property name="option" value="alone"/> <property name="option" value="alone"/>
@@ -168,12 +168,12 @@
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/> value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module> </module>
<module name="ParenPad" /> <module name="ParenPad" />
<module name="MultipleVariableDeclarations"/> <module name="MultipleVariableDeclarations"/>
<module name="MissingSwitchDefault"/> <module name="MissingSwitchDefault"/>
<module name="ModifierOrder"/> <module name="ModifierOrder"/>
<module name="RedundantModifier"/> <module name="RedundantModifier"/>
<module name="EmptyLineSeparator"> <module name="EmptyLineSeparator">
@@ -211,7 +211,7 @@
<message key="name.invalidPattern" <message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/> value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module> </module>
<module name="ConstantName" /> <module name="ConstantName" />
<module name="NoFinalizer"/> <module name="NoFinalizer"/>
<module name="GenericWhitespace"> <module name="GenericWhitespace">
+20 -20
View File
@@ -22,12 +22,12 @@ dependencies {
spotbugsPlugins "jp.skypencil.findbugs.slf4j:bug-pattern:1.5.0@jar" spotbugsPlugins "jp.skypencil.findbugs.slf4j:bug-pattern:1.5.0@jar"
spotbugs 'com.github.spotbugs:spotbugs:4.0.4' spotbugs 'com.github.spotbugs:spotbugs:4.0.4'
// Never use "compile" scope, but make all dependencies either 'implementation', 'runtimeOnly' or 'testCompile'. // 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. // 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'. // 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( implementation(
//'ch.vorburger.mariaDB4j:mariaDB4j:2.4.0', //'ch.vorburger.mariaDB4j:mariaDB4j:2.4.0',
@@ -79,50 +79,50 @@ dependencies {
'com.github.spotbugs:spotbugs-annotations', 'com.github.spotbugs:spotbugs-annotations',
) )
implementation ('io.swagger:swagger-jersey-jaxrs') { implementation ('io.swagger:swagger-jersey-jaxrs') {
exclude group: 'javax.validation' exclude group: 'javax.validation'
} }
implementation ('org.apache.activemq:activemq-broker') { implementation ('org.apache.activemq:activemq-broker') {
exclude group: 'org.apache.geronimo.specs' exclude group: 'org.apache.geronimo.specs'
} }
implementation ('org.springframework.boot:spring-boot-starter-data-jpa') { 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') { implementation ('org.quartz-scheduler:quartz') {
exclude group: 'com.zaxxer', module: 'HikariCP-java7' exclude group: 'com.zaxxer', module: 'HikariCP-java7'
} }
implementation ('com.amazonaws:aws-java-sdk-s3') { implementation ('com.amazonaws:aws-java-sdk-s3') {
exclude group: 'commons-logging' exclude group: 'commons-logging'
} }
implementation ('org.mnode.ical4j:ical4j') { implementation ('org.mnode.ical4j:ical4j') {
exclude group: 'commons-logging' exclude group: 'commons-logging'
} }
implementation ('org.ehcache:ehcache') { implementation ('org.ehcache:ehcache') {
exclude group: 'org.glassfish.jaxb', module: 'jaxb-runtime' 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 dependencies are things that Fineract code has no direct compile time dependency on, but which must be present at run-time
runtimeOnly( runtimeOnly(
'org.apache.bval:org.apache.bval.bundle', 'org.apache.bval:org.apache.bval.bundle',
'org.springframework.boot:spring-boot-starter-actuator', 'org.springframework.boot:spring-boot-starter-actuator',
// Although fineract (at the time of writing) doesn't have any compile time dep. on httpclient, // 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 // 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', 'org.apache.httpcomponents:httpclient',
) )
// testCompile dependencies are ONLY used in src/test and/or src/integrationTest, not src/main. // 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! // Do NOT repeat dependencies which are ALREADY in implementation or runtimeOnly!
// //
testImplementation( 'org.mockito:mockito-core', testImplementation( 'org.mockito:mockito-core',
'org.mockito:mockito-junit-jupiter', '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 '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', 'io.github.classgraph:classgraph',
'org.awaitility:awaitility' 'org.awaitility:awaitility'
) )
testImplementation ('io.rest-assured:rest-assured') { testImplementation ('io.rest-assured:rest-assured') {
exclude group: 'commons-logging' exclude group: 'commons-logging'
exclude group: 'org.apache.sling' exclude group: 'org.apache.sling'
@@ -26,4 +26,4 @@ management.info.git.mode=FULL
# FINERACT-914 # FINERACT-914
server.forward-headers-strategy=framework 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"); Integer id = (Integer) preferenceId.get("id");
HashMap<String, Object> delResponse = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(id, this.responseSpec, HashMap<String, Object> delResponse = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(id, this.responseSpec,
""); "");
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 */ /* 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, HashMap<String, Object> deletionError = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(10,
this.responseNotFoundError, ""); this.responseNotFoundError, "");
@@ -180,25 +181,25 @@ public class AccountNumberPreferencesTest {
} }
private void createAccountNumberPreference() { private void createAccountNumberPreference() {
this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference( this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createClientAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Client (ID: {})",this.clientAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Client (ID: {})", this.clientAccountNumberPreferenceId);
this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createLoanAccountNumberPreference( this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createLoanAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Loan (ID: {} )", this.loanAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Loan (ID: {} )", this.loanAccountNumberPreferenceId);
this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference( this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createSavingsAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Savings (ID: {})" , this.savingsAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Savings (ID: {})", this.savingsAccountNumberPreferenceId);
this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference( this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createGroupsAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Groups (ID: {})" , this.groupsAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Groups (ID: {})", this.groupsAccountNumberPreferenceId);
this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference( this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper
this.responseSpec, "resourceId"); .createCenterAccountNumberPreference(this.responseSpec, "resourceId");
LOG.info("Successfully created account number preferences for Center (ID: {})" ,this.centerAccountNumberPreferenceId); LOG.info("Successfully created account number preferences for Center (ID: {})", this.centerAccountNumberPreferenceId);
this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId, this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId,
this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId, this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId,
@@ -211,10 +212,11 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) { private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) {
/* Creating account Preference with duplicate data should fail */ /* Creating account Preference with duplicate data should fail */
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( HashMap<String, Object> creationError = this.accountNumberPreferencesHelper
this.responseForbiddenError, accountType, prefixType, ""); .createAccountNumberPreferenceWithInvalidData(this.responseForbiddenError, accountType, prefixType, "");
Assertions.assertEquals("error.msg.account.number.format.duplicate.account.type", Assertions.assertEquals("error.msg.account.number.format.duplicate.account.type",
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -224,34 +226,36 @@ public class AccountNumberPreferencesTest {
private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) { private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) {
/* Creating account Preference with invalid data should fail */ /* Creating account Preference with invalid data should fail */
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( HashMap<String, Object> creationError = this.accountNumberPreferencesHelper
this.responseValidationError, accountType, prefixType, ""); .createAccountNumberPreferenceWithInvalidData(this.responseValidationError, accountType, prefixType, "");
if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals( if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)
"validation.msg.accountNumberFormat.accountType.is.not.within.expected.range")) { .equals("validation.msg.accountNumberFormat.accountType.is.not.within.expected.range")) {
Assertions.assertEquals("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)); creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} else if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals( } else if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)
"validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations")) { .equals("validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations")) {
Assertions.assertEquals("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)); creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
} }
private void updateAccountNumberPreference() { private void updateAccountNumberPreference() {
HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference( HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper
this.clientAccountNumberPreferenceId, "101", this.responseSpec, ""); .updateAccountNumberPreference(this.clientAccountNumberPreferenceId, "101", this.responseSpec, "");
LOG.info("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID {}" LOG.info("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID {}",
, accountNumberPreferences.get("resourceId")); accountNumberPreferences.get("resourceId"));
this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"), this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"),
this.responseSpec, this.requestSpec); this.responseSpec, this.requestSpec);
/* Update invalid account preference id should fail */ /* Update invalid account preference id should fail */
LOG.info("---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); LOG.info(
"---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------");
/* Invalid Account Type */ /* Invalid Account Type */
HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101", HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101",
@@ -260,8 +264,8 @@ public class AccountNumberPreferencesTest {
Assertions.assertEquals("error.msg.resource.not.found", updationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); Assertions.assertEquals("error.msg.resource.not.found", updationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
/* Invalid Prefix Type */ /* Invalid Prefix Type */
HashMap<String, Object> updationError1 = this.accountNumberPreferencesHelper.updateAccountNumberPreference( HashMap<String, Object> updationError1 = this.accountNumberPreferencesHelper
this.clientAccountNumberPreferenceId, "103", this.responseValidationError, ""); .updateAccountNumberPreference(this.clientAccountNumberPreferenceId, "103", this.responseValidationError, "");
Assertions.assertEquals("validation.msg.validation.errors.exist", updationError1.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); 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"); this.groupAccountNo = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "accountNo");
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String groupsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String groupsPrefixName = (String) this.accountNumberPreferencesHelper
this.groupsAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.groupsAccountNumberPreferenceId, "prefixType.value");
if (groupsPrefixName.equals(this.officeName)) { if (groupsPrefixName.equals(this.officeName)) {
@@ -313,8 +317,8 @@ public class AccountNumberPreferencesTest {
Assertions.assertTrue(center.getName().equals(name)); Assertions.assertTrue(center.getName().equals(name));
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String centerPrefixName = (String) this.accountNumberPreferencesHelper
this.centerAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.centerAccountNumberPreferenceId, "prefixType.value");
final String CENTER_URL = "/fineract-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER; final String CENTER_URL = "/fineract-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER;
if (centerPrefixName.equals(this.officeName)) { if (centerPrefixName.equals(this.officeName)) {
@@ -326,7 +330,6 @@ public class AccountNumberPreferencesTest {
} }
} }
private void createAndValidateClientWithoutAccountPreference() { private void createAndValidateClientWithoutAccountPreference() {
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(this.clientId); Assertions.assertNotNull(this.clientId);
@@ -337,8 +340,8 @@ public class AccountNumberPreferencesTest {
private void createAndValidateClientBasedOnAccountPreference() { private void createAndValidateClientBasedOnAccountPreference() {
final String codeName = "ClientType"; final String codeName = "ClientType";
String clientAccountNo = null; String clientAccountNo = null;
String clientPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String clientPrefixName = (String) this.accountNumberPreferencesHelper
this.clientAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.clientAccountNumberPreferenceId, "prefixType.value");
if (clientPrefixName.equals(this.clientTypeName)) { if (clientPrefixName.equals(this.clientTypeName)) {
/* Retrieve Code id for the Code "ClientType" */ /* Retrieve Code id for the Code "ClientType" */
@@ -390,7 +393,7 @@ public class AccountNumberPreferencesTest {
.withInterestRateFrequencyTypeAsYear().build(null); .withInterestRateFrequencyTypeAsYear().build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); 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) { private void createAndValidateLoanEntity(Boolean isAccountPreferenceSetUp) {
@@ -405,15 +408,15 @@ public class AccountNumberPreferencesTest {
.withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2") .withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2")
.build(this.clientId.toString(), this.loanProductId.toString(), null); .build(this.clientId.toString(), this.loanProductId.toString(), null);
LOG.info("Loan Application :{}" , loanApplicationJSON); LOG.info("Loan Application :{}", loanApplicationJSON);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
String loanAccountNo = (String) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanId, String loanAccountNo = (String) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanId,
"accountNo"); "accountNo");
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String loanPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String loanPrefixName = (String) this.accountNumberPreferencesHelper
this.loanAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.loanAccountNumberPreferenceId, "prefixType.value");
if (loanPrefixName.equals(this.officeName)) { if (loanPrefixName.equals(this.officeName)) {
String loanOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "officeName"); String loanOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "officeName");
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanOfficeName); this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanOfficeName);
@@ -422,10 +425,10 @@ public class AccountNumberPreferencesTest {
this.loanProductId, "shortName"); this.loanProductId, "shortName");
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanShortName); 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 { } else {
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, null); 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) .withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance)
.withMinimumOpenningBalance(this.MINIMUM_OPENING_BALANCE).build(); .withMinimumOpenningBalance(this.MINIMUM_OPENING_BALANCE).build();
this.savingsProductId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec); this.savingsProductId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec);
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.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
this.savingsId = this.savingsAccountHelper this.savingsId = this.savingsAccountHelper.applyForSavingsApplication(this.clientId, this.savingsProductId,
.applyForSavingsApplication(this.clientId, this.savingsProductId, ACCOUNT_TYPE_INDIVIDUAL); ACCOUNT_TYPE_INDIVIDUAL);
String savingsAccountNo = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "accountNo"); String savingsAccountNo = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "accountNo");
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String savingsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String savingsPrefixName = (String) this.accountNumberPreferencesHelper
this.savingsAccountNumberPreferenceId, "prefixType.value"); .getAccountNumberPreference(this.savingsAccountNumberPreferenceId, "prefixType.value");
if (savingsPrefixName.equals(this.officeName)) { if (savingsPrefixName.equals(this.officeName)) {
String savingsOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), 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"); String loanShortName = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "shortName");
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, loanShortName); 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 { } else {
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, null); 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 @AfterEach
public void tearDown() { public void tearDown() {
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = financialActivityAccountHelper
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
} }
@@ -214,10 +214,10 @@ public class AccountTransferTest {
HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsID); HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsID);
assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"), assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"),
"Verifying To Savings Account Balance after Account Transfer"); "Verifying To Savings Account Balance after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), final JournalEntry[] office1LiabilityEntries = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), final JournalEntry[] office2LiabilityEntries = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries); AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -311,10 +311,10 @@ public class AccountTransferTest {
assertEquals(TRANSFER_AMOUNT_ADJUST, toLoanSummaryAfter.get("totalRepayment"), assertEquals(TRANSFER_AMOUNT_ADJUST, toLoanSummaryAfter.get("totalRepayment"),
"Verifying To Loan Repayment Amount after Account Transfer"); "Verifying To Loan Repayment Amount after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office1LiabilityEntries = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office2LiabilityEntries = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries); AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -432,10 +432,10 @@ public class AccountTransferTest {
assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"), assertEquals(toSavingsBalance, toSavingsSummaryAfter.get("accountBalance"),
"Verifying From Savings Account Balance after Account Transfer"); "Verifying From Savings Account Balance after Account Transfer");
final JournalEntry[] office1LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office1LiabilityEntries = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), final JournalEntry[] office2LiabilityEntries = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(Float.valueOf(ACCOUNT_TRANSFER_AMOUNT_ADJUST), JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries); AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
@@ -68,6 +68,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
public class AccountingScenarioIntegrationTest { public class AccountingScenarioIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class);
private static RequestSpecification requestSpec; private static RequestSpecification requestSpec;
private static ResponseSpecification responseSpec; private static ResponseSpecification responseSpec;
@@ -94,7 +95,8 @@ public class AccountingScenarioIntegrationTest {
Float SP_WITHDRAWAL_AMOUNT = Float.valueOf(WITHDRAWAL_AMOUNT); Float SP_WITHDRAWAL_AMOUNT = Float.valueOf(WITHDRAWAL_AMOUNT);
Float SP_WITHDRAWAL_AMOUNT_ADJUSTED = Float.valueOf(WITHDRAWAL_AMOUNT_ADJUSTED); 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[] REPAYMENT_AMOUNT = { .0f, 2200.0f, 3000.0f, 900.0f, 2000.0f, 2500.0f };
private final Float AMOUNT_TO_BE_WAIVE = 400.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[] assetAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) }; final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountInitialEntry);
this.journalEntryHelper this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, liablilityAccountInitialEntry); liablilityAccountInitialEntry);
// First Transaction-Deposit // First Transaction-Deposit
this.savingsAccountHelper.depositToSavingsAccount(savingsID, DEPOSIT_AMOUNT, SavingsAccountHelper.TRANSACTION_DATE, 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"); assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after Deposit");
LOG.info("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------"); LOG.info("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------");
final JournalEntry[] assetAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, final JournalEntry[] assetAccountFirstTransactionEntry = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(this.SP_DEPOSIT_AMOUNT, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] liabililityAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, final JournalEntry[] liabililityAccountFirstTransactionEntry = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.SP_DEPOSIT_AMOUNT, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountFirstTransactionEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountFirstTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liabililityAccountFirstTransactionEntry); liabililityAccountFirstTransactionEntry);
@@ -301,10 +303,10 @@ public class AccountingScenarioIntegrationTest {
assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after Withdrawal"); assertEquals(balance, summary.get("accountBalance"), "Verifying Balance after Withdrawal");
LOG.info("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------"); LOG.info("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------");
final JournalEntry[] assetAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, final JournalEntry[] assetAccountSecondTransactionEntry = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] liabililityAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, final JournalEntry[] liabililityAccountSecondTransactionEntry = {
JournalEntry.TransactionType.DEBIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, JournalEntry.TransactionType.DEBIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountSecondTransactionEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountSecondTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE,
liabililityAccountSecondTransactionEntry); liabililityAccountSecondTransactionEntry);
@@ -322,16 +324,15 @@ public class AccountingScenarioIntegrationTest {
Float chargeAmount = (Float) paidCharge.get("amount"); Float chargeAmount = (Float) paidCharge.get("amount");
// Withdrawal after adding Charge of type Withdrawal Fee // Withdrawal after adding Charge of type Withdrawal Fee
this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsID, WITHDRAWAL_AMOUNT_ADJUSTED, this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsID, WITHDRAWAL_AMOUNT_ADJUSTED, SavingsAccountHelper.TRANSACTION_DATE,
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
summary = this.savingsAccountHelper.getSavingsSummary(savingsID); summary = this.savingsAccountHelper.getSavingsSummary(savingsID);
balance = balance - SP_WITHDRAWAL_AMOUNT_ADJUSTED - chargeAmount; balance = balance - SP_WITHDRAWAL_AMOUNT_ADJUSTED - chargeAmount;
final JournalEntry[] liabililityAccountThirdTransactionEntry = { final JournalEntry[] liabililityAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(chargeAmount, JournalEntry.TransactionType.DEBIT),
new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.DEBIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.DEBIT) };
final JournalEntry[] assetAccountThirdTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, final JournalEntry[] assetAccountThirdTransactionEntry = {
JournalEntry.TransactionType.CREDIT) }; new JournalEntry(this.SP_WITHDRAWAL_AMOUNT_ADJUSTED, JournalEntry.TransactionType.CREDIT) };
final JournalEntry[] incomeAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.CREDIT) }; final JournalEntry[] incomeAccountThirdTransactionEntry = { new JournalEntry(chargeAmount, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountThirdTransactionEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountThirdTransactionEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, 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); VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, RecurringDepositTest.WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
Assertions.assertNotNull(recurringDepositAccountId); Assertions.assertNotNull(recurringDepositAccountId);
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); .getStatusOfRecurringDepositAccount(this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
@@ -529,13 +530,14 @@ public class AccountingScenarioIntegrationTest {
LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType);
return this.fixedDepositAccountHelper return this.fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec,
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); this.responseSpec);
} }
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) { private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) {
LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec,
this.responseSpec);
final String recurringDepositProductJSON = recurringDepositProductHelper // final String recurringDepositProductJSON = recurringDepositProductHelper //
.withPeriodRangeChart()// .withPeriodRangeChart()//
.withAccountingRuleAsCashBased(accounts).build(validFrom, validTo); .withAccountingRuleAsCashBased(accounts).build(validFrom, validTo);
@@ -554,7 +556,7 @@ public class AccountingScenarioIntegrationTest {
} }
@Test @Test
public void checkPeriodicAccrualAccountingFlow() throws InterruptedException,ParseException { public void checkPeriodicAccrualAccountingFlow() throws InterruptedException, ParseException {
final Account assetAccount = this.accountHelper.createAssetAccount(); final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -667,7 +669,7 @@ public class AccountingScenarioIntegrationTest {
} }
@Test @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 assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -715,14 +717,14 @@ public class AccountingScenarioIntegrationTest {
final JournalEntry[] assetAccountEntry = { new JournalEntry(15000f, JournalEntry.TransactionType.DEBIT), final JournalEntry[] assetAccountEntry = { new JournalEntry(15000f, JournalEntry.TransactionType.DEBIT),
new JournalEntry(11000f, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(11000f, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry);
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f, this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1],
JournalEntry.TransactionType.CREDIT)); new JournalEntry(4000f, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment Done......"); LOG.info("Repayment Done......");
} }
@Test @Test
public void checkPeriodicAccrualAccountingTillCurrentDateFlow() throws InterruptedException,ParseException { public void checkPeriodicAccrualAccountingTillCurrentDateFlow() throws InterruptedException, ParseException {
final Account assetAccount = this.accountHelper.createAssetAccount(); final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -738,8 +740,8 @@ public class AccountingScenarioIntegrationTest {
final float PENALTY_PORTION = 100.0f; final float PENALTY_PORTION = 100.0f;
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false)); ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true)); .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -766,10 +768,8 @@ public class AccountingScenarioIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
todayDate.add(Calendar.DATE, 1); todayDate.add(Calendar.DATE, 1);
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION))); String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION)));
@@ -814,7 +814,7 @@ public class AccountingScenarioIntegrationTest {
} }
@Test @Test
public void checkPeriodicAccrualAccountingAPIFlow() throws ParseException{ public void checkPeriodicAccrualAccountingAPIFlow() throws ParseException {
final Account assetAccount = this.accountHelper.createAssetAccount(); final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount();
final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account expenseAccount = this.accountHelper.createExpenseAccount();
@@ -833,11 +833,11 @@ public class AccountingScenarioIntegrationTest {
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false)); ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true)); .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
Integer flatNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( Integer flatNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_FEE_PORTION), false)); .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_FEE_PORTION), false));
Integer flatSpecifiedDueDateNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper Integer flatSpecifiedDueDateNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_PENALTY_PORTION), true)); .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); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
todayDate.add(Calendar.DATE, 1); todayDate.add(Calendar.DATE, 1);
String runOndate = dateFormat.format(todayDate.getTime()); String runOndate = dateFormat.format(todayDate.getTime());
this.loanTransactionHelper this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper
.addChargesForLoan( .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), runOndate, String.valueOf(FEE_PORTION)));
loanID,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), runOndate,
String.valueOf(FEE_PORTION)));
todayDate.add(Calendar.DATE, 1); todayDate.add(Calendar.DATE, 1);
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatSpecifiedDueDateNext), dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_PENALTY_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDateNext),
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_PENALTY_PORTION)));
this.loanTransactionHelper.addChargesForLoan( this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
loanID, String.valueOf(flatNext), dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatNext),
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
// CHECK ACCOUNT ENTRIES // CHECK ACCOUNT ENTRIES
LOG.info("Entries ......"); LOG.info("Entries ......");
@@ -986,8 +977,8 @@ public class AccountingScenarioIntegrationTest {
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
LOG.info("CHECKING INCOME: ******************************************"); LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1], new JournalEntry(FIRST_INTEREST, this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1],
JournalEntry.TransactionType.CREDIT)); new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment 1 Done......"); LOG.info("Repayment 1 Done......");
// REPAYMENT 2 // REPAYMENT 2
@@ -1001,8 +992,8 @@ public class AccountingScenarioIntegrationTest {
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), }; new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
LOG.info("CHECKING INCOME: ******************************************"); LOG.info("CHECKING INCOME: ******************************************");
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2], new JournalEntry( this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2],
SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT)); new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT));
LOG.info("Repayment 2 Done ......"); LOG.info("Repayment 2 Done ......");
// WAIVE INTEREST // WAIVE INTEREST
@@ -1053,7 +1044,7 @@ public class AccountingScenarioIntegrationTest {
return this.loanTransactionHelper.getLoanProductId(loanProductJSON); 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); DateFormat df = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
LocalDate date = new LocalDate(df.parse(dateAsString)); LocalDate date = new LocalDate(df.parse(dateAsString));
@@ -33,9 +33,8 @@ public class ActuatorIntegrationTest {
@Test @Test
public void testActuatorGitBuildInfo() { public void testActuatorGitBuildInfo() {
Response response = RestAssured.given() Response response = RestAssured.given().headers("Content-Type", ContentType.JSON, "Accept", ContentType.JSON).when().get(INFO_URL)
.headers("Content-Type", ContentType.JSON, "Accept", ContentType.JSON).when() .then().contentType(ContentType.JSON).extract().response();
.get(INFO_URL).then().contentType(ContentType.JSON).extract().response();
Map<String, String> gitBuildInfo = response.jsonPath().getMap("git"); 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, * 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 @BeforeEach
public void setup() { public void setup() {
@@ -333,10 +334,10 @@ public class BatchApiTest {
} }
/** /**
* Tests that batch repayment for loans is happening properly. * Tests that batch repayment for loans is happening properly. Collected
* Collected properly 200(OK) status was returned for successful responses. * properly 200(OK) status was returned for successful responses. It first
* It first creates a new loan and then makes two repayments for it * creates a new loan and then makes two repayments for it and then verifies
* and then verifies that 200(OK) is returned for the repayment requests. * that 200(OK) is returned for the repayment requests.
* *
* @see org.apache.fineract.batch.command.internal.RepayLoanCommandStrategy * @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 * Test for the successful create client, apply loan,approval and disbursal
* Batch API with enclosingTransaction. A '200' status code is expected on successful activation. * 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.ApproveLoanCommandStrategy
* @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusOnSuccessfulLoanApprovalAndDisburseWithTransaction(){ public void shouldReturnOkStatusOnSuccessfulLoanApprovalAndDisburseWithTransaction() {
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("10000000.00") // .withPrincipal("10000000.00") //
.withNumberOfRepayments("24") // .withNumberOfRepayments("24") //
@@ -515,7 +517,7 @@ public class BatchApiTest {
// Create a disburseLoan Request // Create a disburseLoan Request
final BatchRequest br4 = BatchHelper.disburseLoanRequest(4744L, 4743L); 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); final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
@@ -58,7 +58,8 @@ public class BatchRequestsIntegrationTest {
/** /**
* Sets up the essential settings for the TEST like contentType, * 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 @BeforeEach
public void setup() { public void setup() {
@@ -91,7 +92,7 @@ public class BatchRequestsIntegrationTest {
for (Integer i = 0; i < clientsCount; i++) { for (Integer i = 0; i < clientsCount; i++) {
clientIDs[i] = ClientHelper.createClient(this.requestSpec, this.responseSpec); clientIDs[i] = ClientHelper.createClient(this.requestSpec, this.responseSpec);
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientIDs[i].toString()); groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientIDs[i].toString());
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 // 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; import org.slf4j.LoggerFactory;
public class CenterIntegrationTest { public class CenterIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(CenterIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(CenterIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -106,8 +107,8 @@ public class CenterIntegrationTest {
Assertions.assertNotNull(paginatedList); Assertions.assertNotNull(paginatedList);
Assertions.assertNotNull(list); Assertions.assertNotNull(list);
Assertions.assertTrue(Arrays.equals(paginatedList.toArray(new CenterDomain[paginatedList.size()]), Assertions.assertTrue(
list.toArray(new CenterDomain[list.size()]))); Arrays.equals(paginatedList.toArray(new CenterDomain[paginatedList.size()]), list.toArray(new CenterDomain[list.size()])));
} }
@Test @Test
@@ -162,7 +163,7 @@ public class CenterIntegrationTest {
Assertions.assertNotNull(center); Assertions.assertNotNull(center);
Assertions.assertEquals(newName, center.getName()); Assertions.assertEquals(newName, center.getName());
Assertions.assertEquals(newExternalId, center.getExternalId()); Assertions.assertEquals(newExternalId, center.getExternalId());
Assertions.assertEquals((Integer)newStaffId, center.getStaffId()); Assertions.assertEquals((Integer) newStaffId, center.getStaffId());
Assertions.assertArrayEquals(newGroupMembers, center.getGroupMembers()); Assertions.assertArrayEquals(newGroupMembers, center.getGroupMembers());
} }
@@ -190,8 +191,8 @@ public class CenterIntegrationTest {
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", "04 March 2011"); map.put("activationDate", "04 March 2011");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec, "/fineract-provider/api/v1/groups?" groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec,
+ Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId"); "/fineract-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
} }
return groupMembers; return groupMembers;
} }
@@ -200,7 +201,7 @@ public class CenterIntegrationTest {
public void testStaffAssignmentDuringCenterCreation() { public void testStaffAssignmentDuringCenterCreation() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating first staff with id------------- {}" , staffId); LOG.info("--------------creating first staff with id------------- {}", staffId);
Assertions.assertNotNull(staffId); Assertions.assertNotNull(staffId);
final int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId); final int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId);
@@ -214,15 +215,14 @@ public class CenterIntegrationTest {
@Test @Test
public void testAssignStaffToCenter() { public void testAssignStaffToCenter() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating first staff with id------------- {}" , staffId); LOG.info("--------------creating first staff with id------------- {}", staffId);
Assertions.assertNotNull(staffId); Assertions.assertNotNull(staffId);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID); CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec,
this.responseSpec, groupID.toString(), groupID.toString(), staffId.longValue());
staffId.longValue());
assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent"); assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent");
final CenterDomain center = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec); final CenterDomain center = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
@@ -235,24 +235,22 @@ public class CenterIntegrationTest {
@Test @Test
public void testUnassignStaffToCenter() { public void testUnassignStaffToCenter() {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
LOG.info("--------------creating first staff with id------------- {}" , staffId); LOG.info("--------------creating first staff with id------------- {}", staffId);
Assertions.assertNotNull(staffId); Assertions.assertNotNull(staffId);
final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID); CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, final HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec,
this.responseSpec, groupID.toString(), groupID.toString(), staffId.longValue());
staffId.longValue());
assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent"); assertEquals(assignStaffToCenterResponseMap.get("staffId"), staffId, "Verify assigned staff id is the same as id sent");
final CenterDomain centerWithStaffAssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec); final CenterDomain centerWithStaffAssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
Assertions.assertNotNull(centerWithStaffAssigned); Assertions.assertNotNull(centerWithStaffAssigned);
Assertions.assertTrue(centerWithStaffAssigned.getId().intValue() == groupID); Assertions.assertTrue(centerWithStaffAssigned.getId().intValue() == groupID);
Assertions.assertTrue(centerWithStaffAssigned.getStaffId().intValue() == staffId); Assertions.assertTrue(centerWithStaffAssigned.getStaffId().intValue() == staffId);
final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec, final HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec, this.responseSpec,
this.responseSpec, groupID.toString(), groupID.toString(), staffId.longValue());
staffId.longValue());
assertEquals(unassignStaffToCenterResponseMap.get("staffId"), null, "Verify staffId is null after unassigning "); assertEquals(unassignStaffToCenterResponseMap.get("staffId"), null, "Verify staffId is null after unassigning ");
final CenterDomain centerWithStaffUnssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec); final CenterDomain centerWithStaffUnssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
Assertions.assertNotNull(centerWithStaffUnssigned); 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; import org.slf4j.LoggerFactory;
public class ClientStatusChecker { public class ClientStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(ClientStatusChecker.class); private final static Logger LOG = LoggerFactory.getLogger(ClientStatusChecker.class);
public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) {
@@ -32,36 +33,31 @@ public class ClientStatusChecker {
} }
public static void verifyClientClosed(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientClosed(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
assertEquals(600, (int) clientStatusHashMap.get("id")); assertEquals(600, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientPending(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientPending(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
assertEquals(100, (int) clientStatusHashMap.get("id")); assertEquals(100, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientRejected(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientRejected(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
assertEquals(700, (int) clientStatusHashMap.get("id")); assertEquals(700, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientActiavted(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientActiavted(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
assertEquals(300, (int) clientStatusHashMap.get("id")); assertEquals(300, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
public static void verifyClientWithdrawn(final HashMap<String, Object> clientStatusHashMap) { public static void verifyClientWithdrawn(final HashMap<String, Object> clientStatusHashMap) {
LOG.info( LOG.info("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
"\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
assertEquals(800, (int) clientStatusHashMap.get("id")); assertEquals(800, (int) clientStatusHashMap.get("id"));
LOG.info("Client Status: {} \n", clientStatusHashMap); LOG.info("Client Status: {} \n", clientStatusHashMap);
} }
@@ -53,8 +53,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
@@ -69,8 +68,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -93,8 +91,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -122,8 +119,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
@@ -152,8 +148,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -182,8 +177,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -207,8 +201,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -236,8 +229,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
@@ -265,8 +257,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
@@ -297,16 +288,14 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec); final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
status = this.clientHelper.withdrawClient(clientId); status = this.clientHelper.withdrawClient(clientId);
ClientStatusChecker.verifyClientWithdrawn(status); ClientStatusChecker.verifyClientWithdrawn(status);
status = this.clientHelper.undoWithdrawn(clientId); status = this.clientHelper.undoWithdrawn(clientId);
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.activateClient(clientId, ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.activateClient(clientId, CommonConstants.RESPONSE_ERROR);
CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.clients.submittedOnDate.after.reopened.date", assertEquals("error.msg.clients.submittedOnDate.after.reopened.date",
clientErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); clientErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -315,15 +304,15 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
@Test @Test
public void testReopenedDate() { public void testReopenedDate() {
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build(); 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 // CREATE CLIENT
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec); final Integer clientId = ClientHelper.createClientPending(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId); Assertions.assertNotNull(clientId);
// GET CLIENT STATUS // GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status); ClientStatusChecker.verifyClientPending(status);
status = this.clientHelper.withdrawClient(clientId); status = this.clientHelper.withdrawClient(clientId);
@@ -41,6 +41,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ConcurrencyIntegrationTest { public class ConcurrencyIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ConcurrencyIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(ConcurrencyIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -75,7 +76,7 @@ public class ConcurrencyIntegrationTest {
date.set(2011, 9, 20); date.set(2011, 9, 20);
Float repaymentAmount = 100.0f; Float repaymentAmount = 100.0f;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
LOG.info("Starting concurrent transaction number {}" , i); LOG.info("Starting concurrent transaction number {}", i);
date.add(Calendar.DAY_OF_MONTH, 1); date.add(Calendar.DAY_OF_MONTH, 1);
repaymentAmount = repaymentAmount + 100; repaymentAmount = repaymentAmount + 100;
Runnable worker = new LoanRepaymentExecutor(loanTransactionHelper, loanID, repaymentAmount, date); Runnable worker = new LoanRepaymentExecutor(loanTransactionHelper, loanID, repaymentAmount, date);
@@ -152,12 +153,13 @@ public class ConcurrencyIntegrationTest {
try { try {
this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId); this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId);
} catch (Exception e) { } catch (Exception e) {
LOG.info("Found an exception {}" , e.getMessage()); LOG.info("Found an exception {}", e.getMessage());
LOG.info("Details of failed concurrent transaction (date, amount, loanId) are {},{},{}" , repaymentDate, repaymentAmount , loanId); LOG.info("Details of failed concurrent transaction (date, amount, loanId) are {},{},{}", repaymentDate, repaymentAmount,
loanId);
throw (e); throw (e);
} }
LOG.info("Details of passed concurrent transaction, details (date, amount, loanId) are {},{},{}" , repaymentDate LOG.info("Details of passed concurrent transaction, details (date, amount, loanId) are {},{},{}", repaymentDate,
, repaymentAmount , loanId); repaymentAmount, loanId);
} }
} }
@@ -73,7 +73,6 @@ public class CurrenciesTest {
currenciestoUpdate.add("USD"); currenciestoUpdate.add("USD");
currenciestoUpdate.add("INR"); currenciestoUpdate.add("INR");
ArrayList<String> currenciesOutput = CurrenciesHelper.updateSelectedCurrencies(this.requestSpec, this.responseSpec, ArrayList<String> currenciesOutput = CurrenciesHelper.updateSelectedCurrencies(this.requestSpec, this.responseSpec,
currenciestoUpdate); currenciestoUpdate);
Assertions.assertNotNull(currenciesOutput); Assertions.assertNotNull(currenciesOutput);
@@ -92,4 +91,4 @@ public class CurrenciesTest {
Assertions.assertEquals(currenciesBeforeUpdate, currenciesAfterUpdate, "Verifying Do Selected Currencies Match after Updation"); Assertions.assertEquals(currenciesBeforeUpdate, currenciesAfterUpdate, "Verifying Do Selected Currencies Match after Updation");
} }
} }
@@ -33,7 +33,6 @@ public class CurrencyIntegrationTest {
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private SavingsAccountHelper savingsAccountHelper; private SavingsAccountHelper savingsAccountHelper;
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -53,362 +53,352 @@ import org.junit.jupiter.api.Test;
@Disabled @Disabled
public class DisbursalAndRepaymentScheduleTest { public class DisbursalAndRepaymentScheduleTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403; private ResponseSpecification responseSpecForStatusCode403;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
private LoanRescheduleRequestHelper loanRescheduleRequestHelper; private LoanRescheduleRequestHelper loanRescheduleRequestHelper;
private Integer loanRescheduleRequestId; private Integer loanRescheduleRequestId;
private Integer clientId; private Integer clientId;
private Integer groupId; private Integer groupId;
private Integer groupCalendarId; private Integer groupCalendarId;
private Integer loanProductId; private Integer loanProductId;
private Integer loanId; private Integer loanId;
private final String loanPrincipalAmount = "100000.00"; private final String loanPrincipalAmount = "100000.00";
private final String numberOfRepayments = "12"; private final String numberOfRepayments = "12";
private final String interestRatePerPeriod = "18"; private final String interestRatePerPeriod = "18";
private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy"); private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy");
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
}
@Test
public void testRescheduleJLGLoanSynk() {
// system.out.println("---------------------------------STARTING
// RESCHEDULE JLG
// LOAN TEST ------------------------------------------");
Calendar meetingCalendar = Calendar.getInstance();
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
int today = meetingCalendar.get(Calendar.DAY_OF_WEEK);
// making sure that the meeting calendar is set for the coming monday.
if (today >= Calendar.MONDAY) {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
} else {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
} }
@Test Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
public void testRescheduleJLGLoanSynk() {
// system.out.println("---------------------------------STARTING RESCHEDULE JLG
// LOAN TEST ------------------------------------------");
Calendar meetingCalendar = Calendar.getInstance(); meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
int today = meetingCalendar.get(Calendar.DAY_OF_WEEK); final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
// making sure that the meeting calendar is set for the coming monday.
if (today >= Calendar.MONDAY) {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
} else {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
}
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); 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 this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
// after group creation 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 loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24")
final String rescheduleInterestRate = "28.0"; .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2")
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); .withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
final String groupMeetingNewStartDate = this.dateFormatterStandard .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate)
.format(groupMeetingChangeCalendar.getTime()); .withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin()
// The date .withCalendarID(this.groupCalendarId.toString())
// from .build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null);
// which we
// start the
// new group
// meeting
// occasion,
// this is a
// tuesday.
groupMeetingChangeCalendar.add(Calendar.WEEK_OF_YEAR, 2);
final String rescheduleDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime());
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); // Test for loan account is created
// system.out.println("---------------------------------CREATING ENTITIES AND Assertions.assertNotNull(this.loanId);
// JLG LOAN ------------------------------------------"); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
.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.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 // Test for loan account approved can be disbursed
Assertions.assertNotNull(this.loanId); this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
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 ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec,
this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId); this.loanId);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
// Test for loan account approved can be disbursed ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); Calendar dueDateCalendar = Calendar.getInstance();
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); 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 // system.out.println("---------------------------------CREATING LOAN
// DATE ------------------------------------------"); // RESCHEDULE
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, // REQUEST------------------------------------------");
this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New
// meeting
// dates
// will be
// the
// tuesday
// after the
// coming
// monday
ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2").updateGraceOnPrincipal("2")
generalResponseSpec, this.loanId); .updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate)
.updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString());
ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
Calendar dueDateCalendar = Calendar.getInstance(); this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
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("---------------------------------CREATING LOAN RESCHEDULE loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
// REQUEST------------------------------------------"); dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2") (Integer) dueDateLoanSchedule.get(2));
.updateGraceOnPrincipal("2").updateNewInterestRate(rescheduleInterestRate) assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
.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),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT"); "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: " + // system.out.println("Successfully created loan reschedule request (ID:
// this.loanRescheduleRequestId + ")"); // " +
// this.loanRescheduleRequestId + ")");
// system.out.println("-----------------------------APPROVING LOAN RESCHEDULE // system.out.println("-----------------------------APPROVING LOAN
// REQUEST--------------------------"); // RESCHEDULE
// REQUEST--------------------------");
requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate) requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate)
.getApproveLoanRescheduleRequestJSON(); .getApproveLoanRescheduleRequestJSON();
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); assertTrue((Boolean) response.get("approved"));
assertTrue((Boolean) response.get("approved"));
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
generalResponseSpec, this.loanId);
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
(Integer) dueDateLoanSchedule.get(2)); (Integer) dueDateLoanSchedule.get(2));
assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK),
"AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE"); "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE");
// system.out.println("Successfully changed group meeting date (CAELNDAR ID: " + // system.out.println("Successfully changed group meeting date (CAELNDAR
// this.groupCalendarId // ID: " +
// + ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId + // this.groupCalendarId
// ")"); // + ") and rescheduled loan (RESCHEDULE ID: " +
// this.loanRescheduleRequestId +
// ")");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
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 Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
public void testChangeGroupMeetingMaturedOnDate() {
// system.out
// .println("---------------------------------STARTING GROUP LOAN MEETING CHANGE
// DATE EXPECTED MATURED CHANGE------------------------------------------");
Calendar meetingCalendar = Calendar.getInstance(); meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
meetingCalendar.setTime(new java.util.Date());
int today = meetingCalendar.get(Calendar.DAY_OF_WEEK); final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime());
// making sure that the meeting calendar is set for the coming monday.
if (today >= Calendar.MONDAY) {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
} else {
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
}
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); 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 this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
// after group creation // system.out.println("---------------------------------CREATING
// ENTITIES AND
// JLG LOAN ------------------------------------------");
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String loanType = "jlg"; final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24")
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2")
final String groupMeetingNewStartDate = this.dateFormatterStandard .withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
.format(groupMeetingChangeCalendar.getTime()); .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate)
// The date .withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin()
// from .withCalendarID(this.groupCalendarId.toString())
// which we .build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null);
// start the
// new group
// meeting
// occasion,
// this is a
// tuesday.
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build();
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); // Test for loan account is created
// system.out.println("---------------------------------CREATING ENTITIES AND Assertions.assertNotNull(this.loanId);
// JLG LOAN ------------------------------------------"); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
// create all required entities
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
.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.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 // Test for loan account approved can be disbursed
Assertions.assertNotNull(this.loanId); this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
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 Calendar expectedMaturityCalendar = Calendar.getInstance();
this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId); expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec,
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); this.loanId, "timeline")).get("expectedMaturityDate"));
// Test for loan account approved can be disbursed expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), (Integer) expectedMaturityDate.get(1) - 1,
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); (Integer) expectedMaturityDate.get(2));
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// system.out.println("---------------------------------CHANGING GROUP MEETING assertEquals(3, expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK),
// DATE ------------------------------------------"); "AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY");
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId,
this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New
// meeting
// dates
// will be
// the
// tuesday
// after the
// coming
// monday
Calendar expectedMaturityCalendar = Calendar.getInstance(); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY); }
ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper
.getLoanDetail(requestSpec, generalResponseSpec, this.loanId, "timeline"))
.get("expectedMaturityDate"));
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
} */
/** private void associateClientToGroup(final Integer groupId, final Integer clientId) {
* entities for jlg loan GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString());
**/ GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId);
private void createRequiredEntitiesForJLGLoanSync(final String groupActivationDate) { }
this.createGroupEntityWithCalendar("2", "2", "1", groupActivationDate);// frequency=2:Weekly
// , interval=2:
// Every two weeks ,
// repeatsOnDay=1:Monday
// groupActivationDate is decided by the current date
this.createClientEntity();
this.associateClientToGroup(this.groupId, this.clientId);
this.createLoanProductEntity();
} private void createGroupEntityWithCalendar(final String frequency, final String interval, final String repeatsOnDay,
final String groupActivationDate) {
this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate);
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId);
/* final String startDate = groupActivationDate;
* Associate client to the group
*/
private void associateClientToGroup(final Integer groupId, final Integer clientId) { this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, startDate,
GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), frequency, interval, repeatsOnDay));
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) { * create a new client
this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate); **/
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId); 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, public void setGroupCalendarId(Integer groupCalendarId) {
this.responseSpec, this.groupId, startDate, frequency, interval, repeatsOnDay)); this.groupCalendarId = groupCalendarId;
} }
}
/**
* 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;
}
}
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" }) @SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
public class ExternalServicesConfigurationTest { public class ExternalServicesConfigurationTest {
private final static Logger LOG = LoggerFactory.getLogger(ExternalServicesConfigurationTest.class); private final static Logger LOG = LoggerFactory.getLogger(ExternalServicesConfigurationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -65,11 +66,11 @@ public class ExternalServicesConfigurationTest {
String value = null; String value = null;
if (name.equals(configName)) { if (name.equals(configName)) {
value = (String) externalServicesConfig.get(configIndex).get("value"); value = (String) externalServicesConfig.get(configIndex).get("value");
if(value == null){ if (value == null) {
value = "testnull"; value = "testnull";
} }
String newValue = "test"; String newValue = "test";
LOG.info( "{} : {}",name, value); LOG.info("{} : {}", name, value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec, HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "S3", name, newValue); responseSpec, "S3", name, newValue);
Assertions.assertNotNull(arrayListValue.get("value")); Assertions.assertNotNull(arrayListValue.get("value"));
@@ -93,11 +94,11 @@ public class ExternalServicesConfigurationTest {
String value = null; String value = null;
if (name.equals(configName)) { if (name.equals(configName)) {
value = (String) externalServicesConfig.get(configIndex).get("value"); value = (String) externalServicesConfig.get(configIndex).get("value");
if(value == null){ if (value == null) {
value = "testnull"; value = "testnull";
} }
String newValue = "test"; String newValue = "test";
LOG.info("{} : {}",name,value); LOG.info("{} : {}", name, value);
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec, HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
responseSpec, "SMTP", name, newValue); responseSpec, "SMTP", name, newValue);
Assertions.assertNotNull(arrayListValue.get("value")); Assertions.assertNotNull(arrayListValue.get("value"));
@@ -86,7 +86,8 @@ public class FinancialActivityAccountsTest {
* Fetch Created Financial Activity to Account Mapping and validate * Fetch Created Financial Activity to Account Mapping and validate
* created values * 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 * 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)); invalidFinancialActivityAccountError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
/** Should be able to delete a Financial Activity to Account Mapping **/ /** Should be able to delete a Financial Activity to Account Mapping **/
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = financialActivityAccountHelper
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
@@ -138,7 +139,8 @@ public class FinancialActivityAccountsTest {
financialActivityAccountHelper.getFinancialActivityAccount(deletedFinancialActivityAccountId, responseSpecForResourceNotFoundError); 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); HashMap mappingDetails = financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId, responseSpec);
Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id")); Assertions.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
Assertions.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).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); List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
for (HashMap financialActivity : financialActivities) { for (HashMap financialActivity : financialActivities) {
Integer financialActivityAccountId = (Integer) financialActivity.get("id"); Integer financialActivityAccountId = (Integer) financialActivity.get("id");
Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper.deleteFinancialActivityAccount( Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper
financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID); .deleteFinancialActivityAccount(financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(deletedFinancialActivityAccountId); Assertions.assertNotNull(deletedFinancialActivityAccountId);
Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
} }
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unused", "unchecked" }) @SuppressWarnings({ "rawtypes", "unused", "unchecked" })
public class FlexibleSavingsInterestPostingIntegrationTest { public class FlexibleSavingsInterestPostingIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class);
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
@@ -74,8 +75,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
final Integer savingsId = createSavingsAccount(clientID, startDate); final Integer savingsId = createSavingsAccount(clientID, startDate);
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate, this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate, CommonConstants.RESPONSE_RESOURCE_ID);
CommonConstants.RESPONSE_RESOURCE_ID);
/*** /***
* Perform Post interest transaction and verify the posted transaction * Perform Post interest transaction and verify the posted transaction
@@ -85,8 +85,9 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions"); ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2); HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
for (Entry<String, Object> entry : interestPostingTransaction.entrySet()) for (Entry<String, Object> entry : interestPostingTransaction.entrySet()) {
{LOG.info("{} - {}",entry.getKey(), entry.getValue().toString());} LOG.info("{} - {}", entry.getKey(), entry.getValue().toString());
}
// 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily // 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily
// balance // balance
// 33.7016 obtained from formula in excel provided by Subramanya // 33.7016 obtained from formula in excel provided by Subramanya
@@ -123,16 +124,16 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled"); Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
if (!enabled.equals(periodEndEnable)) { if (!enabled.equals(periodEndEnable)) {
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
this.responseSpec, periodEndConfigId.toString(), periodEndEnable); periodEndConfigId.toString(), periodEndEnable);
} }
// Updating value for financial year beginning month // Updating value for financial year beginning month
Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id"); Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
Assertions.assertNotNull(financialYearBeginningConfigId); Assertions.assertNotNull(financialYearBeginningConfigId);
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
this.responseSpec, financialYearBeginningConfigId.toString()); financialYearBeginningConfigId.toString());
Assertions.assertNotNull(financialYearBeginningConfigData); Assertions.assertNotNull(financialYearBeginningConfigData);
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
@@ -57,10 +57,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFund() { public void testCreateFund() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -69,10 +66,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithEmptyName() { public void testCreateFundWithEmptyName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(null).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(null)
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -82,10 +76,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithEmptyExternalId() { public void testCreateFundWithEmptyExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(null).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(null)
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -94,19 +85,13 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithDuplicateName() { public void testCreateFundWithDuplicateName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
Assertions.assertNotNull(fundID); Assertions.assertNotNull(fundID);
FundsHelper fh2 = FundsHelper FundsHelper fh2 = FundsHelper.create(fh.getName()).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(fh.getName())
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
jsonData = fh2.toJSON(); jsonData = fh2.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
@@ -116,19 +101,13 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithDuplicateExternalId() { public void testCreateFundWithDuplicateExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
Assertions.assertNotNull(fundID); Assertions.assertNotNull(fundID);
FundsHelper fh2 = FundsHelper FundsHelper fh2 = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(fh.getExternalId()).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(fh.getExternalId())
.build();
jsonData = fh2.toJSON(); jsonData = fh2.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
@@ -138,10 +117,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithInvalidName() { public void testCreateFundWithInvalidName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 120)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 120))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -151,10 +127,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testCreateFundWithInvalidExternalId() { public void testCreateFundWithInvalidExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 120)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 120))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
@@ -164,10 +137,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testRetrieveFund() { public void testRetrieveFund() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -181,10 +151,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testRetrieveAllFunds() { public void testRetrieveAllFunds() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -201,16 +168,13 @@ public class FundsIntegrationTest {
public void testRetrieveUnknownFund() { public void testRetrieveUnknownFund() {
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
String jsonData = FundsResourceHandler.retrieveFund(Long.MAX_VALUE, this.requestSpec, responseSpec); 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")); assertEquals("error.msg.resource.not.found", map.get("userMessageGlobalisationCode"));
} }
@Test @Test
public void testUpdateFund() { public void testUpdateFund() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -229,17 +193,13 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 10); String newName = Utils.randomNameGenerator("", 10);
String newExternalId = Utils.randomNameGenerator("fund-", 5); String newExternalId = Utils.randomNameGenerator("fund-", 5);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec, FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec, responseSpec);
responseSpec);
Assertions.assertNull(fh); Assertions.assertNull(fh);
} }
@Test @Test
public void testUpdateFundWithInvalidNewName() { public void testUpdateFundWithInvalidNewName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -248,18 +208,14 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 120); String newName = Utils.randomNameGenerator("", 120);
String newExternalId = Utils.randomNameGenerator("fund-", 5); String newExternalId = Utils.randomNameGenerator("fund-", 5);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, responseSpec);
responseSpec);
Assertions.assertNull(fh2); Assertions.assertNull(fh2);
} }
@Test @Test
public void testUpdateFundWithNewExternalId() { public void testUpdateFundWithNewExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -273,10 +229,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testUpdateFundWithInvalidNewExternalId() { public void testUpdateFundWithInvalidNewExternalId() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -285,18 +238,14 @@ public class FundsIntegrationTest {
String newName = Utils.randomNameGenerator("", 10); String newName = Utils.randomNameGenerator("", 10);
String newExternalId = Utils.randomNameGenerator("fund-", 120); String newExternalId = Utils.randomNameGenerator("fund-", 120);
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, responseSpec);
responseSpec);
Assertions.assertNull(fh2); Assertions.assertNull(fh2);
} }
@Test @Test
public void testUpdateFundWithNewName() { public void testUpdateFundWithNewName() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -310,10 +259,7 @@ public class FundsIntegrationTest {
@Test @Test
public void testUpdateFundWithEmptyParams() { public void testUpdateFundWithEmptyParams() {
FundsHelper fh = FundsHelper FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)).externalId(Utils.randomNameGenerator("fund-", 5)).build();
.create(Utils.randomNameGenerator("", 10))
.externalId(Utils.randomNameGenerator("fund-", 5))
.build();
String jsonData = fh.toJSON(); String jsonData = fh.toJSON();
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
@@ -333,9 +279,7 @@ public class FundsIntegrationTest {
Assertions.assertEquals(fh.getExternalId(), fh3.getExternalId()); Assertions.assertEquals(fh.getExternalId(), fh3.getExternalId());
} }
private Long createFund(final String fundJSON, private Long createFund(final String fundJSON, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
String fundId = String.valueOf(FundsResourceHandler.createFund(fundJSON, requestSpec, responseSpec)); String fundId = String.valueOf(FundsResourceHandler.createFund(fundJSON, requestSpec, responseSpec));
if (fundId.equals("null")) { if (fundId.equals("null")) {
// Invalid JSON data parameters // 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.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest { public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -53,30 +52,27 @@ public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest {
GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec);
} }
@SuppressWarnings( {"static-access", "rawtypes", "unchecked"}) @SuppressWarnings({ "static-access", "rawtypes", "unchecked" })
@Test @Test
public void testInterestChargedFromDateSameAsDisbursalDate(){ public void testInterestChargedFromDateSameAsDisbursalDate() {
this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); this.responseSpec);
Assertions.assertNotNull(globalConfig); Assertions.assertNotNull(globalConfig);
String configName = "interest-charged-from-date-same-as-disbursal-date"; String configName = "interest-charged-from-date-same-as-disbursal-date";
boolean newBooleanValue = true; boolean newBooleanValue = true;
for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) {
if (globalConfig.get(configIndex).get("name") if (globalConfig.get(configIndex).get("name").equals(configName)) {
.equals(configName)) { String configId = globalConfig.get(configIndex).get("id").toString();
String configId = globalConfig.get(configIndex).get("id") Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
.toString(); this.responseSpec, configId.toString(), newBooleanValue);
Integer updateConfigId = this.globalConfigurationHelper Assertions.assertNotNull(updateConfigId);
.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, break;
configId.toString(), newBooleanValue); }
Assertions.assertNotNull(updateConfigId);
break;
}
} }
} }
@@ -137,8 +137,8 @@ public class GlobalConfigurationTest {
cacheTypeId -= 1; cacheTypeId -= 1;
} }
HashMap changes = this.globalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec, HashMap changes = this.globalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec, this.responseSpec,
this.responseSpec, cacheTypeId.toString()); cacheTypeId.toString());
Assertions.assertEquals(cacheTypeId, changes.get("cacheType"), "Verifying Is Cache Enabled Global Config after Updation"); Assertions.assertEquals(cacheTypeId, changes.get("cacheType"), "Verifying Is Cache Enabled Global Config after Updation");
} }
} }
@@ -147,8 +147,8 @@ public class GlobalConfigurationTest {
public void testGlobalConfigForcePasswordResetDays() { public void testGlobalConfigForcePasswordResetDays() {
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); this.responseSpec);
Assertions.assertNotNull(globalConfig); Assertions.assertNotNull(globalConfig);
String configName = "force-password-reset-days"; String configName = "force-password-reset-days";
@@ -157,23 +157,18 @@ public class GlobalConfigurationTest {
for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) {
if (globalConfig.get(configIndex).get("name").equals(configName)) { if (globalConfig.get(configIndex).get("name").equals(configName)) {
Integer configId = (Integer) globalConfig.get(configIndex).get( Integer configId = (Integer) globalConfig.get(configIndex).get("id");
"id");
Assertions.assertNotNull(configId); Assertions.assertNotNull(configId);
/* /*
* Update force-password-reset-days with value as 0 and Enable * Update force-password-reset-days with value as 0 and Enable
* as true - failure case * as true - failure case
*/ */
ArrayList error = (ArrayList) this.globalConfigurationHelper ArrayList error = (ArrayList) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(this.requestSpec,
.updatePasswordResetDaysForGlobalConfiguration( this.httpStatusForidden, configId, newValue, newBooleanValue, CommonConstants.RESPONSE_ERROR);
this.requestSpec, this.httpStatusForidden,
configId, newValue, newBooleanValue,
CommonConstants.RESPONSE_ERROR);
HashMap hash = (HashMap) error.get(0); HashMap hash = (HashMap) error.get(0);
Assertions.assertEquals( Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero",
"error.msg.password.reset.days.value.must.be.greater.than.zero",
hash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), hash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"Force Password Reset days value must be greater than zero."); "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 * Update force-password-reset-days with value as 50 and Enable
* as true - success case * as true - success case
*/ */
final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
.updatePasswordResetDaysForGlobalConfiguration( this.requestSpec, this.responseSpec, configId, "50", newBooleanValue, "changes");
this.requestSpec, this.responseSpec, configId,
"50", newBooleanValue, "changes");
Assertions.assertNotNull(updateSuccess); Assertions.assertNotNull(updateSuccess);
/* Update with value as 0 and Enable as false - success case */ /* Update with value as 0 and Enable as false - success case */
final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
.updatePasswordResetDaysForGlobalConfiguration( this.requestSpec, this.responseSpec, configId, newValue, "false", "changes");
this.requestSpec, this.responseSpec, configId,
newValue, "false", "changes");
Assertions.assertNotNull(updateSuccess1); Assertions.assertNotNull(updateSuccess1);
/* Update without sending value and Enable as true - failure case*/ /*
ArrayList failure = (ArrayList) this.globalConfigurationHelper * Update without sending value and Enable as true - failure
.updatePasswordResetDaysForGlobalConfiguration( * case
this.requestSpec, this.httpStatusForidden, configId, */
null, newBooleanValue, CommonConstants.RESPONSE_ERROR); ArrayList failure = (ArrayList) this.globalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(
this.requestSpec, this.httpStatusForidden, configId, null, newBooleanValue, CommonConstants.RESPONSE_ERROR);
HashMap failureHash = (HashMap) failure.get(0); HashMap failureHash = (HashMap) failure.get(0);
Assertions.assertEquals( Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero",
"error.msg.password.reset.days.value.must.be.greater.than.zero",
failureHash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), failureHash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"Force Password Reset days value must be greater than zero."); "Force Password Reset days value must be greater than zero.");
@@ -211,13 +202,10 @@ public class GlobalConfigurationTest {
/* Update other global configuration property */ /* Update other global configuration property */
String otherConfigName = "maker-checker"; String otherConfigName = "maker-checker";
for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) {
if (globalConfig.get(configIndex).get("name") if (globalConfig.get(configIndex).get("name").equals(otherConfigName)) {
.equals(otherConfigName)) { String configId = globalConfig.get(configIndex).get("id").toString();
String configId = globalConfig.get(configIndex).get("id") Integer updateConfigId = this.globalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec,
.toString(); this.responseSpec, configId, newValue);
Integer updateConfigId = this.globalConfigurationHelper
.updateValueForGlobalConfiguration(this.requestSpec,
this.responseSpec, configId, newValue);
Assertions.assertNotNull(updateConfigId); Assertions.assertNotNull(updateConfigId);
break; break;
} }
@@ -74,7 +74,7 @@ public class GroupLoanIntegrationTest {
final Integer loanProductID = createLoanProduct(); final Integer loanProductID = createLoanProduct();
final Integer loanID = applyForLoanApplication(groupID, loanProductID); final Integer loanID = applyForLoanApplication(groupID, loanProductID);
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
loanID); loanID);
verifyLoanRepaymentSchedule(loanSchedule); verifyLoanRepaymentSchedule(loanSchedule);
} }
@@ -86,20 +86,20 @@ public class GroupLoanIntegrationTest {
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString()); groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
final Integer loanProductID = createLoanProduct(); 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); LOG.info("Glim Loan Application: {} ", glim);
final Integer glimId=glim.get("glimId"); final Integer glimId = glim.get("glimId");
LOG.info("GlimId : {} ", glimId); LOG.info("GlimId : {} ", glimId);
final Integer loanId=glim.get("loanId"); final Integer loanId = glim.get("loanId");
LOG.info("LoanId : {} ", loanId); LOG.info("LoanId : {} ", loanId);
List<Map<String, Object>> approvalFormData = new ArrayList<>(); 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, HashMap loanStatusHashMap = this.loanTransactionHelper.approveGlimAccount(this.requestSpec, this.responseSpec, approvalFormData,
approvalFormData, glimId); glimId);
LOG.info("glim approval loanSchedule: {} ", loanStatusHashMap); LOG.info("glim approval loanSchedule: {} ", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
@@ -115,7 +115,7 @@ public class GroupLoanIntegrationTest {
LOG.info("glim undoApproval loanSchedule: {} ", loanStatusHashMap); LOG.info("glim undoApproval loanSchedule: {} ", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsPending(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); LOG.info("glim reject loanSchedule: {} ", loanStatusHashMap);
LoanStatusChecker.verifyLoanAccountRejected(loanStatusHashMap); LoanStatusChecker.verifyLoanAccountRejected(loanStatusHashMap);
} }
@@ -136,16 +136,16 @@ public class GroupLoanIntegrationTest {
final Integer loanProductID = createLoanProduct(); final Integer loanProductID = createLoanProduct();
Assertions.assertNotNull(loanProductID); 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); LOG.info("Glim Loan Application: {} ", glim);
final Integer glimId=glim.get("glimId"); final Integer glimId = glim.get("glimId");
LOG.info("GlimId: {} ", glimId); LOG.info("GlimId: {} ", glimId);
final Integer loanId=glim.get("loanId"); final Integer loanId = glim.get("loanId");
LOG.info("LoanId: {} ", 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()); Assertions.assertNotNull(retrievedGlimId.toString());
} }
@@ -165,16 +165,17 @@ public class GroupLoanIntegrationTest {
final Integer loanProductID = createLoanProduct(); final Integer loanProductID = createLoanProduct();
Assertions.assertNotNull(loanProductID); 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); LOG.info("Glim Loan Application: {} ", glim);
final Integer glimId=glim.get("glimId"); final Integer glimId = glim.get("glimId");
LOG.info("GlimId: {} ", glimId); LOG.info("GlimId: {} ", glimId);
final Integer loanId=glim.get("loanId"); final Integer loanId = glim.get("loanId");
LOG.info("LoanId: {} ", 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); Assertions.assertNotNull(retrievedGlimAccountId);
} }
@@ -222,7 +223,7 @@ public class GroupLoanIntegrationTest {
return this.loanTransactionHelper.getLoanId(loanApplicationJSON); 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--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String GlimApplicationJSON = new LoanApplicationTestBuilder() // final String GlimApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
@@ -236,10 +237,8 @@ public class GroupLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() // .withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() // .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
.withExpectedDisbursementDate("20 September 2011") // .withExpectedDisbursementDate("20 September 2011") //
.withSubmittedOnDate("20 September 2011") .withSubmittedOnDate("20 September 2011").withLoanType("glim").withtotalLoan("10000").withParentAccount("1")
.withLoanType("glim") .build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
.withtotalLoan("10000")
.withParentAccount("1").build(clientID.toString(), groupID.toString(), loanProductID.toString(), null);
LOG.info(GlimApplicationJSON); LOG.info(GlimApplicationJSON);
return this.loanTransactionHelper.getGlimId(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"), assertEquals(new ArrayList<>(Arrays.asList(2011, 10, 20)), loanSchedule.get(1).get("dueDate"),
"Checking for Due Date for 1st Month"); "Checking for Due Date for 1st Month");
assertEquals(Float.valueOf("2911.49"), loanSchedule.get(1).get("principalOriginalDue"), assertEquals(Float.valueOf("2911.49"), loanSchedule.get(1).get("principalOriginalDue"), "Checking for Principal Due for 1st Month");
"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("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"), assertEquals(new ArrayList<>(Arrays.asList(2011, 11, 20)), loanSchedule.get(2).get("dueDate"),
"Checking for Due Date for 2nd Month"); "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(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"), 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("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"); 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(); Calendar todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false"; String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField( ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE); .closeSavingsAccountAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
withdrawBalance = "true"; withdrawBalance = "true";
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId, withdrawBalance); savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId, withdrawBalance);
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap); SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
} }
@@ -221,7 +221,7 @@ public class GroupSavingsIntegrationTest {
} }
//gsimcommands testing // gsimcommands testing
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testGsimSavingsAccount_REJECT_APPLICATION() { public void testGsimSavingsAccount_REJECT_APPLICATION() {
@@ -248,7 +248,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>(); 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 Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
@@ -267,7 +267,8 @@ public class GroupSavingsIntegrationTest {
assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date", assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); 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", assertEquals("validation.msg.savingsaccount.reject.cannot.be.before.submittal.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -276,7 +277,7 @@ public class GroupSavingsIntegrationTest {
} }
@Test @Test
public void testGsimSavingsAccount_DEPOSIT_APPLICATION() { public void testGsimSavingsAccount_DEPOSIT_APPLICATION() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -298,7 +299,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>(); 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); LOG.info("client Array : {} ", clientArray);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP); final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
@@ -313,7 +314,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(paymentTypeId); Assertions.assertNotNull(paymentTypeId);
List<Map<String, Object>> savingsArray = new ArrayList<>(); List<Map<String, Object>> savingsArray = new ArrayList<>();
final Integer transactionAmount=2500; final Integer transactionAmount = 2500;
savingsArray.add(savingsArray(paymentTypeId, savingsId, transactionAmount, "10 March 2013")); savingsArray.add(savingsArray(paymentTypeId, savingsId, transactionAmount, "10 March 2013"));
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId); HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
@@ -328,7 +329,7 @@ public class GroupSavingsIntegrationTest {
final Integer depositId = this.savingsAccountHelper.depositGsimApplication(savingsId, savingsArray); final Integer depositId = this.savingsAccountHelper.depositGsimApplication(savingsId, savingsArray);
Assertions.assertNotNull(depositId); Assertions.assertNotNull(depositId);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
@@ -354,7 +355,7 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>(); 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 Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
@@ -368,12 +369,13 @@ public class GroupSavingsIntegrationTest {
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
String withdrawBalance = "false"; 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", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
withdrawBalance = "true"; withdrawBalance = "true";
savingsStatusHashMap = this.savingsAccountHelper.closeGsimSavingsAccount(gsimID, withdrawBalance); savingsStatusHashMap = this.savingsAccountHelper.closeGsimSavingsAccount(gsimID, withdrawBalance);
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap); SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
} }
@@ -401,12 +403,12 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>(); 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 Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
HashMap savingsStatusHashMap = this.savingsAccountHelper.updateGsimApplication(gsimID, clientID, groupID, savingsProductID); HashMap savingsStatusHashMap = this.savingsAccountHelper.updateGsimApplication(gsimID, clientID, groupID, savingsProductID);
LOG.info("savingsStatusHashMap: {} ",savingsStatusHashMap); LOG.info("savingsStatusHashMap: {} ", savingsStatusHashMap);
Assertions.assertTrue(savingsStatusHashMap.containsKey("savingsId")); Assertions.assertTrue(savingsStatusHashMap.containsKey("savingsId"));
} }
@@ -434,12 +436,12 @@ public class GroupSavingsIntegrationTest {
Assertions.assertNotNull(savingsProductID); Assertions.assertNotNull(savingsProductID);
List<Map<String, Object>> clientArray = new ArrayList<>(); 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 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()); Assertions.assertNotNull(retrievedGsimId.toString());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
@@ -727,7 +729,8 @@ public class GroupSavingsIntegrationTest {
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount); totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived")); assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsWeeklyFeeJSON()); final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getSavingsWeeklyFeeJSON());
Assertions.assertNotNull(weeklyFeeId); Assertions.assertNotNull(weeklyFeeId);
this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId, true); this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId, true);
@@ -777,7 +780,8 @@ public class GroupSavingsIntegrationTest {
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); 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<String, Object> map = new HashMap<>();
map.put("clientId", clientId); map.put("clientId", clientId);
map.put("groupId", groupId); map.put("groupId", groupId);
@@ -790,12 +794,13 @@ public class GroupSavingsIntegrationTest {
return map; 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<String, Object> map = new HashMap<>();
map.put("transactionDate", transactionDate); map.put("transactionDate", transactionDate);
map.put("dateFormat", CommonConstants.DATE_FORMAT); map.put("dateFormat", CommonConstants.DATE_FORMAT);
map.put("locale", "en"); map.put("locale", "en");
map.put("transactionAmount",transactionAmount); map.put("transactionAmount", transactionAmount);
map.put("paymentTypeId", paymentId); map.put("paymentTypeId", paymentId);
map.put("childAccountId", savingsId); map.put("childAccountId", savingsId);
return map; return map;
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
* Updating & Deletion * Updating & Deletion
*/ */
public class GroupTest { public class GroupTest {
private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class); private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -109,11 +110,11 @@ public class GroupTest {
// create staff // create staff
Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec); 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); Assertions.assertNotNull(createStaffId1);
Integer createStaffId2 = StaffHelper.createStaff(this.requestSpec, this.responseSpec); 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); Assertions.assertNotNull(createStaffId2);
// assign staff "createStaffId1" to group // assign staff "createStaffId1" to group
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class HookIntegrationTest { public class HookIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(HookIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(HookIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -78,8 +79,8 @@ public class HookIntegrationTest {
final String json = RestAssured.get(payloadURL.replace("?", "")).asString(); final String json = RestAssured.get(payloadURL.replace("?", "")).asString();
final Integer notificationOfficeId = JsonPath.with(json).get("officeId"); final Integer notificationOfficeId = JsonPath.with(json).get("officeId");
Assertions.assertEquals(createdOfficeID, notificationOfficeId, Assertions.assertEquals(createdOfficeID, notificationOfficeId,
"Equality check for created officeId and hook received payload officeId"); "Equality check for created officeId and hook received payload officeId");
LOG.info("Notification Office Id - {}" , notificationOfficeId); LOG.info("Notification Office Id - {}", notificationOfficeId);
i = 6; i = 6;
} catch (Exception e) { } catch (Exception e) {
TimeUnit.SECONDS.sleep(3); TimeUnit.SECONDS.sleep(3);
@@ -97,20 +98,20 @@ public class HookIntegrationTest {
} }
@Test @Test
public void createUpdateAndDeleteHook(){ public void createUpdateAndDeleteHook() {
final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?"; final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?";
final String updateURL = "http://localhost"; final String updateURL = "http://localhost";
Long hookId = this.hookHelper.createHook(payloadURL).longValue(); Long hookId = this.hookHelper.createHook(payloadURL).longValue();
Assertions.assertNotNull(hookId); Assertions.assertNotNull(hookId);
this.hookHelper.verifyHookCreatedOnServer(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.updateHook(updateURL, hookId);
this.hookHelper.verifyUpdateHook(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.deleteHook(hookId);
this.hookHelper.verifyDeleteHook(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") @SuppressWarnings("rawtypes")
public class LoanApplicationApprovalTest { public class LoanApplicationApprovalTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403; private ResponseSpecification responseSpecForStatusCode403;
@@ -130,14 +131,13 @@ public class LoanApplicationApprovalTest {
createTranches.add(createTrancheDetail("23 March 2014", "4000")); createTranches.add(createTrancheDetail("23 March 2014", "4000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches); this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches); this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
@@ -155,8 +155,7 @@ public class LoanApplicationApprovalTest {
approveTranches.add(createTrancheDetail("23 March 2014", "1000")); approveTranches.add(createTrancheDetail("23 March 2014", "1000"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -201,8 +200,7 @@ public class LoanApplicationApprovalTest {
approveTranche4.add(createTrancheDetail("24 March 2014", "100")); approveTranche4.add(createTrancheDetail("24 March 2014", "100"));
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -233,8 +231,8 @@ public class LoanApplicationApprovalTest {
/* No. of tranches exceeds the max tranche count at product level */ /* No. of tranches exceeds the max tranche count at product level */
error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount3, loanID, error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount3, loanID,
approveTranche3, CommonConstants.RESPONSE_ERROR); approveTranche3, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.disbursementData.exceeding.max.tranche.count", error.get(0) assertEquals("error.msg.disbursementData.exceeding.max.tranche.count",
.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
/* If tranches are not specified for a multi-disburse loan */ /* If tranches are not specified for a multi-disburse loan */
/** /**
@@ -259,7 +257,7 @@ public class LoanApplicationApprovalTest {
List<HashMap> tranches) { List<HashMap> tranches) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(principal) .withPrincipal(principal)
// //
.withLoanTermFrequency("5") .withLoanTermFrequency("5")
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanApplicationUndoLastTrancheTest { public class LoanApplicationUndoLastTrancheTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -67,15 +68,14 @@ public class LoanApplicationUndoLastTrancheTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT // CREATE LOAN MULTIDISBURSAL PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
// CREATE TRANCHES // CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>(); List<HashMap> createTranches = new ArrayList<>();
@@ -89,8 +89,7 @@ public class LoanApplicationUndoLastTrancheTest {
// APPLY FOR LOAN WITH TRANCHES // APPLY FOR LOAN WITH TRANCHES
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
@@ -133,7 +132,7 @@ public class LoanApplicationUndoLastTrancheTest {
List<HashMap> tranches) { List<HashMap> tranches) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(principal) .withPrincipal(principal)
// //
.withLoanTermFrequency("5") .withLoanTermFrequency("5")
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanDisbursalDateValidationTest { public class LoanDisbursalDateValidationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -65,19 +66,17 @@ public class LoanDisbursalDateValidationTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
// CREATE LOAN PRODUCT // CREATE LOAN PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withSyncExpectedWithDisbursementDate(true).build(null)); .getLoanProductId(new LoanProductTestBuilder().withSyncExpectedWithDisbursementDate(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
// APPLY FOR LOAN // APPLY FOR LOAN
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN STATUS // VALIDATE THE LOAN STATUS
@@ -92,7 +91,8 @@ public class LoanDisbursalDateValidationTest {
// DISBURSE A LOAN // DISBURSE A LOAN
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID, this.responseForbiddenError); List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID,
this.responseForbiddenError);
Assertions.assertEquals(disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), Assertions.assertEquals(disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
"error.msg.actual.disbursement.date.does.not.match.with.expected.disbursal.date"); "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) { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) {
final String loanApplication = new LoanApplicationTestBuilder() final String loanApplication = new LoanApplicationTestBuilder().withPrincipal(proposedAmount).withLoanTermFrequency("5")
.withPrincipal(proposedAmount).withLoanTermFrequency("5") .withLoanTermFrequencyAsMonths().withNumberOfRepayments("5").withRepaymentEveryAfter("1")
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5") .withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("1 March 2014")
.withRepaymentEveryAfter("1") .withSubmittedOnDate("26 February 2014").build(clientID.toString(), loanProductID.toString(), null);
.withRepaymentFrequencyTypeAsMonths()
.withInterestRatePerPeriod("2")
.withExpectedDisbursementDate("1 March 2014")
.withSubmittedOnDate("26 February 2014").
build(clientID.toString(), loanProductID.toString(), null);
return this.loanTransactionHelper.getLoanId(loanApplication); return this.loanTransactionHelper.getLoanId(loanApplication);
} }
} }
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class LoanDisbursementDetailsIntegrationTest { public class LoanDisbursementDetailsIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursementDetailsIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursementDetailsIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -75,20 +76,19 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000")); createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------{}" LOG.info("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------{}", clientID);
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
.withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true) .withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches, final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
installmentAmount); installmentAmount);
LOG.info("-----------------------------------LOAN CREATED WITH EMI LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH EMI LOANID------------------------------------------------- {}",
, loanIDWithEmi); loanIDWithEmi);
HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec,
loanIDWithEmi, "repaymentSchedule"); loanIDWithEmi, "repaymentSchedule");
@@ -106,7 +106,8 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches); createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(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, final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
withoutInstallmentAmount); withoutInstallmentAmount);
@@ -117,8 +118,8 @@ public class LoanDisbursementDetailsIntegrationTest {
ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods"); ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi.get("periods");
assertEquals(15, periods1.size()); assertEquals(15, periods1.size());
LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}",
, loanIDWithoutEmi); loanIDWithoutEmi);
/* To be uncommented once issue MIFOSX-2006 is closed. */ /* To be uncommented once issue MIFOSX-2006 is closed. */
// this.validateRepaymentScheduleWithoutEMI(periods1); // this.validateRepaymentScheduleWithoutEMI(periods1);
@@ -131,7 +132,8 @@ public class LoanDisbursementDetailsIntegrationTest {
loanIDWithoutEmi, createTranches); loanIDWithoutEmi, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(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("dueDate").toString(), expectedRepaymentSchedule.getDueDate());
assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding()); assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding());
LOG.info("{}",period.get("totalOriginalDueForPeriod").toString()); LOG.info("{}", period.get("totalOriginalDueForPeriod").toString());
assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()), expectedRepaymentSchedule assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()),
.getTotalOriginalDueForPeriod().floatValue(), 0.0f); expectedRepaymentSchedule.getTotalOriginalDueForPeriod().floatValue(), 0.0f);
assertEquals(Float.valueOf(period.get("totalOutstandingForPeriod").toString()).floatValue(), assertEquals(Float.valueOf(period.get("totalOutstandingForPeriod").toString()).floatValue(),
expectedRepaymentSchedule.getTotalOutstandingForPeriod(), 0.0f); expectedRepaymentSchedule.getTotalOutstandingForPeriod(), 0.0f);
@@ -220,7 +222,8 @@ public class LoanDisbursementDetailsIntegrationTest {
expectedRepaymentSchedule.getInterestOutstanding(), 0.0f); expectedRepaymentSchedule.getInterestOutstanding(), 0.0f);
assertEquals(Float.valueOf(period.get("principalOutstanding").toString()).floatValue(), assertEquals(Float.valueOf(period.get("principalOutstanding").toString()).floatValue(),
expectedRepaymentSchedule.getPrincipalOutstanding(), 0.0f); 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(), assertEquals(Float.valueOf(period.get("principalOriginalDue").toString()).floatValue(),
expectedRepaymentSchedule.getPrincipalOriginalDue(), 0.0f); expectedRepaymentSchedule.getPrincipalOriginalDue(), 0.0f);
assertEquals(period.get("fromDate").toString(), expectedRepaymentSchedule.getFromDate()); assertEquals(period.get("fromDate").toString(), expectedRepaymentSchedule.getFromDate());
@@ -342,7 +345,7 @@ public class LoanDisbursementDetailsIntegrationTest {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(proposedAmount) .withPrincipal(proposedAmount)
// //
.withLoanTermFrequency("12") .withLoanTermFrequency("12")
@@ -364,25 +367,23 @@ public class LoanDisbursementDetailsIntegrationTest {
} }
@Test @Test
public void createApproveAndValidateMultiDisburseLoan() throws ParseException{ public void createApproveAndValidateMultiDisburseLoan() throws ParseException {
List<HashMap> createTranches = new ArrayList<>(); List<HashMap> createTranches = new ArrayList<>();
String id = null; String id = null;
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000")); createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000"));
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() final Integer loanProductID = this.loanTransactionHelper
.withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.build(null)); .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
, loanProductID); loanProductID);
this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}", loanID);
, loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -423,7 +424,7 @@ public class LoanDisbursementDetailsIntegrationTest {
addTranches, ""); addTranches, "");
} }
private void deleteDisbursmentDetails() throws ParseException{ private void deleteDisbursmentDetails() throws ParseException {
List<HashMap> deleteTranches = new ArrayList<>(); List<HashMap> deleteTranches = new ArrayList<>();
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper.getLoanDetail(this.requestSpec, ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper.getLoanDetail(this.requestSpec,
this.responseSpec, this.loanID, "disbursementDetails"); this.responseSpec, this.loanID, "disbursementDetails");
@@ -440,7 +441,7 @@ public class LoanDisbursementDetailsIntegrationTest {
deleteTranches, ""); deleteTranches, "");
} }
private void editDateAndPrincipalOfExistingTranche() throws ParseException{ private void editDateAndPrincipalOfExistingTranche() throws ParseException {
String updatedExpectedDisbursementDate = "01 March 2014"; String updatedExpectedDisbursementDate = "01 March 2014";
String updatedPrincipal = "900"; String updatedPrincipal = "900";
/* Update */ /* Update */
@@ -469,7 +470,7 @@ public class LoanDisbursementDetailsIntegrationTest {
List<HashMap> tranches) { List<HashMap> tranches) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder()
// //
.withPrincipal(principal) .withPrincipal(principal)
// //
.withLoanTermFrequency("5") .withLoanTermFrequency("5")
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class LoanRepaymentRescheduleAtDisbursementTest { public class LoanRepaymentRescheduleAtDisbursementTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -65,7 +66,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testLoanRepaymentRescheduleAtDisbursement(){ public void testLoanRepaymentRescheduleAtDisbursement() {
final String approvalAmount = "10000"; final String approvalAmount = "10000";
final String approveDate = "01 March 2015"; final String approveDate = "01 March 2015";
@@ -75,8 +76,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
// CREATE CLIENT // CREATE CLIENT
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
, clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION // CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION
final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY, final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY,
@@ -116,8 +116,9 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
this.loanTransactionHelper.disburseLoanWithRepaymentReschedule(disbursementDate, loanID, adjustRepaymentDate); this.loanTransactionHelper.disburseLoanWithRepaymentReschedule(disbursementDate, loanID, adjustRepaymentDate);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, loanID); ArrayList<HashMap> loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec,
HashMap firstInstallement = loanRepaymnetSchedule.get(1); loanID);
HashMap firstInstallement = loanRepaymnetSchedule.get(1);
Map<String, Object> expectedvalues = new HashMap<>(3); Map<String, Object> expectedvalues = new HashMap<>(3);
Calendar date = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar date = Calendar.getInstance(Utils.getTimeZoneOfTenant());
date.set(2015, Calendar.MARCH, 16); date.set(2015, Calendar.MARCH, 16);
@@ -170,17 +171,10 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType,
final Integer recalculationRestFrequencyDayOfWeekType) { final Integer recalculationRestFrequencyDayOfWeekType) {
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("12")
.withPrincipal("10000.00") .withRepaymentAfterEvery("2").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withNumberOfRepayments("12") .withInterestRateFrequencyTypeAsMonths().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentAfterEvery("2") .withRepaymentStrategy(repaymentStrategy).withInterestTypeAsDecliningBalance()
.withRepaymentTypeAsWeek()
.withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths()
.withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentStrategy(repaymentStrategy)
.withInterestTypeAsDecliningBalance()
.withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod, .withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod,
preCloseInterestCalculationStrategy) preCloseInterestCalculationStrategy)
.withInterestRecalculationRestFrequencyDetails(recalculationRestFrequencyType, recalculationRestFrequencyInterval, .withInterestRecalculationRestFrequencyDetails(recalculationRestFrequencyType, recalculationRestFrequencyInterval,
@@ -193,7 +187,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
} }
if (isArrearsBasedOnOriginalSchedule) { if (isArrearsBasedOnOriginalSchedule) {
builder = builder.withArrearsConfiguration(); builder = builder.withArrearsConfiguration();
} }
final String loanProductJSON = builder.build(chargeId); final String loanProductJSON = builder.build(chargeId);
@@ -221,8 +215,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
.withRepaymentFrequencyTypeAsWeeks() // .withRepaymentFrequencyTypeAsWeeks() //
.withInterestRatePerPeriod("2") // .withInterestRatePerPeriod("2") //
.withAmortizationTypeAsEqualInstallments() // .withAmortizationTypeAsEqualInstallments() //
.withTranches(tranches) .withTranches(tranches).withFixedEmiAmount("") //
.withFixedEmiAmount("") //
.withInterestTypeAsDecliningBalance() // .withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeAsDays() // .withInterestCalculationPeriodTypeAsDays() //
.withInterestCalculationPeriodTypeAsDays() // .withInterestCalculationPeriodTypeAsDays() //
@@ -240,7 +233,6 @@ public class LoanRepaymentRescheduleAtDisbursementTest {
private List getDateAsArray(Calendar date, int addvalue, int type) { private List getDateAsArray(Calendar date, int addvalue, int type) {
date.add(type, addvalue); date.add(type, addvalue);
return new ArrayList<>(Arrays.asList(date.get(Calendar.YEAR), date.get(Calendar.MONTH) + 1, return new ArrayList<>(Arrays.asList(date.get(Calendar.YEAR), date.get(Calendar.MONTH) + 1, date.get(Calendar.DAY_OF_MONTH)));
date.get(Calendar.DAY_OF_MONTH)));
} }
} }
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
**/ **/
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public class LoanRescheduleRequestTest { public class LoanRescheduleRequestTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
@@ -98,15 +99,12 @@ public class LoanRescheduleRequestTest {
private void createLoanProductEntity() { private void createLoanProductEntity() {
LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
.withPrincipal(loanPrincipalAmount) .withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
.withNumberOfRepayments(numberOfRepayments) .withInterestRateFrequencyTypeAsYear().build(null);
.withinterestRatePerPeriod(interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear()
.build(null);
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); 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() { private void createLoanEntity() {
LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------"); LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
.withPrincipal(loanPrincipalAmount) .withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsMonths().withNumberOfRepayments(numberOfRepayments)
.withLoanTermFrequency(numberOfRepayments) .withRepaymentEveryAfter("1").withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments()
.withLoanTermFrequencyAsMonths() .withInterestCalculationPeriodTypeAsDays().withInterestRatePerPeriod(interestRatePerPeriod).withLoanTermFrequencyAsMonths()
.withNumberOfRepayments(numberOfRepayments) .withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2")
.withRepaymentEveryAfter("1")
.withRepaymentFrequencyTypeAsMonths()
.withAmortizationTypeAsEqualInstallments()
.withInterestCalculationPeriodTypeAsDays()
.withInterestRatePerPeriod(interestRatePerPeriod)
.withLoanTermFrequencyAsMonths()
.withSubmittedOnDate(dateString)
.withExpectedDisbursementDate(dateString)
.withPrincipalGrace("2")
.withInterestGrace("2")
.build(this.clientId.toString(), this.loanProductId.toString(), null); .build(this.clientId.toString(), this.loanProductId.toString(), null);
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
LOG.info("Sucessfully created loan (ID: {} )" , this.loanId); LOG.info("Sucessfully created loan (ID: {} )", this.loanId);
this.approveLoanApplication(); this.approveLoanApplication();
this.disburseLoan(); this.disburseLoan();
@@ -145,9 +133,9 @@ public class LoanRescheduleRequestTest {
**/ **/
private void approveLoanApplication() { private void approveLoanApplication() {
if(this.loanId != null) { if (this.loanId != null) {
this.loanTransactionHelper.approveLoan(this.dateString, this.loanId); this.loanTransactionHelper.approveLoan(this.dateString, this.loanId);
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() { private void disburseLoan() {
if(this.loanId != null) { if (this.loanId != null) {
this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId); this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId);
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.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId); 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 @Test
@@ -191,9 +179,9 @@ public class LoanRescheduleRequestTest {
this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean)response.get("rejected")); assertTrue((Boolean) response.get("rejected"));
LOG.info("Successfully rejected loan reschedule request (ID: {} )" , this.loanRescheduleRequestId); LOG.info("Successfully rejected loan reschedule request (ID: {} )", this.loanRescheduleRequestId);
} }
@Test @Test
@@ -206,15 +194,16 @@ public class LoanRescheduleRequestTest {
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
assertTrue((Boolean)response.get("approved")); assertTrue((Boolean) response.get("approved"));
final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId, "numberOfRepayments"); final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId,
"numberOfRepayments");
final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId); final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId);
final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment"); final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment");
assertEquals(12, numberOfRepayments, "NUMBER OF REPAYMENTS is NOK"); assertEquals(12, numberOfRepayments, "NUMBER OF REPAYMENTS is NOK");
assertEquals(118000, totalExpectedRepayment, "TOTAL EXPECTED REPAYMENT 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; package org.apache.fineract.integrationtests;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.Gson; import com.google.gson.Gson;
@@ -56,6 +55,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class LoanReschedulingWithinCenterTest { public class LoanReschedulingWithinCenterTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -114,8 +114,7 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, null, null);
null, null);
// APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION // APPLY FOR TRANCHE LOAN WITH INTEREST RECALCULATION
final Integer loanId = applyForLoanApplicationForInterestRecalculation(clientId, groupId, calendarId, loanProductID, disbursalDate, final Integer loanId = applyForLoanApplicationForInterestRecalculation(clientId, groupId, calendarId, loanProductID, disbursalDate,
@@ -177,13 +176,13 @@ public class LoanReschedulingWithinCenterTest {
final String interval = "2"; // Every one week final String interval = "2"; // Every one week
Integer repeatsOnDay = today.get(Calendar.DAY_OF_WEEK) - 1; Integer repeatsOnDay = today.get(Calendar.DAY_OF_WEEK) - 1;
if (repeatsOnDay.intValue() == 0){ if (repeatsOnDay.intValue() == 0) {
repeatsOnDay = 7; repeatsOnDay = 7;
} }
Integer calendarId = CalendarHelper.createMeetingForGroup(this.requestSpec, this.responseSpec, centerId, startDate, frequency, Integer calendarId = CalendarHelper.createMeetingForGroup(this.requestSpec, this.responseSpec, centerId, startDate, frequency,
interval, repeatsOnDay.toString()); interval, repeatsOnDay.toString());
LOG.info("calendarId {}" , calendarId); LOG.info("calendarId {}", calendarId);
return calendarId; return calendarId;
} }
@@ -229,12 +228,11 @@ public class LoanReschedulingWithinCenterTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "0", recalculationRestFrequencyDate,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, isMultiTrancheLoan, null, null);
null, null);
Calendar seondTrancheDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar seondTrancheDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
seondTrancheDate.add(Calendar.MONTH, 1); seondTrancheDate.add(Calendar.MONTH, 1);
String secondDisbursement = dateFormat.format(seondTrancheDate.getTime()) ; String secondDisbursement = dateFormat.format(seondTrancheDate.getTime());
// CREATE TRANCHES // CREATE TRANCHES
List<HashMap> createTranches = new ArrayList<>(); List<HashMap> createTranches = new ArrayList<>();
@@ -290,7 +288,8 @@ public class LoanReschedulingWithinCenterTest {
final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod, final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod,
final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval, final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval,
final String recalculationRestFrequencyDate, final String preCloseInterestCalculationStrategy, final Account[] accounts, 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 recalculationCompoundingFrequencyType = null;
final String recalculationCompoundingFrequencyInterval = null; final String recalculationCompoundingFrequencyInterval = null;
final String recalculationCompoundingFrequencyDate = null; final String recalculationCompoundingFrequencyDate = null;
@@ -300,8 +299,8 @@ public class LoanReschedulingWithinCenterTest {
rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval, rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval,
recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval, recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval,
recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, isMultiTrancheLoan, recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, isMultiTrancheLoan,
recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, recalculationRestFrequencyOnDayType, recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType,
recalculationRestFrequencyDayOfWeekType); recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType);
} }
private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy, private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy,
@@ -311,20 +310,13 @@ public class LoanReschedulingWithinCenterTest {
final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate, final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate,
final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId, final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId,
boolean isArrearsBasedOnOriginalSchedule, final boolean isMultiTrancheLoan, boolean isArrearsBasedOnOriginalSchedule, final boolean isMultiTrancheLoan,
final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType,
final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) {
final Integer recalculationRestFrequencyDayOfWeekType) {
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
LoanProductTestBuilder builder = new LoanProductTestBuilder() LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("12")
.withPrincipal("10000.00") .withRepaymentAfterEvery("2").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
.withNumberOfRepayments("12") .withInterestRateFrequencyTypeAsMonths().withTranches(isMultiTrancheLoan)
.withRepaymentAfterEvery("2") .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).withRepaymentStrategy(repaymentStrategy)
.withRepaymentTypeAsWeek()
.withinterestRatePerPeriod("2")
.withInterestRateFrequencyTypeAsMonths()
.withTranches(isMultiTrancheLoan)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withRepaymentStrategy(repaymentStrategy)
.withInterestTypeAsDecliningBalance() .withInterestTypeAsDecliningBalance()
.withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod, .withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod,
preCloseInterestCalculationStrategy) preCloseInterestCalculationStrategy)
@@ -395,8 +387,8 @@ public class LoanReschedulingWithinCenterTest {
map.put("active", "true"); map.put("active", "true");
map.put("activationDate", "04 March 2011"); map.put("activationDate", "04 March 2011");
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec, "/fineract-provider/api/v1/groups?" groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec,
+ Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId"); "/fineract-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
} }
return groupMembers; return groupMembers;
} }
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
*/ */
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public class LoanWithWaiveInterestAndWriteOffIntegrationTest { public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -101,7 +102,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DISBURSE // DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
LOG.info("DISBURSE {}" , loanStatusHashMap.toString()); LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// PERFORM REPAYMENTS AND CHECK LOAN STATUS // PERFORM REPAYMENTS AND CHECK LOAN STATUS
@@ -114,7 +115,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DIBURSE AGAIN // DIBURSE AGAIN
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
LOG.info("DISBURSE {}" , loanStatusHashMap); LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS // MAKE REPAYMENTS
@@ -160,7 +161,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DISBURSE // DISBURSE
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
LOG.info("DISBURSE {}" , loanStatusHashMap); LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// MAKE REPAYMENTS // MAKE REPAYMENTS
@@ -174,17 +175,21 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
"Checking for Principal paid "); "Checking for Principal paid ");
Assertions.assertTrue(Float.valueOf("180.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestPaid")))) == 0, Assertions.assertTrue(Float.valueOf("180.0").compareTo(Float.valueOf(String.valueOf(toLoanSummaryAfter.get("interestPaid")))) == 0,
"Checking for interestPaid paid "); "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 "); "Checking for total paid ");
// WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED // WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED
LoanStatusChecker.verifyLoanAccountIsClosed(this.loanTransactionHelper.writeOffLoan("1 January 2011", loanID)); LoanStatusChecker.verifyLoanAccountIsClosed(this.loanTransactionHelper.writeOffLoan("1 January 2011", loanID));
toLoanSummaryAfter = this.loanTransactionHelper.getLoanSummary(requestSpec, responseSpec, 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 "); "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 "); "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 "); "Checking for total written off ");
} }
@@ -215,4 +215,4 @@ public class MinimumDaysBetweenDisbursalAndFirstRepaymentTest {
public void setGroupCalendarId(Integer groupCalendarId) { public void setGroupCalendarId(Integer groupCalendarId) {
this.groupCalendarId = groupCalendarId; this.groupCalendarId = groupCalendarId;
} }
} }
@@ -33,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class NotificationApiTest { public class NotificationApiTest {
private final static Logger LOG = LoggerFactory.getLogger(NotificationApiTest.class); private final static Logger LOG = LoggerFactory.getLogger(NotificationApiTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -50,7 +51,7 @@ public class NotificationApiTest {
public void testNotificationRetrieval() { public void testNotificationRetrieval() {
HashMap<String, Object> response = (HashMap<String, Object>) NotificationHelper.getNotifications(this.requestSpec, HashMap<String, Object> response = (HashMap<String, Object>) NotificationHelper.getNotifications(this.requestSpec,
this.responseSpec, ""); this.responseSpec, "");
LOG.info("Response : {}" , response.toString()); LOG.info("Response : {}", response.toString());
Assertions.assertNotNull(response); Assertions.assertNotNull(response);
} }
} }
@@ -38,14 +38,9 @@ public class OfficeIntegrationTest {
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType( this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
ContentType.JSON).build(); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
.header("Authorization",
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@Test @Test
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class PasswordPreferencesIntegrationTest { public class PasswordPreferencesIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(PasswordPreferencesIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(PasswordPreferencesIntegrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -59,7 +60,7 @@ public class PasswordPreferencesIntegrationTest {
this.validateIfThePasswordIsUpdated(validationPolicyId); this.validateIfThePasswordIsUpdated(validationPolicyId);
} }
private void validateIfThePasswordIsUpdated(String validationPolicyId){ private void validateIfThePasswordIsUpdated(String validationPolicyId) {
Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec); Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec);
assertEquals(validationPolicyId, id.toString()); assertEquals(validationPolicyId, id.toString());
LOG.info("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------"); LOG.info("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------");
@@ -69,8 +70,8 @@ public class PasswordPreferencesIntegrationTest {
@Test @Test
public void updateWithInvalidPolicyId() { public void updateWithInvalidPolicyId() {
String invalidValidationPolicyId = "2000"; String invalidValidationPolicyId = "2000";
final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec, invalidValidationPolicyId, final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec,
CommonConstants.RESPONSE_ERROR); invalidValidationPolicyId, CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.password.validation.policy.id.invalid", error.get(0).get("userMessageGlobalisationCode"), assertEquals("error.msg.password.validation.policy.id.invalid", error.get(0).get("userMessageGlobalisationCode"),
"Password Validation Policy with identifier 2000 does not exist"); "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.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@SuppressWarnings({"rawtypes"}) @SuppressWarnings({ "rawtypes" })
public class RatesTest { public class RatesTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); }
}
@Test @Test
public void testRatesForLoans() { public void testRatesForLoans() {
// Retrieving all Rates // Retrieving all Rates
ArrayList<HashMap> allRatesData = RatesHelper.getRates(this.requestSpec, this.responseSpec); ArrayList<HashMap> allRatesData = RatesHelper.getRates(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(allRatesData); Assertions.assertNotNull(allRatesData);
// Testing Creation and Update of Loan Rate // Testing Creation and Update of Loan Rate
final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec, final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec, RatesHelper.getLoanRateJSON());
RatesHelper.getLoanRateJSON()); Assertions.assertNotNull(loanRateId);
Assertions.assertNotNull(loanRateId);
//Update Rate percentage // Update Rate percentage
HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId, HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId, RatesHelper.getModifyRateJSON());
RatesHelper.getModifyRateJSON());
HashMap rateDataAfterChanges = RatesHelper HashMap rateDataAfterChanges = RatesHelper.getRateById(this.requestSpec, this.responseSpec, loanRateId);
.getRateById(this.requestSpec, this.responseSpec, loanRateId); Assertions.assertEquals(rateDataAfterChanges.get("percentage"), changes.get("percentage"), "Verifying Rate after modification");
Assertions.assertEquals(rateDataAfterChanges.get("percentage"),
changes.get("percentage"), "Verifying Rate after modification");
}
}
} }
@@ -38,6 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class RolesTest { public class RolesTest {
private final static Logger LOG = LoggerFactory.getLogger(RolesTest.class); private final static Logger LOG = LoggerFactory.getLogger(RolesTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -109,7 +110,7 @@ public class RolesTest {
assertEquals(enableRoleId, roleId); assertEquals(enableRoleId, roleId);
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
assertEquals((Integer) role.get("id"), roleId); assertEquals((Integer) role.get("id"), roleId);
assertEquals(false,(Boolean) role.get("disabled")); assertEquals(false, (Boolean) role.get("disabled"));
} }
@@ -67,12 +67,12 @@ public class SchedulerJobsTest {
@Test // FINERACT-926 @Test // FINERACT-926
public void testDateFormat() { public void testDateFormat() {
// must start scheduler and make job active to have nextRunTime (which is a // must start scheduler and make job active to have nextRunTime (which
// is a
// java.util.Date) // java.util.Date)
schedulerJobHelper.updateSchedulerStatus(true); schedulerJobHelper.updateSchedulerStatus(true);
schedulerJobHelper.updateSchedulerJob(1, true); schedulerJobHelper.updateSchedulerJob(1, true);
String nextRunTimeText = await().until( String nextRunTimeText = await().until(() -> (String) schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"),
() -> (String) schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"),
nextRunTime -> nextRunTime != null); nextRunTime -> nextRunTime != null);
DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText); DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText);
} }
@@ -102,7 +102,8 @@ public class SchedulerJobsTest {
@Test @Test
public void testFlippingJobsActiveStatus() throws InterruptedException { public void testFlippingJobsActiveStatus() throws InterruptedException {
// Stop the Scheduler while we test flapping jobs' active on/off, to avoid side // Stop the Scheduler while we test flapping jobs' active on/off, to
// avoid side
// effects // effects
schedulerJobHelper.updateSchedulerStatus(false); schedulerJobHelper.updateSchedulerStatus(false);
@@ -131,4 +132,4 @@ public class SchedulerJobsTest {
schedulerJobHelper.executeAndAwaitJob(jobName); schedulerJobHelper.executeAndAwaitJob(jobName);
} }
} }
} }
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" }) @SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" })
public class SkipRepaymentOnMonthFirstTest { public class SkipRepaymentOnMonthFirstTest {
private final static Logger LOG = LoggerFactory.getLogger(SkipRepaymentOnMonthFirstTest.class); private final static Logger LOG = LoggerFactory.getLogger(SkipRepaymentOnMonthFirstTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -56,8 +57,7 @@ public class SkipRepaymentOnMonthFirstTest {
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
} }
@@ -72,8 +72,8 @@ public class SkipRepaymentOnMonthFirstTest {
this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
// Retrieving All Global Configuration details // Retrieving All Global Configuration details
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); this.responseSpec);
Assertions.assertNotNull(globalConfig); Assertions.assertNotNull(globalConfig);
String configName = "skip-repayment-on-first-day-of-month"; String configName = "skip-repayment-on-first-day-of-month";
@@ -82,8 +82,8 @@ public class SkipRepaymentOnMonthFirstTest {
for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) { for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) {
if (globalConfig.get(configIndex).get("name").equals(configName)) { if (globalConfig.get(configIndex).get("name").equals(configName)) {
String configId = globalConfig.get(configIndex).get("id").toString(); String configId = globalConfig.get(configIndex).get("id").toString();
Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration( Integer updateConfigId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
this.requestSpec, this.responseSpec, configId.toString(), newBooleanValue); this.responseSpec, configId.toString(), newBooleanValue);
Assertions.assertNotNull(updateConfigId); Assertions.assertNotNull(updateConfigId);
break; break;
} }
@@ -97,26 +97,23 @@ public class SkipRepaymentOnMonthFirstTest {
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true); Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
clientID.toString());
final String startDate = "15 September 2011"; final String startDate = "15 September 2011";
final String frequency = "3"; // Monthly final String frequency = "3"; // Monthly
final String interval = "1"; //Every One Moth final String interval = "1"; // Every One Moth
Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency, Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency, interval, null);
interval, null); LOG.info("caladerId -------------------- {}", calendarID);
LOG.info("caladerId -------------------- {}" , calendarID);
final Integer loanProductID = createLoanProduct(); final Integer loanProductID = createLoanProduct();
final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID); final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID);
LOG.info("loanID---- {}" , loanID); LOG.info("loanID---- {}", loanID);
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
this.responseSpec, loanID); loanID);
verifyLoanRepaymentSchedule(loanSchedule); verifyLoanRepaymentSchedule(loanSchedule);
} }
private Integer createLoanProduct() { private Integer createLoanProduct() {
LOG.info( LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
"------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() // final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
@@ -130,10 +127,8 @@ public class SkipRepaymentOnMonthFirstTest {
return this.loanTransactionHelper.getLoanProductId(loanProductJSON); return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
} }
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID, private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID, Integer clientID) {
Integer clientID) { LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
LOG.info(
"--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() // final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("12,000.00") // .withPrincipal("12,000.00") //
.withLoanTermFrequency("4") // .withLoanTermFrequency("4") //
@@ -157,19 +152,19 @@ public class SkipRepaymentOnMonthFirstTest {
LOG.info("--------------------VERIFYING THE REPAYMENT DATE--------------------------"); LOG.info("--------------------VERIFYING THE REPAYMENT DATE--------------------------");
assertEquals(new ArrayList<>(Arrays.asList(2011, 10, 15)), loanSchedule.get(1).get("dueDate"), assertEquals(new ArrayList<>(Arrays.asList(2011, 10, 15)), loanSchedule.get(1).get("dueDate"),
"Checking for Repayment Date for 1st Month"); "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"), assertEquals(new ArrayList<>(Arrays.asList(2011, 11, 15)), loanSchedule.get(2).get("dueDate"),
"Checking for Repayment Date for 2nd Month"); "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"), assertEquals(new ArrayList<>(Arrays.asList(2011, 12, 15)), loanSchedule.get(3).get("dueDate"),
"Checking for Repayment Date for 3rd Month"); "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"), assertEquals(new ArrayList<>(Arrays.asList(2012, 1, 15)), loanSchedule.get(4).get("dueDate"),
"Checking for Repayment Date for 4th Month"); "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 @Test
public void getStaffImage(){ public void getStaffImage() {
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId); Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
assertNotNull(imageId, "Image id should not be null"); assertNotNull(imageId, "Image id should not be null");
@@ -63,7 +63,7 @@ public class StaffImageApiTest {
} }
@Test @Test
public void getStaffImageAsBinary(){ public void getStaffImageAsBinary() {
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId); Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
assertNotNull(imageId, "Image id should not be null"); assertNotNull(imageId, "Image id should not be null");
@@ -84,7 +84,7 @@ public class StaffTest {
/** Long lastname test */ /** Long lastname test */
map.put("lastname", Utils.randomNameGenerator("Doe_", 47)); map.put("lastname", Utils.randomNameGenerator("Doe_", 47));
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map)); 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 */ /** Long mobileNo test */
map.put("mobileNo", Utils.randomNameGenerator("num_", 47)); map.put("mobileNo", Utils.randomNameGenerator("num_", 47));
@@ -136,7 +136,7 @@ public class StaffTest {
@Test @Test
public void testStaffListStatusActive() { public void testStaffListStatusActive() {
List<Map<String, Object>> responseActive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active"); 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.assertNotNull(staff.get("id"));
Assertions.assertEquals(true, staff.get("isActive")); Assertions.assertEquals(true, staff.get("isActive"));
} }
@@ -145,7 +145,7 @@ public class StaffTest {
@Test @Test
public void testStaffListStatusInactive() { public void testStaffListStatusInactive() {
List<Map<String, Object>> responseInactive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive"); 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.assertNotNull(staff.get("id"));
Assertions.assertEquals(false, staff.get("isActive")); Assertions.assertEquals(false, staff.get("isActive"));
} }
@@ -46,4 +46,4 @@ public class SurveyIntegrationTest {
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
} }
} }
@@ -90,8 +90,8 @@ public class SystemCodeTest {
assertEquals(createResponseId, deleteResponseId, "Verify code deleted"); assertEquals(createResponseId, deleteResponseId, "Verify code deleted");
// verify code deleted // verify code deleted
final HashMap deletedCodeValues = (HashMap) CodeHelper final HashMap deletedCodeValues = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId,
.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId, ""); "");
Assertions.assertNotNull(deletedCodeValues); Assertions.assertNotNull(deletedCodeValues);
assertNull(deletedCodeValues.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId"); 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"); assertEquals(createResponseId, deleteResponseId, "Verify code deleted");
// verify code deleted // verify code deleted
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId,
deleteResponseId, ""); "");
Assertions.assertNotNull(deletedCodeAttributes); Assertions.assertNotNull(deletedCodeAttributes);
assertNull(deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId"); assertNull(deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), "Verify value of codeId");
@@ -206,11 +206,10 @@ public class SystemCodeTest {
createCodeResponseId, createCodeValueResponseId1, ""); createCodeResponseId, createCodeValueResponseId1, "");
Assertions.assertNotNull(codeValuesAttributes1); Assertions.assertNotNull(codeValuesAttributes1);
assertEquals(createCodeValueResponseId1, assertEquals(createCodeValueResponseId1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME),
codeValuesAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME), "Verify value of codeValueId"); "Verify value of codeValueId");
assertEquals(codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME), assertEquals(codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME), "Verify value of code name");
"Verify value of code name");
assertEquals(codeDescription1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME), assertEquals(codeDescription1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME),
"Verify value of code description"); "Verify value of code description");
@@ -64,11 +64,13 @@ public class TemplateIntegrationTest {
ArrayList<?> get = Utils.performServerGet(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, ""); ArrayList<?> get = Utils.performServerGet(this.requestSpec, this.responseSpec, this.GET_TEMPLATES_URL, "");
final int entriesBeforeTest = get.size(); 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 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")); Assertions.assertTrue(getrequest2.equals("foo"));
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class UserAdministrationTest { public class UserAdministrationTest {
private final static Logger LOG = LoggerFactory.getLogger(UserAdministrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(UserAdministrationTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -59,7 +60,7 @@ public class UserAdministrationTest {
@AfterEach @AfterEach
public void tearDown() { public void tearDown() {
for(Integer userId : this.transientUsers) { for (Integer userId : this.transientUsers) {
UserHelper.deleteUser(this.requestSpec, this.responseSpec, userId); UserHelper.deleteUser(this.requestSpec, this.responseSpec, userId);
} }
this.transientUsers.clear(); this.transientUsers.clear();
@@ -74,14 +75,15 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId); 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); Assertions.assertNotNull(userId);
this.transientUsers.add(userId); this.transientUsers.add(userId);
final List errors = (List) UserHelper.createUser(this.requestSpec, expectStatusCode(403), roleId, staffId, "alphabet", "errors"); final List errors = (List) UserHelper.createUser(this.requestSpec, expectStatusCode(403), roleId, staffId, "alphabet", "errors");
Map reason = (Map) errors.get(0); Map reason = (Map) errors.get(0);
LOG.info("Reason: {}" , reason.get("defaultUserMessage")); LOG.info("Reason: {}", reason.get("defaultUserMessage"));
LOG.info("Code: {}" , reason.get("userMessageGlobalisationCode")); LOG.info("Code: {}", reason.get("userMessageGlobalisationCode"));
Assertions.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage")); Assertions.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage"));
Assertions.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode")); 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); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId); 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); Assertions.assertNotNull(userId);
this.transientUsers.add(userId); this.transientUsers.add(userId);
@@ -113,11 +116,13 @@ public class UserAdministrationTest {
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(staffId); 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); Assertions.assertNotNull(userId);
this.transientUsers.add(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); Assertions.assertNotNull(userId2);
this.transientUsers.add(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("User with username alphabet already exists.", reason.get("defaultUserMessage"));
Assertions.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode")); Assertions.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode"));
} }
@Test @Test
public void testCreateNewUserBlocksDuplicateClientId() { public void testCreateNewUserBlocksDuplicateClientId() {
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); 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); final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assertions.assertNotNull(clientId); 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); Assertions.assertNotNull(userId);
this.transientUsers.add(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); 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" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class XBRLIntegrationTest { public class XBRLIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(XBRLIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(XBRLIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -52,6 +52,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClientEntityImportHandlerTest { public class ClientEntityImportHandlerTest {
private final static Logger LOG = LoggerFactory.getLogger(ClientEntityImportHandlerTest.class); private final static Logger LOG = LoggerFactory.getLogger(ClientEntityImportHandlerTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
@@ -68,85 +69,90 @@ public class ClientEntityImportHandlerTest {
@Test @Test
public void testClientImport() throws InterruptedException, IOException, ParseException { 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); 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"); Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
//in order to populate helper sheets // in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000"); Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office"); Assertions.assertNotNull(outcome_office_creation, "Could not create office");
//in order to populate helper columns in client entity sheet // in order to populate helper columns in client entity sheet
//create constitution // create constitution
CodeHelper.retrieveOrCreateCodeValue(24,requestSpec,responseSpec); CodeHelper.retrieveOrCreateCodeValue(24, requestSpec, responseSpec);
//create client classification // create client classification
CodeHelper.retrieveOrCreateCodeValue(17,requestSpec,responseSpec); CodeHelper.retrieveOrCreateCodeValue(17, requestSpec, responseSpec);
//create client types // create client types
CodeHelper.retrieveOrCreateCodeValue(16,requestSpec,responseSpec); CodeHelper.retrieveOrCreateCodeValue(16, requestSpec, responseSpec);
//create Address types // create Address types
CodeHelper.retrieveOrCreateCodeValue(29,requestSpec,responseSpec); CodeHelper.retrieveOrCreateCodeValue(29, requestSpec, responseSpec);
//create State // create State
CodeHelper.retrieveOrCreateCodeValue(27,requestSpec,responseSpec); CodeHelper.retrieveOrCreateCodeValue(27, requestSpec, responseSpec);
//create Country // create Country
CodeHelper.retrieveOrCreateCodeValue(28,requestSpec,responseSpec); CodeHelper.retrieveOrCreateCodeValue(28, requestSpec, responseSpec);
//create Main business line // create Main business line
CodeHelper.retrieveOrCreateCodeValue(25,requestSpec,responseSpec); CodeHelper.retrieveOrCreateCodeValue(25, requestSpec, responseSpec);
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec); ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Workbook workbook=clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY,"dd MMMM yyyy"); 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); Sheet clientEntitySheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
Row firstClientRow=clientEntitySheet.getRow(1); Row firstClientRow = clientEntitySheet.getRow(1);
firstClientRow.createCell(ClientEntityConstants.NAME_COL).setCellValue(Utils.randomNameGenerator("C_E_",6)); firstClientRow.createCell(ClientEntityConstants.NAME_COL).setCellValue(Utils.randomNameGenerator("C_E_", 6));
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME); Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
firstClientRow.createCell(ClientEntityConstants.OFFICE_NAME_COL).setCellValue(staffSheet.getRow(1).getCell(0).getStringCellValue()); 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()); firstClientRow.createCell(ClientEntityConstants.STAFF_NAME_COL).setCellValue(staffSheet.getRow(1).getCell(1).getStringCellValue());
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date incoporationDate=simpleDateFormat.parse("14 May 2001"); Date incoporationDate = simpleDateFormat.parse("14 May 2001");
firstClientRow.createCell(ClientEntityConstants.INCOPORATION_DATE_COL).setCellValue(incoporationDate); 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.INCOPORATION_VALID_TILL_COL).setCellValue(validTill);
firstClientRow.createCell(ClientEntityConstants.MOBILE_NO_COL).setCellValue(Utils.randomNumberGenerator(7)); 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_TYPE_COL)
firstClientRow.createCell(ClientEntityConstants.CLIENT_CLASSIFICATION_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CLIENT_CLASSIFICATION).getStringCellValue()); .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.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.MAIN_BUSINESS_LINE)
firstClientRow.createCell(ClientEntityConstants.CONSTITUTION_COL).setCellValue(clientEntitySheet.getRow(1).getCell(ClientEntityConstants.LOOKUP_CONSTITUTION_COL).getStringCellValue()); .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"); 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.SUBMITTED_ON_COL).setCellValue(submittedDate);
firstClientRow.createCell(ClientEntityConstants.ADDRESS_ENABLED).setCellValue("False"); 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()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
File file= new File(directory+File.separator+"ClientEntity.xls"); File file = new File(directory + File.separator + "ClientEntity.xls");
OutputStream outputStream=new FileOutputStream(file); OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream); workbook.write(outputStream);
outputStream.close(); outputStream.close();
String importDocumentId=clientHelper.importClientEntityTemplate(file); String importDocumentId = clientHelper.importClientEntityTemplate(file);
file.delete(); file.delete();
Assertions.assertNotNull(importDocumentId); Assertions.assertNotNull(importDocumentId);
//Wait for the creation of output excel // Wait for the creation of output excel
Thread.sleep(10000); Thread.sleep(10000);
//check status column of output excel // check status column of output excel
String location=clientHelper.getOutputTemplateLocation(importDocumentId); String location = clientHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location); FileInputStream fileInputStream = new FileInputStream(location);
Workbook outputWorkbook=new HSSFWorkbook(fileInputStream); Workbook outputWorkbook = new HSSFWorkbook(fileInputStream);
Sheet outputClientEntitySheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME); 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("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(ClientEntityConstants.STATUS_COL).getStringCellValue()); 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(); outputWorkbook.close();
} }
} }
@@ -80,9 +80,9 @@ public class LoanImportHandlerTest {
public void testLoanImport() throws InterruptedException, IOException, ParseException { public void testLoanImport() throws InterruptedException, IOException, ParseException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets // in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000"); Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office"); Assertions.assertNotNull(outcome_office_creation, "Could not create office");
OfficeDomain office = officeHelper.retrieveOfficeByID(outcome_office_creation); OfficeDomain office = officeHelper.retrieveOfficeByID(outcome_office_creation);
@@ -102,55 +102,57 @@ public class LoanImportHandlerTest {
clientMap.put("active", "true"); clientMap.put("active", "true");
clientMap.put("activationDate", "04 March 2011"); 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"); new Gson().toJson(clientMap), "clientId");
Assertions.assertNotNull(outcome_client_creation, "Could not create client"); Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets // in order to populate helper sheets
Integer outcome_group_creation = GroupHelper.createGroup(requestSpec,responseSpec,true); Integer outcome_group_creation = GroupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group"); Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets // in order to populate helper sheets
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"); Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
Map<String, Object> staffMap = StaffHelper.getStaff(requestSpec, responseSpec, outcome_staff_creation); Map<String, Object> staffMap = StaffHelper.getStaff(requestSpec, responseSpec, outcome_staff_creation);
Assertions.assertNotNull(staffMap, "Could not retrieve created staff"); Assertions.assertNotNull(staffMap, "Could not retrieve created staff");
LoanTransactionHelper ltHelper=new LoanTransactionHelper(requestSpec,responseSpec); LoanTransactionHelper ltHelper = new LoanTransactionHelper(requestSpec, responseSpec);
LoanProductTestBuilder loanProductTestBuilder=new LoanProductTestBuilder(); LoanProductTestBuilder loanProductTestBuilder = new LoanProductTestBuilder();
String jsonLoanProduct=loanProductTestBuilder.build(null); String jsonLoanProduct = loanProductTestBuilder.build(null);
Integer outcome_lp_creation=ltHelper.getLoanProductId(jsonLoanProduct); Integer outcome_lp_creation = ltHelper.getLoanProductId(jsonLoanProduct);
Assertions.assertNotNull(outcome_lp_creation, "Could not create Loan Product"); Assertions.assertNotNull(outcome_lp_creation, "Could not create Loan Product");
String loanProductStr = ltHelper.getLoanProductDetails(requestSpec, responseSpec, outcome_lp_creation); 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); JsonPath loanProductJson = JsonPath.from(loanProductStr);
String fundName = Utils.randomNameGenerator("",9); String fundName = Utils.randomNameGenerator("", 9);
FundsHelper fh = FundsHelper.create(fundName).externalId("fund-" + fundName).build(); 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"); Assertions.assertNotNull(outcome_fund_creation, "Could not create Fund");
String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5); String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5);
String paymentTypeDescription = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); 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"); Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
LoanTransactionHelper loanTransactionHelper=new LoanTransactionHelper(requestSpec,responseSpec); LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
Workbook workbook=loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy"); 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); 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.OFFICE_NAME_COL).setCellValue(office.getName());
firstLoanRow.createCell(LoanConstants.LOAN_TYPE_COL).setCellValue("Individual"); 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.CLIENT_EXTERNAL_ID).setCellValue(externalId);
firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name")); firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name"));
firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName")); firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date date=simpleDateFormat.parse("13 May 2017"); Date date = simpleDateFormat.parse("13 May 2017");
firstLoanRow.createCell(LoanConstants.SUBMITTED_ON_DATE_COL).setCellValue(date); firstLoanRow.createCell(LoanConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
firstLoanRow.createCell(LoanConstants.APPROVED_DATE_COL).setCellValue(date); firstLoanRow.createCell(LoanConstants.APPROVED_DATE_COL).setCellValue(date);
firstLoanRow.createCell(LoanConstants.DISBURSED_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.PRINCIPAL_COL).setCellValue(loanProductJson.getFloat("principal"));
firstLoanRow.createCell(LoanConstants.NO_OF_REPAYMENTS_COL).setCellValue(loanProductJson.getInt("numberOfRepayments")); 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_COL).setCellValue(loanProductJson.getInt("repaymentEvery"));
firstLoanRow.createCell(LoanConstants.REPAID_EVERY_FREQUENCY_COL).setCellValue(loanProductJson.getString("repaymentFrequencyType.value")); firstLoanRow.createCell(LoanConstants.REPAID_EVERY_FREQUENCY_COL)
firstLoanRow.createCell(LoanConstants.LOAN_TERM_COL).setCellValue(loanProductJson.getInt("repaymentEvery") * loanProductJson.getInt("numberOfRepayments")); .setCellValue(loanProductJson.getString("repaymentFrequencyType.value"));
firstLoanRow.createCell(LoanConstants.LOAN_TERM_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_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.AMORTIZATION_COL).setCellValue(loanProductJson.getString("amortizationType.value"));
firstLoanRow.createCell(LoanConstants.INTEREST_METHOD_COL).setCellValue(loanProductJson.getString("interestType.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.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_PRINCIPAL_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0); firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_CHARGED_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); firstLoanRow.createCell(LoanConstants.REPAYMENT_TYPE_COL).setCellValue(paymentTypeName);
String currentdirectory = new File("").getAbsolutePath(); String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+ File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"loan") ; + "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "loan");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
File file= new File(directory+File.separator+"Loan.xls"); File file = new File(directory + File.separator + "Loan.xls");
OutputStream outputStream=new FileOutputStream(file); OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream); workbook.write(outputStream);
outputStream.close(); outputStream.close();
String importDocumentId=loanTransactionHelper.importLoanTemplate(file); String importDocumentId = loanTransactionHelper.importLoanTemplate(file);
file.delete(); file.delete();
Assertions.assertNotNull(importDocumentId); Assertions.assertNotNull(importDocumentId);
//Wait for the creation of output excel // Wait for the creation of output excel
Thread.sleep(10000); Thread.sleep(10000);
//check status column of output excel // check status column of output excel
String location=loanTransactionHelper.getOutputTemplateLocation(importDocumentId); String location = loanTransactionHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location); FileInputStream fileInputStream = new FileInputStream(location);
Workbook outputworkbook=new HSSFWorkbook(fileInputStream); Workbook outputworkbook = new HSSFWorkbook(fileInputStream);
Sheet outputLoanSheet = outputworkbook.getSheet(TemplatePopulateImportConstants.LOANS_SHEET_NAME); 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("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(LoanConstants.FAILURE_REPORT_COL).getStringCellValue()); 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(); outputworkbook.close();
} }
} }
@@ -52,56 +52,54 @@ public class OfficeImportHandlerTest {
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@BeforeEach @BeforeEach
public void setup(){ public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec=new RequestSpecBuilder().build(); this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
.header("Authorization", this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@Test @Test
public void testOfficeImport() throws IOException, InterruptedException, NoSuchFieldException, ParseException { public void testOfficeImport() throws IOException, InterruptedException, NoSuchFieldException, ParseException {
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Workbook workbook=officeHelper.getOfficeWorkBook("dd MMMM yyyy"); Workbook workbook = officeHelper.getOfficeWorkBook("dd MMMM yyyy");
//insert dummy data into excel // insert dummy data into excel
Sheet sheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME); Sheet sheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow= sheet.getRow(1); Row firstOfficeRow = sheet.getRow(1);
firstOfficeRow.createCell(OfficeConstants.OFFICE_NAME_COL).setCellValue(Utils.randomNameGenerator("Test_Off_",6)); 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_NAME_COL)
firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_ID_COL).setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_ID_COL).getNumericCellValue()); .setCellValue(firstOfficeRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue());
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy"); firstOfficeRow.createCell(OfficeConstants.PARENT_OFFICE_ID_COL)
Date date=simpleDateFormat.parse("14 May 2001"); .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); firstOfficeRow.createCell(OfficeConstants.OPENED_ON_COL).setCellValue(date);
String currentdirectory = new File("").getAbsolutePath(); String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+ File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"office"); + "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "office");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
File file= new File(directory+File.separator+"Office.xls"); File file = new File(directory + File.separator + "Office.xls");
OutputStream outputStream=new FileOutputStream(file); OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream); workbook.write(outputStream);
outputStream.close(); outputStream.close();
String importDocumentId=officeHelper.importOfficeTemplate(file); String importDocumentId = officeHelper.importOfficeTemplate(file);
file.delete(); file.delete();
Assertions.assertNotNull(importDocumentId); Assertions.assertNotNull(importDocumentId);
// Wait for the creation of output excel // Wait for the creation of output excel
Thread.sleep(10000); Thread.sleep(10000);
//check status column of output excel // check status column of output excel
String location=officeHelper.getOutputTemplateLocation(importDocumentId); String location = officeHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location); FileInputStream fileInputStream = new FileInputStream(location);
Workbook outputWorkbook=new HSSFWorkbook(fileInputStream); Workbook outputWorkbook = new HSSFWorkbook(fileInputStream);
Sheet officeSheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME); 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("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(OfficeConstants.STATUS_COL).getStringCellValue()); 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 { public void testSavingsImport() throws InterruptedException, IOException, ParseException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets // in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000"); Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office"); Assertions.assertNotNull(outcome_office_creation, "Could not create office");
OfficeDomain office = officeHelper.retrieveOfficeByID(outcome_office_creation); OfficeDomain office = officeHelper.retrieveOfficeByID(outcome_office_creation);
@@ -99,87 +99,98 @@ public class SavingsImportHandlerTest {
clientMap.put("active", "true"); clientMap.put("active", "true");
clientMap.put("activationDate", "04 March 2011"); 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"); new Gson().toJson(clientMap), "clientId");
Assertions.assertNotNull(outcome_client_creation, "Could not create client"); Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets // in order to populate helper sheets
Integer outcome_group_creation=GroupHelper.createGroup(requestSpec,responseSpec,true); Integer outcome_group_creation = GroupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group"); Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets // in order to populate helper sheets
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"); Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
Map<String, Object> staffMap = StaffHelper.getStaff(requestSpec, responseSpec, outcome_staff_creation); Map<String, Object> staffMap = StaffHelper.getStaff(requestSpec, responseSpec, outcome_staff_creation);
Assertions.assertNotNull(staffMap, "Could not retrieve created staff"); Assertions.assertNotNull(staffMap, "Could not retrieve created staff");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
String jsonSavingsProduct=savingsProductHelper.build(); String jsonSavingsProduct = savingsProductHelper.build();
Integer outcome_sp_creaction=SavingsProductHelper.createSavingsProduct(jsonSavingsProduct,requestSpec,responseSpec); Integer outcome_sp_creaction = SavingsProductHelper.createSavingsProduct(jsonSavingsProduct, requestSpec, responseSpec);
Assertions.assertNotNull(outcome_sp_creaction, "Could not create Savings product"); Assertions.assertNotNull(outcome_sp_creaction, "Could not create Savings product");
SavingsAccountHelper savingsAccountHelper=new SavingsAccountHelper(requestSpec,responseSpec); SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
Workbook workbook=savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy"); 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); 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.OFFICE_NAME_COL).setCellValue(office.getName());
firstSavingsRow.createCell(SavingsConstants.SAVINGS_TYPE_COL).setCellValue("Individual"); firstSavingsRow.createCell(SavingsConstants.SAVINGS_TYPE_COL).setCellValue("Individual");
firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL).setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")"); firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL)
Sheet savingsProductSheet=workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME); .setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
firstSavingsRow.createCell(SavingsConstants.PRODUCT_COL).setCellValue(savingsProductSheet.getRow(1).getCell(1).getStringCellValue()); 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")); firstSavingsRow.createCell(SavingsConstants.FIELD_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");
Date date=simpleDateFormat.parse("13 May 2017"); Date date = simpleDateFormat.parse("13 May 2017");
firstSavingsRow.createCell(SavingsConstants.SUBMITTED_ON_DATE_COL).setCellValue(date); firstSavingsRow.createCell(SavingsConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.APPROVED_DATE_COL).setCellValue(date); firstSavingsRow.createCell(SavingsConstants.APPROVED_DATE_COL).setCellValue(date);
firstSavingsRow.createCell(SavingsConstants.ACTIVATION_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.CURRENCY_COL)
firstSavingsRow.createCell(SavingsConstants.DECIMAL_PLACES_COL).setCellValue(savingsProductSheet.getRow(1).getCell(11).getNumericCellValue()); .setCellValue(savingsProductSheet.getRow(1).getCell(10).getStringCellValue());
firstSavingsRow.createCell(SavingsConstants.IN_MULTIPLES_OF_COL).setCellValue(savingsProductSheet.getRow(1).getCell(12).getNumericCellValue()); firstSavingsRow.createCell(SavingsConstants.DECIMAL_PLACES_COL)
firstSavingsRow.createCell(SavingsConstants.NOMINAL_ANNUAL_INTEREST_RATE_COL).setCellValue(savingsProductSheet.getRow(1).getCell(2).getNumericCellValue()); .setCellValue(savingsProductSheet.getRow(1).getCell(11).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_COMPOUNDING_PERIOD_COL).setCellValue(savingsProductSheet.getRow(1).getCell(3).getStringCellValue()); firstSavingsRow.createCell(SavingsConstants.IN_MULTIPLES_OF_COL)
firstSavingsRow.createCell(SavingsConstants.INTEREST_POSTING_PERIOD_COL).setCellValue(savingsProductSheet.getRow(1).getCell(4).getStringCellValue()); .setCellValue(savingsProductSheet.getRow(1).getCell(12).getNumericCellValue());
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_COL).setCellValue(savingsProductSheet.getRow(1).getCell(5).getStringCellValue()); firstSavingsRow.createCell(SavingsConstants.NOMINAL_ANNUAL_INTEREST_RATE_COL)
firstSavingsRow.createCell(SavingsConstants.INTEREST_CALCULATION_DAYS_IN_YEAR_COL).setCellValue(savingsProductSheet.getRow(1).getCell(6).getStringCellValue()); .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.MIN_OPENING_BALANCE_COL).setCellValue(1000.0);
firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_COL).setCellValue(1); firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_COL).setCellValue(1);
firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_FREQUENCY_COL).setCellValue("Weeks"); firstSavingsRow.createCell(SavingsConstants.LOCKIN_PERIOD_FREQUENCY_COL).setCellValue("Weeks");
firstSavingsRow.createCell(SavingsConstants.APPLY_WITHDRAWAL_FEE_FOR_TRANSFERS).setCellValue("False"); firstSavingsRow.createCell(SavingsConstants.APPLY_WITHDRAWAL_FEE_FOR_TRANSFERS).setCellValue("False");
firstSavingsRow.createCell(SavingsConstants.ALLOW_OVER_DRAFT_COL).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(); String currentdirectory = new File("").getAbsolutePath();
File directory=new File(currentdirectory+File.separator+"src"+File.separator+"integrationTest"+File.separator+ File directory = new File(currentdirectory + File.separator + "src" + File.separator + "integrationTest" + File.separator
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"savings") ; + "resources" + File.separator + "bulkimport" + File.separator + "importhandler" + File.separator + "savings");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
File file= new File(directory+File.separator+"Savings.xls"); File file = new File(directory + File.separator + "Savings.xls");
OutputStream outputStream=new FileOutputStream(file); OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream); workbook.write(outputStream);
outputStream.close(); outputStream.close();
String importDocumentId=savingsAccountHelper.importSavingsTemplate(file); String importDocumentId = savingsAccountHelper.importSavingsTemplate(file);
file.delete(); file.delete();
Assertions.assertNotNull(importDocumentId); Assertions.assertNotNull(importDocumentId);
//Wait for the creation of output excel // Wait for the creation of output excel
Thread.sleep(10000); Thread.sleep(10000);
//check status column of output excel // check status column of output excel
String location=savingsAccountHelper.getOutputTemplateLocation(importDocumentId); String location = savingsAccountHelper.getOutputTemplateLocation(importDocumentId);
FileInputStream fileInputStream = new FileInputStream(location); FileInputStream fileInputStream = new FileInputStream(location);
Workbook Outputworkbook=new HSSFWorkbook(fileInputStream); Workbook Outputworkbook = new HSSFWorkbook(fileInputStream);
Sheet OutputSavingsSheet = Outputworkbook.getSheet(TemplatePopulateImportConstants.SAVINGS_ACCOUNTS_SHEET_NAME); 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("Output location: {}", location);
LOG.info("Failure reason column: {}", row.getCell(SavingsConstants.STATUS_COL).getStringCellValue()); 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(); Outputworkbook.close();
} }
} }
@@ -44,39 +44,34 @@ public class ClientEntityWorkbookPopulatorTest {
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@BeforeEach @BeforeEach
public void setup(){ public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec=new RequestSpecBuilder().build(); this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
.header("Authorization", this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@Test @Test
public void testClientEntityWorkbookPopulate() throws IOException { public void testClientEntityWorkbookPopulate() throws IOException {
//in order to populate helper sheets // in order to populate helper sheets
StaffHelper staffHelper=new StaffHelper(); StaffHelper staffHelper = new StaffHelper();
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); 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"); Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
//in order to populate helper sheets // in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000"); Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office"); Assertions.assertNotNull(outcome_office_creation, "Could not create office");
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec); ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Workbook workbook=clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY,"dd MMMM yyyy"); Workbook workbook = clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY, "dd MMMM yyyy");
Sheet officeSheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME); Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow=officeSheet.getRow(1); Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found for given OfficeId "); Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found for given OfficeId ");
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME); Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow=staffSheet.getRow(1); Row firstStaffRow = staffSheet.getRow(1);
Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found for given staffId"); Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found for given staffId");
} }
} }
@@ -49,80 +49,80 @@ public class LoanWorkbookPopulatorTest {
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@BeforeEach @BeforeEach
public void setup(){ public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); 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.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
} }
@Test @Test
public void testLoanWorkbookPopulate() throws IOException { public void testLoanWorkbookPopulate() throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets // in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000"); Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office"); Assertions.assertNotNull(outcome_office_creation, "Could not create office");
//in order to populate helper sheets // in order to populate helper sheets
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec); ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec); Integer outcome_client_creation = clientHelper.createClient(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_client_creation, "Could not create client"); Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets // in order to populate helper sheets
GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec); GroupHelper groupHelper = new GroupHelper(requestSpec, responseSpec);
Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true); Integer outcome_group_creation = groupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group"); Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets // in order to populate helper sheets
StaffHelper staffHelper=new StaffHelper(); StaffHelper staffHelper = new StaffHelper();
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"); Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
LoanTransactionHelper loanTransactionHelper=new LoanTransactionHelper(requestSpec,responseSpec); LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
LoanProductTestBuilder loanProductTestBuilder=new LoanProductTestBuilder(); LoanProductTestBuilder loanProductTestBuilder = new LoanProductTestBuilder();
String jsonLoanProduct=loanProductTestBuilder.build(null); String jsonLoanProduct = loanProductTestBuilder.build(null);
Integer outcome_lp_creaion=loanTransactionHelper.getLoanProductId(jsonLoanProduct); Integer outcome_lp_creaion = loanTransactionHelper.getLoanProductId(jsonLoanProduct);
Assertions.assertNotNull(outcome_lp_creaion, "Could not create Loan Product"); Assertions.assertNotNull(outcome_lp_creaion, "Could not create Loan Product");
FundsResourceHandler fundsResourceHandler=new FundsResourceHandler(); FundsResourceHandler fundsResourceHandler = new FundsResourceHandler();
String jsonFund="{\n" + String jsonFund = "{\n" + "\t\"name\": \"" + Utils.randomNameGenerator("Fund_Name", 9) + "\"\n" + "}";
"\t\"name\": \""+Utils.randomNameGenerator("Fund_Name",9)+"\"\n" + Integer outcome_fund_creation = fundsResourceHandler.createFund(jsonFund, requestSpec, responseSpec);
"}";
Integer outcome_fund_creation=fundsResourceHandler.createFund(jsonFund,requestSpec,responseSpec);
Assertions.assertNotNull(outcome_fund_creation, "Could not create Fund"); 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 name = PaymentTypeHelper.randomNameGenerator("P_T", 5);
String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15);
Boolean isCashPayment = true; Boolean isCashPayment = true;
Integer position = 1; 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"); 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); Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow=officeSheet.getRow(1); Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found "); Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found ");
Sheet clientSheet=workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME); Sheet clientSheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME);
Row firstClientRow=clientSheet.getRow(1); Row firstClientRow = clientSheet.getRow(1);
Assertions.assertNotNull(firstClientRow.getCell(1), "No clients found "); Assertions.assertNotNull(firstClientRow.getCell(1), "No clients found ");
Sheet groupSheet=workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME); Sheet groupSheet = workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME);
Row firstGroupRow=groupSheet.getRow(1); Row firstGroupRow = groupSheet.getRow(1);
Assertions.assertNotNull(firstGroupRow.getCell(1), "No groups found "); Assertions.assertNotNull(firstGroupRow.getCell(1), "No groups found ");
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME); Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow=staffSheet.getRow(1); Row firstStaffRow = staffSheet.getRow(1);
Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found "); Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found ");
Sheet productSheet=workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME); Sheet productSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
Row firstProductRow=productSheet.getRow(1); Row firstProductRow = productSheet.getRow(1);
Assertions.assertNotNull(firstProductRow.getCell(1), "No products found "); Assertions.assertNotNull(firstProductRow.getCell(1), "No products found ");
Sheet extrasSheet=workbook.getSheet(TemplatePopulateImportConstants.EXTRAS_SHEET_NAME); Sheet extrasSheet = workbook.getSheet(TemplatePopulateImportConstants.EXTRAS_SHEET_NAME);
Row firstExtrasRow=extrasSheet.getRow(1); Row firstExtrasRow = extrasSheet.getRow(1);
Assertions.assertNotNull(firstExtrasRow.getCell(1), "No Extras found "); Assertions.assertNotNull(firstExtrasRow.getCell(1), "No Extras found ");
} }
} }
@@ -35,27 +35,24 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class OfficeWorkBookPopulatorTest { public class OfficeWorkBookPopulatorTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@BeforeEach @BeforeEach
public void setup(){ public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec=new RequestSpecBuilder().build(); this.requestSpec = new RequestSpecBuilder().build();
this.requestSpec this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
.header("Authorization", this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
"Basic "
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
.build();
} }
@Test @Test
public void testOfficeWorkbookPopulate() throws IOException { public void testOfficeWorkbookPopulate() throws IOException {
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Workbook workbook=officeHelper.getOfficeWorkBook("dd MMMM yyyy"); Workbook workbook = officeHelper.getOfficeWorkBook("dd MMMM yyyy");
Sheet sheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME); Sheet sheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstRow= sheet.getRow(1); Row firstRow = sheet.getRow(1);
Assertions.assertNotNull("No parent offices found", firstRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue()); 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); 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; import org.junit.jupiter.api.Test;
public class SavingsWorkbookPopulateTest { public class SavingsWorkbookPopulateTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@BeforeEach @BeforeEach
public void setup(){ public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
@@ -56,52 +57,52 @@ public class SavingsWorkbookPopulateTest {
@Test @Test
public void testSavingsWorkbookPopulate() throws IOException { public void testSavingsWorkbookPopulate() throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
//in order to populate helper sheets // in order to populate helper sheets
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation=officeHelper.createOffice("02 May 2000"); Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office"); Assertions.assertNotNull(outcome_office_creation, "Could not create office");
//in order to populate helper sheets // in order to populate helper sheets
ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec); ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec); Integer outcome_client_creation = clientHelper.createClient(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_client_creation, "Could not create client"); Assertions.assertNotNull(outcome_client_creation, "Could not create client");
//in order to populate helper sheets // in order to populate helper sheets
GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec); GroupHelper groupHelper = new GroupHelper(requestSpec, responseSpec);
Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true); Integer outcome_group_creation = groupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group"); Assertions.assertNotNull(outcome_group_creation, "Could not create group");
//in order to populate helper sheets // in order to populate helper sheets
StaffHelper staffHelper=new StaffHelper(); StaffHelper staffHelper = new StaffHelper();
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"); Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
SavingsProductHelper savingsProductHelper=new SavingsProductHelper(); SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
String jsonSavingsProduct=savingsProductHelper.build(); String jsonSavingsProduct = savingsProductHelper.build();
Integer outcome_sp_creaction=savingsProductHelper.createSavingsProduct(jsonSavingsProduct,requestSpec,responseSpec); Integer outcome_sp_creaction = savingsProductHelper.createSavingsProduct(jsonSavingsProduct, requestSpec, responseSpec);
Assertions.assertNotNull(outcome_sp_creaction, "Could not create Savings product"); Assertions.assertNotNull(outcome_sp_creaction, "Could not create Savings product");
SavingsAccountHelper savingsAccountHelper=new SavingsAccountHelper(requestSpec,responseSpec); SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
Workbook workbook=savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy"); Workbook workbook = savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy");
Sheet officeSheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME); Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow=officeSheet.getRow(1); Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found "); Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found ");
Sheet clientSheet=workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME); Sheet clientSheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME);
Row firstClientRow=clientSheet.getRow(1); Row firstClientRow = clientSheet.getRow(1);
Assertions.assertNotNull(firstClientRow.getCell(1), "No clients found "); Assertions.assertNotNull(firstClientRow.getCell(1), "No clients found ");
Sheet groupSheet=workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME); Sheet groupSheet = workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME);
Row firstGroupRow=groupSheet.getRow(1); Row firstGroupRow = groupSheet.getRow(1);
Assertions.assertNotNull(firstGroupRow.getCell(1), "No groups found "); Assertions.assertNotNull(firstGroupRow.getCell(1), "No groups found ");
Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME); Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow=staffSheet.getRow(1); Row firstStaffRow = staffSheet.getRow(1);
Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found "); Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found ");
Sheet productSheet=workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME); Sheet productSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
Row firstProductRow=productSheet.getRow(1); Row firstProductRow = productSheet.getRow(1);
Assertions.assertNotNull(firstProductRow.getCell(1), "No products found "); Assertions.assertNotNull(firstProductRow.getCell(1), "No products found ");
} }
@@ -32,15 +32,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It * Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}.
* takes care of creation of {@code BatchRequest} list and posting this list to * It takes care of creation of {@code BatchRequest} list and posting this list
* the server. * to the server.
* *
* @author Rishabh Shukla * @author Rishabh Shukla
* *
* @see org.apache.fineract.integrationtests.BatchApiTest * @see org.apache.fineract.integrationtests.BatchApiTest
*/ */
public class BatchHelper { public class BatchHelper {
private final static Logger LOG = LoggerFactory.getLogger(BatchHelper.class); private final static Logger LOG = LoggerFactory.getLogger(BatchHelper.class);
private static final String BATCH_API_URL = "/fineract-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER; private static final String BATCH_API_URL = "/fineract-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER;
private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true"; private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true";
@@ -190,14 +191,14 @@ public class BatchHelper {
} }
final String body = "{ \"officeId\": 1, \"firstname\": \"Petra\", \"lastname\": \"Yton\"," + "\"externalId\": \"" + externalId 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); br.setBody(body);
return br; return br;
} }
/** /**
* Creates and returns a * Creates and returns a
* {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy} * {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy}
@@ -408,8 +409,8 @@ public class BatchHelper {
br.setReference(reference); br.setReference(reference);
br.setRelativeUrl("loans/$.loanId/transactions?command=repayment"); br.setRelativeUrl("loans/$.loanId/transactions?command=repayment");
br.setMethod("POST"); br.setMethod("POST");
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", " + br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", "
"\"transactionDate\": \"15 September 2013\", \"transactionAmount\": 500}"); + "\"transactionDate\": \"15 September 2013\", \"transactionAmount\": 500}");
return br; return br;
} }
@@ -29,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class CalendarHelper { public class CalendarHelper {
private final static Logger LOG = LoggerFactory.getLogger(CalendarHelper.class); private final static Logger LOG = LoggerFactory.getLogger(CalendarHelper.class);
private static final String BASE_URL = "/fineract-provider/api/v1/"; private static final String BASE_URL = "/fineract-provider/api/v1/";
private static final String PARENT_ENTITY_NAME = "groups/"; private static final String PARENT_ENTITY_NAME = "groups/";
@@ -43,7 +44,7 @@ public class CalendarHelper {
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER; final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL); LOG.info("{}", CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -57,7 +58,7 @@ public class CalendarHelper {
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "/" + calendarID; final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "/" + calendarID;
LOG.info("{}",CALENDAR_RESOURCE_URL); LOG.info("{}", CALENDAR_RESOURCE_URL);
// TODO: check that resource id indeed exists in calendar update put. // TODO: check that resource id indeed exists in calendar update put.
return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -76,7 +77,7 @@ public class CalendarHelper {
map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4)); map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4));
map.put("typeId", "1"); map.put("typeId", "1");
map.put("startDate", startDate); map.put("startDate", startDate);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -87,17 +88,17 @@ public class CalendarHelper {
final String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, final String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL,
"collectionMeetingCalendar"); "collectionMeetingCalendar");
final Integer responseCalendarId = from(responseCalendarDetailsinJSON).get("id"); 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, 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------------------------------"); LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER; final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL); LOG.info("{}", CALENDAR_RESOURCE_URL);
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL,
getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId");
@@ -111,7 +112,7 @@ public class CalendarHelper {
final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + centerId + ENITY_NAME + "/" + calendarID + "?" final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + centerId + ENITY_NAME + "/" + calendarID + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL); LOG.info("{}", CALENDAR_RESOURCE_URL);
return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarMeetingAsJSON(oldDate, startDate), return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarMeetingAsJSON(oldDate, startDate),
"resourceId"); "resourceId");
@@ -128,4 +129,4 @@ public class CalendarHelper {
LOG.info("map : {}", map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
} }
@@ -26,7 +26,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class CenterDomain implements Comparable<CenterDomain> { public class CenterDomain implements Comparable<CenterDomain> {
private final static Logger LOG = LoggerFactory.getLogger(CenterDomain.class); private final static Logger LOG = LoggerFactory.getLogger(CenterDomain.class);
public static class Builder { public static class Builder {
private final Integer id; private final Integer id;
@@ -84,9 +86,9 @@ public class CenterDomain implements Comparable<CenterDomain> {
/* super(); */ /* super(); */
} }
private CenterDomain(final Integer id, final String accountNo, final Integer statusid, final String statuscode, final String statusvalue, final boolean active, private CenterDomain(final Integer id, final String accountNo, final Integer statusid, final String statuscode,
final String name, final String externalId, final Integer staffId, final Integer officeId, final String officeName, final String statusvalue, final boolean active, final String name, final String externalId, final Integer staffId,
final String hierarchy, final ArrayList<HashMap> groupMembers) { final Integer officeId, final String officeName, final String hierarchy, final ArrayList<HashMap> groupMembers) {
this.id = id; this.id = id;
this.accountNo = accountNo; this.accountNo = accountNo;
this.status = new HashMap<>(); this.status = new HashMap<>();
@@ -163,7 +165,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
if (groupMembers != null) { if (groupMembers != null) {
map.put("groupMembers", groupMembers); map.put("groupMembers", groupMembers);
} }
LOG.info("{}",map.toString()); LOG.info("{}", map.toString());
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -211,7 +213,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
return this.hierarchy; return this.hierarchy;
} }
public String getAccountNo(){ public String getAccountNo() {
return this.accountNo; return this.accountNo;
} }
@@ -256,15 +258,11 @@ public class CenterDomain implements Comparable<CenterDomain> {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { return true; } if (obj == this) { return true; }
if (!(obj instanceof CenterDomain)) { if (!(obj instanceof CenterDomain)) { return false; }
return false;
}
CenterDomain cd = (CenterDomain) obj; CenterDomain cd = (CenterDomain) obj;
if (this.hashCode() == cd.hashCode()) { if (this.hashCode() == cd.hashCode()) { return true; }
return true;
}
return false; return false;
} }
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class CenterHelper { public class CenterHelper {
private final static Logger LOG = LoggerFactory.getLogger(CenterHelper.class); private final static Logger LOG = LoggerFactory.getLogger(CenterHelper.class);
private static final String CENTERS_URL = "/fineract-provider/api/v1/centers"; private static final String CENTERS_URL = "/fineract-provider/api/v1/centers";
@@ -40,7 +41,7 @@ public class CenterHelper {
public static CenterDomain retrieveByID(int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static CenterDomain retrieveByID(int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String GET_CENTER_BY_ID_URL = CENTERS_URL + "/" + id + "?associations=groupMembers&" + Utils.TENANT_IDENTIFIER; final String GET_CENTER_BY_ID_URL = CENTERS_URL + "/" + id + "?associations=groupMembers&" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING CENTER AT {}-------------------------",id); LOG.info("------------------------ RETRIEVING CENTER AT {}-------------------------", id);
Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER_BY_ID_URL, ""); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER_BY_ID_URL, "");
final String jsonData = new Gson().toJson(get); final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<CenterDomain>() {}.getType()); return new Gson().fromJson(jsonData, new TypeToken<CenterDomain>() {}.getType());
@@ -110,7 +111,7 @@ public class CenterHelper {
public static HashMap<String, String> updateCenter(final int id, HashMap request, final RequestSpecification requestSpec, public static HashMap<String, String> updateCenter(final int id, HashMap request, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String UPDATE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
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), HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_CENTER_URL, new Gson().toJson(request),
"changes"); "changes");
return hash; return hash;
@@ -121,10 +122,10 @@ public class CenterHelper {
final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&" + Utils.TENANT_IDENTIFIER; final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&" + Utils.TENANT_IDENTIFIER;
HashMap groupMemberHashMap = new HashMap(); HashMap groupMemberHashMap = new HashMap();
groupMemberHashMap.put("groupMembers", groupMembers); groupMemberHashMap.put("groupMembers", groupMembers);
LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------",id); LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------", id);
HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL, HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL, new Gson().toJson(groupMemberHashMap),
new Gson().toJson(groupMemberHashMap), "changes"); "changes");
LOG.info("{}",hash.toString()); LOG.info("{}", hash.toString());
ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers"); ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers");
int[] ret = new int[arr.size()]; int[] ret = new int[arr.size()];
for (int i = 0; i < ret.length; i++) { for (int i = 0; i < ret.length; i++) {
@@ -135,7 +136,7 @@ public class CenterHelper {
public static void deleteCenter(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static void deleteCenter(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final String DELETE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String DELETE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------DELETING CENTER AT {}--------------------------------------------",id); LOG.info("---------------------------------DELETING CENTER AT {}--------------------------------------------", id);
Utils.performServerDelete(requestSpec, responseSpec, DELETE_CENTER_URL, ""); Utils.performServerDelete(requestSpec, responseSpec, DELETE_CENTER_URL, "");
} }
@@ -182,7 +183,8 @@ public class CenterHelper {
public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String centerId) { final String centerId) {
final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&" + Utils.TENANT_IDENTIFIER; final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&"
+ Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------ACTIVATE A CENTER---------------------------------------------"); LOG.info("---------------------------------ACTIVATE A CENTER---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId"); return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId");
} }
@@ -201,7 +203,7 @@ public class CenterHelper {
int[] groupMembers = null; int[] groupMembers = null;
String submittedDate = 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); externalId, staffId, officeID, officeName, hierarchy, groupMembers);
} }
@@ -220,7 +222,7 @@ public class CenterHelper {
final int[] groupMembers = null; final int[] groupMembers = null;
String submittedDate = 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); externalId, staffId, officeID, officeName, hierarchy, groupMembers);
} }
@@ -228,14 +230,14 @@ public class CenterHelper {
public static String assignStaffAsJSON(final Long staffId) { public static String assignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String unassignStaffAsJSON(final Long staffId) { public static String unassignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -249,7 +251,7 @@ public class CenterHelper {
map.put("activationDate", "CREATED_DATE"); map.put("activationDate", "CREATED_DATE");
LOG.info("defaulting to fixed date: CREATED_DATE"); LOG.info("defaulting to fixed date: CREATED_DATE");
} }
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -257,8 +259,8 @@ public class CenterHelper {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix); return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
} }
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,
final String groupId, final Long staffId) { final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff"; + "&command=assignStaff";
LOG.info("---------------------------------Assign Staff---------------------------------------------"); LOG.info("---------------------------------Assign Staff---------------------------------------------");
@@ -96,8 +96,8 @@ public class ClientChargesTest {
* Revert the paid client charge transaction by passing the * Revert the paid client charge transaction by passing the
* clientChargePaidTransactionId and ensure the same is reverted. * clientChargePaidTransactionId and ensure the same is reverted.
*/ */
final Integer undoTrxnId = ClientHelper.revertClientChargeTransaction(this.requestSpec, this.responseSpec, final Integer undoTrxnId = ClientHelper.revertClientChargeTransaction(this.requestSpec, this.responseSpec, clientId.toString(),
clientId.toString(), clientChargePaidTransactionId); clientChargePaidTransactionId);
Assertions.assertNotNull(undoTrxnId); Assertions.assertNotNull(undoTrxnId);
isReversedTransaction(clientId.toString(), undoTrxnId.toString()); isReversedTransaction(clientId.toString(), undoTrxnId.toString());
/** /**
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClientHelper { public class ClientHelper {
private final static Logger LOG = LoggerFactory.getLogger(ClientHelper.class); private final static Logger LOG = LoggerFactory.getLogger(ClientHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -69,8 +70,7 @@ public class ClientHelper {
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public static Integer createClient(final RequestSpecification requestSpec, public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClient(requestSpec, responseSpec, "04 March 2011"); return createClient(requestSpec, responseSpec, "04 March 2011");
} }
@@ -82,79 +82,72 @@ public class ClientHelper {
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate, final String officeId) { final String activationDate, final String officeId) {
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------"); LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(activationDate, officeId),
getTestClientAsJSON(activationDate, officeId), "clientId"); "clientId");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClientPending(requestSpec, responseSpec, "04 March 2014"); return createClientPending(requestSpec, responseSpec, "04 March 2014");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String submittedOnDate) { final String submittedOnDate) {
return createClientPending(requestSpec, responseSpec, submittedOnDate, "1"); return createClientPending(requestSpec, responseSpec, submittedOnDate, "1");
} }
public static Integer createClientPending(final RequestSpecification requestSpec, public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String submittedOnDate, final String officeId) { final String submittedOnDate, final String officeId) {
LOG.info( LOG.info("---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------");
"---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSONPending(submittedOnDate, officeId),
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, "clientId");
getTestClientAsJSONPending(submittedOnDate, officeId), "clientId");
} }
public Object createClientPendingWithError(final String jsonAttributeToGetBack) { public Object createClientPendingWithError(final String jsonAttributeToGetBack) {
LOG.info( LOG.info("---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------");
"---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------");
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL,
getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack); getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack);
} }
public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec, public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String registeredTableName) { final String registeredTableName) {
LOG.info( LOG.info("-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------");
"-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId"); getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClientAsPerson(requestSpec, responseSpec, "04 March 2011"); return createClientAsPerson(requestSpec, responseSpec, "04 March 2011");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate) { final String activationDate) {
return createClientAsPerson(requestSpec, responseSpec, activationDate, "1"); return createClientAsPerson(requestSpec, responseSpec, activationDate, "1");
} }
public static Integer createClientAsPerson(final RequestSpecification requestSpec, public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate, final String officeId) { final String activationDate, final String officeId) {
LOG.info( LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId),
getTestPersonClientAsJSON(activationDate, officeId), "clientId"); "clientId");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011"); return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate) { final String activationDate) {
return createClientAsEntity(requestSpec, responseSpec, activationDate, "1"); return createClientAsEntity(requestSpec, responseSpec, activationDate, "1");
} }
public static Integer createClientAsEntity(final RequestSpecification requestSpec, public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String activationDate, final String officeId) { 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"); .get("id");
Integer soleProprietorCodeValueId = (Integer) CodeHelper
.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
LOG.info( LOG.info(
"---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
@@ -162,29 +155,27 @@ public class ClientHelper {
getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "clientId"); getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "clientId");
} }
public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientType, String jsonAttributeToGetBack) { final Integer clientType, String jsonAttributeToGetBack) {
final String activationDate = "04 March 2011"; final String activationDate = "04 March 2011";
final String officeId = "1"; final String officeId = "1";
LOG.info( LOG.info(
"---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------"); "---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
public static Object assignStaffToClient(final RequestSpecification requestSpec, public static Object assignStaffToClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, final String staffId) { final String clientId, final String staffId) {
final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER
+ Utils.TENANT_IDENTIFIER + "&command=assignStaff"; + "&command=assignStaff";
LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------"); LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes");
assignStaffToClientAsJson(staffId), "changes");
} }
public static Integer getClientsStaffId(final RequestSpecification requestSpec, public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId) { final String clientId) {
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId"); return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
} }
@@ -283,8 +274,7 @@ public class ClientHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, final String clientType) {
final String clientType) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("officeId", officeId); map.put("officeId", officeId);
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5)); map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
@@ -306,17 +296,16 @@ public class ClientHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer generatedClientID) { final Integer generatedClientID) {
LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id"); final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT"); assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT");
} }
public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId,
final String clientId, final String jsonReturn) { final String jsonReturn) {
final String GET_CLIENT_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER; final String GET_CLIENT_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------GET A CLIENT---------------------------------------------"); LOG.info("---------------------------------GET A CLIENT---------------------------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn); return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn);
@@ -325,8 +314,8 @@ public class ClientHelper {
/* Client status is a map.So adding SuppressWarnings */ /* Client status is a map.So adding SuppressWarnings */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId) { final String clientId) {
return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status"); return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status");
} }
@@ -343,8 +332,7 @@ public class ClientHelper {
Integer clientClosureCodeId = (Integer) code.get("id"); Integer clientClosureCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientClosureReason" */ /* Retrieve/Create Code Values for the Code "ClientClosureReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, this.responseSpec);
this.responseSpec);
Integer closureReasonId = (Integer) codeValue.get("id"); Integer closureReasonId = (Integer) codeValue.get("id");
map.put("closureReasonId", closureReasonId.toString()); map.put("closureReasonId", closureReasonId.toString());
@@ -399,8 +387,8 @@ public class ClientHelper {
Integer clientRejectionReasonCodeId = (Integer) code.get("id"); Integer clientRejectionReasonCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientRejectReason" */ /* Retrieve/Create Code Values for the Code "ClientRejectReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId, HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId, this.requestSpec,
this.requestSpec, this.responseSpec); this.responseSpec);
Integer rejectionReasonId = (Integer) codeValue.get("id"); Integer rejectionReasonId = (Integer) codeValue.get("id");
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
@@ -431,8 +419,8 @@ public class ClientHelper {
Integer clientWithdrawReasonCodeId = (Integer) code.get("id"); Integer clientWithdrawReasonCodeId = (Integer) code.get("id");
/* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */ /* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, this.requestSpec,
this.requestSpec, this.responseSpec); this.responseSpec);
Integer withdrawalReasonId = (Integer) codeValue.get("id"); Integer withdrawalReasonId = (Integer) codeValue.get("id");
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
@@ -479,20 +467,17 @@ public class ClientHelper {
public HashMap<String, Object> closeClient(final Integer clientId) { public HashMap<String, Object> closeClient(final Integer clientId) {
LOG.info("--------------------------------- CLOSE CLIENT -------------------------------"); LOG.info("--------------------------------- CLOSE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
clientId);
} }
public HashMap<String, Object> reactivateClient(final Integer clientId) { public HashMap<String, Object> reactivateClient(final Integer clientId) {
LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
getReactivateClientAsJSON(), clientId);
} }
public HashMap<String, Object> rejectClient(final Integer clientId) { public HashMap<String, Object> rejectClient(final Integer clientId) {
LOG.info("--------------------------------- REJECT CLIENT -------------------------------"); LOG.info("--------------------------------- REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
clientId);
} }
public HashMap<String, Object> activateClient(final Integer clientId) { public HashMap<String, Object> activateClient(final Integer clientId) {
@@ -503,8 +488,7 @@ public class ClientHelper {
public HashMap<String, Object> withdrawClient(final Integer clientId) { public HashMap<String, Object> withdrawClient(final Integer clientId) {
LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------"); LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
getWithdrawClientAsJSON(), clientId);
} }
private String createClientOperationURL(final String command, final Integer clientId) { private String createClientOperationURL(final String command, final Integer clientId) {
@@ -523,113 +507,102 @@ public class ClientHelper {
getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId); getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId);
} }
public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId, public ArrayList<HashMap<String, Object>> undoRejectedclient(final Integer clientId, final String jsonAttributeToGetBack,
final String jsonAttributeToGetBack, final String rejectedDate) { final String rejectedDate) {
LOG.info("----------------------------------UNDO REJECT CLIENT ----------------------------------"); LOG.info("----------------------------------UNDO REJECT CLIENT ----------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId), return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId),
getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack); getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack);
} }
public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId, public ArrayList<HashMap<String, Object>> undoWithdrawclient(final Integer clientId, final String jsonAttributeToGetBack,
final String jsonAttributeToGetBack, final String rejectedDate) { final String rejectedDate) {
LOG.info("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------"); LOG.info("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------");
return performClientActionsWithValidationErrors( return performClientActionsWithValidationErrors(createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId),
getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack); getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack);
} }
public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId, public ArrayList<HashMap<String, Object>> activateClient(final Integer clientId, final String jsonAttributeToGetBack) {
final String jsonAttributeToGetBack) {
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId),
getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack); getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack);
} }
public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId, public HashMap<String, Object> activateClientWithDiffDateOption(final Integer clientId, final String activationDate) {
final String activationDate) {
LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------"); LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(activationDate),
getActivateClientAsJSON(activationDate), clientId); clientId);
} }
private ArrayList<HashMap<String, Object>> performClientActionsWithValidationErrors(final String postURLForClient, private ArrayList<HashMap<String, Object>> performClientActionsWithValidationErrors(final String postURLForClient,
final String jsonToBeSent, final String jsonAttributeToGetBack) { final String jsonToBeSent, final String jsonAttributeToGetBack) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
final Integer clientId) { Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS);
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
CommonConstants.RESPONSE_STATUS);
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec,
String.valueOf(clientId));
return response; return response;
} }
public static Integer addChargesForClient(final RequestSpecification requestSpec, public static Integer addChargesForClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientId, final String request) { final Integer clientId, final String request) {
LOG.info("--------------------------------- ADD CHARGES FOR Client --------------------------------"); LOG.info("--------------------------------- ADD CHARGES FOR Client --------------------------------");
final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public static String payChargesForClients(final RequestSpecification requestSpec, public static String payChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId, final Integer clientId, final Integer clientChargeId, final String json) {
final String json) {
LOG.info("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------"); LOG.info("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=paycharge&"
+ "?command=paycharge&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return response.get("transactionId") != null ? response.get("transactionId").toString() : null; return response.get("transactionId") != null ? response.get("transactionId").toString() : null;
} }
public static String waiveChargesForClients(final RequestSpecification requestSpec, public static String waiveChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId, final Integer clientId, final Integer clientChargeId, final String json) {
final String json) {
LOG.info("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------"); LOG.info("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=waive&"
+ "?command=waive&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
return response.get("transactionId").toString(); return response.get("transactionId").toString();
} }
public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, String clientChargeId) { final String clientId, String clientChargeId) {
LOG.info("---------------------------------UNDO TRANSACTION---------------------------------------------"); LOG.info("---------------------------------UNDO TRANSACTION---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId + "?command=undo&"
+ "?command=undo&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", ""); final HashMap<?, ?> response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", "");
return (Integer) response.get("resourceId"); return (Integer) response.get("resourceId");
} }
public static Object getClientCharge(final RequestSpecification requestSpec, public static Object getClientCharge(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, final String clientChargeId) { final String clientId, final String clientChargeId) {
LOG.info("---------------------------------GET CLIENT CHARGE---------------------------------------------"); LOG.info("---------------------------------GET CLIENT CHARGE---------------------------------------------");
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?" final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding"); return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding");
} }
public static Boolean getClientTransactions(final RequestSpecification requestSpec, public static Boolean getClientTransactions(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String clientId, final String transactionId) { final String clientId, final String transactionId) {
LOG.info( LOG.info("---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------");
"---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------"); final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + "?"
final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + Utils.TENANT_IDENTIFIER;
+ "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed"); return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed");
} }
public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException { public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel"); requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate" byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate" + "?"
+ "?" + Utils.TENANT_IDENTIFIER + "&legalFormType=" + clientsEntity + "&dateFormat=" + dateFormat); + Utils.TENANT_IDENTIFIER + "&legalFormType=" + clientsEntity + "&dateFormat=" + dateFormat);
InputStream inputStream = new ByteArrayInputStream(byteArray); InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook = new HSSFWorkbook(inputStream); Workbook workbook = new HSSFWorkbook(inputStream);
return workbook; return workbook;
@@ -638,8 +611,7 @@ public class ClientHelper {
public String getOutputTemplateLocation(final String importDocumentId) { public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec, return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
"/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
importDocumentId);
} }
public String importClientEntityTemplate(File file) { public String importClientEntityTemplate(File file) {
@@ -647,8 +619,7 @@ public class ClientHelper {
String dateFormat = "dd MMMM yyyy"; String dateFormat = "dd MMMM yyyy";
String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString(); String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString();
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec, responseSpec, return Utils.performServerTemplatePost(requestSpec, responseSpec, CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale, legalFormType, file, locale, dateFormat);
dateFormat);
} }
} }
@@ -18,7 +18,6 @@
*/ */
package org.apache.fineract.integrationtests.common; package org.apache.fineract.integrationtests.common;
public interface CommonConstants { public interface CommonConstants {
public final static String LOCALE = "en"; public final static String LOCALE = "en";
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes", "unchecked" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class CurrenciesHelper { public class CurrenciesHelper {
private final static Logger LOG = LoggerFactory.getLogger(CurrenciesHelper.class); private final static Logger LOG = LoggerFactory.getLogger(CurrenciesHelper.class);
private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies"; private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies";
@@ -57,9 +58,7 @@ public class CurrenciesHelper {
final String code) { final String code) {
ArrayList<CurrencyDomain> currenciesList = getAllCurrencies(requestSpec, responseSpec); ArrayList<CurrencyDomain> currenciesList = getAllCurrencies(requestSpec, responseSpec);
for (CurrencyDomain e : currenciesList) { for (CurrencyDomain e : currenciesList) {
if (e.getCode().equals(code)) { if (e.getCode().equals(code)) { return e; }
return e;
}
} }
return null; return null;
} }
@@ -75,7 +74,7 @@ public class CurrenciesHelper {
private static String currenciesToJSON(final ArrayList<String> currencies) { private static String currenciesToJSON(final ArrayList<String> currencies) {
HashMap map = new HashMap<>(); HashMap map = new HashMap<>();
map.put("currencies", currencies); map.put("currencies", currencies);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
} }
@@ -57,8 +57,8 @@ public class CurrencyDomain implements Comparable<CurrencyDomain> {
super(); super();
} }
private CurrencyDomain(final String code, final String name, final int decimalPlaces, final String displaySymbol, private CurrencyDomain(final String code, final String name, final int decimalPlaces, final String displaySymbol, final String nameCode,
final String nameCode, final String displayLabel) { final String displayLabel) {
super(); super();
this.code = code; this.code = code;
this.name = name; this.name = name;
@@ -135,9 +135,7 @@ public class CurrencyDomain implements Comparable<CurrencyDomain> {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { return true; } if (obj == this) { return true; }
if (!(obj instanceof CurrencyDomain)) { if (!(obj instanceof CurrencyDomain)) { return false; }
return false;
}
CurrencyDomain cd = (CurrencyDomain) obj; CurrencyDomain cd = (CurrencyDomain) obj;
@@ -29,27 +29,27 @@ public class ExternalServicesConfigurationHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName( public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(final RequestSpecification requestSpec,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final ResponseSpecification responseSpec, final String serviceName) {
final String serviceName) { final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?"
final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + Utils.TENANT_IDENTIFIER;
+ serviceName + "?" + Utils.TENANT_IDENTIFIER; // system.out.println("------------------------ RETRIEVING GLOBAL
// system.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION // CONFIGURATION
// BY ID -------------------------"); // BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, "");
} }
public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec, public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) { final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) {
final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?"
+ "?" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------UPDATE VALUE FOR GLOBAL // system.out.println("---------------------------------UPDATE VALUE FOR
// GLOBAL
// CONFIG---------------------------------------------"); // CONFIG---------------------------------------------");
HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL, HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL,
updateExternalServicesConfigUpdateValueAsJSON(name, value), ""); updateExternalServicesConfigUpdateValueAsJSON(name, value), "");
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class GlobalConfigurationHelper { public class GlobalConfigurationHelper {
private final static Logger LOG = LoggerFactory.getLogger(GlobalConfigurationHelper.class); private final static Logger LOG = LoggerFactory.getLogger(GlobalConfigurationHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -38,11 +39,13 @@ public class GlobalConfigurationHelper {
this.responseSpec = responseSpec; 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; final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------"); LOG.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------");
final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, ""); final HashMap<String, ArrayList<HashMap>> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL,
return response.get("globalConfiguration"); "");
return response.get("globalConfiguration");
} }
public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, 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, ""); 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(); final ArrayList<HashMap> defaults = getAllDefaultGlobalConfigurations();
for (HashMap configDefault : defaults) { for (HashMap configDefault : defaults) {
/** /**
* Cannot update trapDoor global configurations because * 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. * will be thrown.
*/ */
if ((Boolean)configDefault.get("trapDoor")) { if ((Boolean) configDefault.get("trapDoor")) {
continue; continue;
} }
// Currently only values and enabled flags are modified by the integration test suite. // Currently only values and enabled flags are modified by the
// If any other column is modified by the integration test suite in the future, it needs to be reset here. // integration test suite.
final Integer configDefaultId = (Integer)configDefault.get("id"); // If any other column is modified by the integration test suite in
final Integer configDefaultValue = (Integer)configDefault.get("value"); // 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()); 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> expectedGlobalConfigurations = getAllDefaultGlobalConfigurations();
ArrayList<HashMap> actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec); ArrayList<HashMap> actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec);
@@ -92,19 +100,26 @@ public class GlobalConfigurationHelper {
Assertions.assertEquals(expectedGlobalConfiguration.get("id"), actualGlobalConfiguration.get("id")); Assertions.assertEquals(expectedGlobalConfiguration.get("id"), actualGlobalConfiguration.get("id"));
final String assertionFailedMessage = "Assertion failed for configID:<" + expectedGlobalConfiguration.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("name"), actualGlobalConfiguration.get("name"), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.get("value"), assertionFailedMessage); Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.get("value"),
Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.get("enabled"), assertionFailedMessage); assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.get("trapDoor"), 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. * Helper method to get the current default instance data of the
* Used to reset and verify that no global configuration affects state between integration tests. * /configurations endpoint. Used to reset and verify that no global
* @see <a href="https://issues.apache.org/jira/browse/FINERACT-722">FINERACT-722</a> * configuration affects state between integration tests.
* 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 * @see <a href=
* integration test infrastructure for transaction commits and rollbacks. * "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() { private static ArrayList<HashMap> getAllDefaultGlobalConfigurations() {
@@ -370,41 +385,42 @@ public class GlobalConfigurationHelper {
} }
public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec, public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) { final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled,
final String jsonAttributeToGetBack) {
final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------"); LOG.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, updatePasswordResetDaysGlobalConfigAsJSON(value, enabled),
updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack); jsonAttributeToGetBack);
} }
public static String updateGlobalConfigUpdateValueAsJSON(final String value) { public static String updateGlobalConfigUpdateValueAsJSON(final String value) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("value", value); map.put("value", value);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String updatePasswordResetDaysGlobalConfigAsJSON(final String value, final String enabled) { public static String updatePasswordResetDaysGlobalConfigAsJSON(final String value, final String enabled) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
if(value != null){ if (value != null) {
map.put("value", value); map.put("value", value);
} }
map.put("enabled", enabled); map.put("enabled", enabled);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) { public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) {
final HashMap<String, Boolean> map = new HashMap<String, Boolean>(); final HashMap<String, Boolean> map = new HashMap<String, Boolean>();
map.put("enabled", enabled); map.put("enabled", enabled);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) { public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("cacheType", cacheType); map.put("cacheType", cacheType);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -70,25 +70,25 @@ public class GroupHelper {
jsonAttributeToGetBack); jsonAttributeToGetBack);
} }
public static Integer createGroupPendingWithDatatable(final RequestSpecification requestSpec, public static Integer createGroupPendingWithDatatable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String registeredTableName) { final String registeredTableName) {
LOG.info("-------------------------- CREATING A GROUP WITH DATATABLES --------------------------------"); LOG.info("-------------------------- CREATING A GROUP WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL, getTestGroupWithDatatableAsJson(registeredTableName),
getTestGroupWithDatatableAsJson(registeredTableName), "groupId"); "groupId");
} }
public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final String clientMember) { final String groupId, final String clientMember) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?command=associateClients&"
+ "?command=associateClients&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------Associate Client To A GROUP---------------------------------------------"); LOG.info("---------------------------------Associate Client To A GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
} }
public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final String clientMember) { final String groupId, final String clientMember) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?command=disassociateClients&"
+ "?command=disassociateClients&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------Disassociate Client To A GROUP---------------------------------------------"); LOG.info("---------------------------------Disassociate Client To A GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId"); 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"); 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; final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("---------------------------------DELETE GROUP---------------------------------------------"); LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId"); 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){ public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff"; final Long staffId) {
final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER
+ "&command=assignStaff";
LOG.info("---------------------------------DELETE GROUP---------------------------------------------"); LOG.info("---------------------------------DELETE GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,assignStaffAsJSON(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 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) { public static String getTestGroupAsJSON(final boolean active, final String activationDate) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
@@ -173,21 +179,22 @@ public class GroupHelper {
LOG.debug("map : {}", map); LOG.debug("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String assignStaffAsJSON(final Long staffId) { public static String assignStaffAsJSON(final Long staffId) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
LOG.debug("map : {}", map); LOG.debug("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static String assignStaffAndInheritStaffForClientAccountsAsJSON(final String staffId) { public static String assignStaffAndInheritStaffForClientAccountsAsJSON(final String staffId) {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("staffId", staffId); map.put("staffId", staffId);
map.put("inheritStaffForClientAccounts","true"); map.put("inheritStaffForClientAccounts", "true");
LOG.debug("map : {}", map); LOG.debug("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedGroupID) { final Integer generatedGroupID) {
LOG.info("------------------------------CHECK GROUP DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK GROUP DETAILS------------------------------------\n");
@@ -216,8 +223,8 @@ public class GroupHelper {
final Integer generatedGroupID, final Integer groupMember) { final Integer generatedGroupID, final Integer groupMember) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP MEMBERS------------------------------------\n"); LOG.info("------------------------------CHECK GROUP MEMBERS------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&"
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers"); list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
LOG.debug("the list of verifyEmptyGroupMembers : {} ", list); LOG.debug("the list of verifyEmptyGroupMembers : {} ", list);
assertTrue(list.toString().contains("id=" + groupMember.toString()), "ERROR IN GROUP MEMBER"); assertTrue(list.toString().contains("id=" + groupMember.toString()), "ERROR IN GROUP MEMBER");
@@ -227,8 +234,8 @@ public class GroupHelper {
final Integer generatedGroupID) { final Integer generatedGroupID) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n"); LOG.info("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n");
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&"
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers"); list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
LOG.debug("the list of verifyEmptyGroupMembers : {} ", list); LOG.debug("the list of verifyEmptyGroupMembers : {} ", list);
assertEquals(list, null, "GROUP MEMBER LIST NOT EMPTY"); 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"); assertFalse(list.toString().contains("id=" + generatedGroupID.toString()), "GROUP NOT DELETED");
} }
//Glim_Gsim_testing // Glim_Gsim_testing
public static List<String> verifyRetrieveGlimAccountsByGroupId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static List<String> verifyRetrieveGlimAccountsByGroupId(final RequestSpecification requestSpec,
final Integer groupID) { final ResponseSpecification responseSpec, final Integer groupID) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n"); 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"); list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "glimId");
LOG.debug("GlimId of Retrieved Account : {} ", list); LOG.debug("GlimId of Retrieved Account : {} ", list);
return list; return list;
} }
public static List<String> verifyRetrieveGlimAccountsByGlimId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static List<String> verifyRetrieveGlimAccountsByGlimId(final RequestSpecification requestSpec,
final Integer glimId) { final ResponseSpecification responseSpec, final Integer glimId) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n"); 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"); list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "glimId");
LOG.debug("GlimId of Retrieved Account: {} ", list); LOG.debug("GlimId of Retrieved Account: {} ", list);
return list; return list;
@@ -268,7 +275,7 @@ public class GroupHelper {
final Integer groupID) { final Integer groupID) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("------------------------------CHECK GROUP Retrieve Accounts------------------------------------\n"); 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"); list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "gsimId");
LOG.debug("GsimId Retrieved Accounts: {} ", list); LOG.debug("GsimId Retrieved Accounts: {} ", list);
return list; return list;
@@ -312,4 +319,4 @@ public class GroupHelper {
map.put("datatables", datatablesListMap); map.put("datatables", datatablesListMap);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
} }
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class HolidayHelper { public class HolidayHelper {
private final static Logger LOG = LoggerFactory.getLogger(HolidayHelper.class); private final static Logger LOG = LoggerFactory.getLogger(HolidayHelper.class);
private static final String HOLIDAYS_URL = "/fineract-provider/api/v1/holidays"; private static final String HOLIDAYS_URL = "/fineract-provider/api/v1/holidays";
private static final String CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
@@ -59,14 +60,14 @@ public class HolidayHelper {
map.put("repaymentsRescheduledTo", "08 April 2013"); map.put("repaymentsRescheduledTo", "08 April 2013");
map.put("reschedulingType", 2); map.put("reschedulingType", 2);
String HolidayCreateJson = new Gson().toJson(map); String HolidayCreateJson = new Gson().toJson(map);
LOG.info("{}",HolidayCreateJson); LOG.info("{}", HolidayCreateJson);
return HolidayCreateJson; return HolidayCreateJson;
} }
public static String getActivateHolidayDataAsJSON() { public static String getActivateHolidayDataAsJSON() {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
String activateHoliday = new Gson().toJson(map); String activateHoliday = new Gson().toJson(map);
LOG.info("{}",activateHoliday); LOG.info("{}", activateHoliday);
return activateHoliday; return activateHoliday;
} }
@@ -74,7 +75,8 @@ public class HolidayHelper {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOLIDAY_URL, getCreateHolidayDataAsJSON(), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOLIDAY_URL, getCreateHolidayDataAsJSON(), "resourceId");
} }
public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String holidayID) { public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String holidayID) {
final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER; final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId");
} }
@@ -87,4 +89,4 @@ public class HolidayHelper {
return response; return response;
} }
} }
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class HookHelper { public class HookHelper {
private final static Logger LOG = LoggerFactory.getLogger(HookHelper.class); private final static Logger LOG = LoggerFactory.getLogger(HookHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -43,8 +44,7 @@ public class HookHelper {
public Integer createHook(final String payloadURL) { public Integer createHook(final String payloadURL) {
LOG.info("---------------------------------CREATING A HOOK---------------------------------------------"); LOG.info("---------------------------------CREATING A HOOK---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId");
"resourceId");
} }
public String getTestHookAsJson(final String payloadURL) { public String getTestHookAsJson(final String payloadURL) {
@@ -62,7 +62,7 @@ public class HookHelper {
createOfficeEvent.put("entityName", "OFFICE"); createOfficeEvent.put("entityName", "OFFICE");
events.add(createOfficeEvent); events.add(createOfficeEvent);
map.put("events", events); map.put("events", events);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -88,8 +88,9 @@ public class HookHelper {
public void verifyUpdateHook(final String updateURL, final Long hookId) { public void verifyUpdateHook(final String updateURL, final Long hookId) {
LOG.info("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
ArrayList<HashMap<String, String>> map = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, this.responseSpec, GET_URL, "config"); ArrayList<HashMap<String, String>> map = Utils.<ArrayList<HashMap<String, String>>> performServerGet(this.requestSpec,
HashMap<String, String> hash = map.get(1); this.responseSpec, GET_URL, "config");
HashMap<String, String> hash = map.get(1);
assertEquals(updateURL, hash.get("fieldValue")); assertEquals(updateURL, hash.get("fieldValue"));
} }
@@ -97,8 +98,9 @@ public class HookHelper {
LOG.info("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n");
final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build(); ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build();
ArrayList<HashMap<String, String>> array = Utils.<ArrayList<HashMap<String, String>>>performServerGet(this.requestSpec, responseSpec404, GET_URL, "errors"); ArrayList<HashMap<String, String>> array = Utils.<ArrayList<HashMap<String, String>>> performServerGet(this.requestSpec,
responseSpec404, GET_URL, "errors");
HashMap<String, String> map = array.get(0); 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; import org.slf4j.LoggerFactory;
public class ImageHelper { public class ImageHelper {
private final static Logger LOG = LoggerFactory.getLogger(ImageHelper.class); private final static Logger LOG = LoggerFactory.getLogger(ImageHelper.class);
private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/"; private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/";
private static final String IMAGES_URI = "/images"; private static final String IMAGES_URI = "/images";
@@ -59,7 +60,8 @@ public class ImageHelper {
return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL); return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL);
} }
public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
Integer staffId) {
LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId");
@@ -24,6 +24,7 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
public class LoanRescheduleRequestHelper { public class LoanRescheduleRequestHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -24,6 +24,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class NotificationHelper { public class NotificationHelper {
private final static Logger LOG = LoggerFactory.getLogger(NotificationHelper.class); private final static Logger LOG = LoggerFactory.getLogger(NotificationHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -36,7 +37,7 @@ public class NotificationHelper {
} }
public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String jsonReturn) { final String jsonReturn) {
final String GET_NOTIFICATIONS_URL = NOTIFICATION_API_URL; final String GET_NOTIFICATIONS_URL = NOTIFICATION_API_URL;
LOG.info("-----------------------------GET NOTIFICATIONS-----------------------------------"); LOG.info("-----------------------------GET NOTIFICATIONS-----------------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_NOTIFICATIONS_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_NOTIFICATIONS_URL, "");
@@ -32,9 +32,8 @@ public class OfficeDomain {
private String[] openingDate; private String[] openingDate;
private String hierarchy; private String hierarchy;
private Builder(final int id, final String name, private Builder(final int id, final String name, final String nameDecorated, final String externalId, final String[] openingDate,
final String nameDecorated, final String externalId, final String hierarchy) {
final String[] openingDate, final String hierarchy) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.nameDecorated = nameDecorated; this.nameDecorated = nameDecorated;
@@ -44,8 +43,7 @@ public class OfficeDomain {
} }
public OfficeDomain build() { public OfficeDomain build() {
return new OfficeDomain(this.id, this.name, this.nameDecorated, return new OfficeDomain(this.id, this.name, this.nameDecorated, this.externalId, this.openingDate, this.hierarchy);
this.externalId, this.openingDate, this.hierarchy);
} }
} }
@@ -60,9 +58,8 @@ public class OfficeDomain {
super(); super();
} }
private OfficeDomain(final int id, final String name, private OfficeDomain(final int id, final String name, final String nameDecorated, final String externalId, final String[] openingDate,
final String nameDecorated, final String externalId, final String hierarchy) {
final String[] openingDate, final String hierarchy) {
super(); super();
this.id = id; this.id = id;
this.name = name; this.name = name;
@@ -80,11 +77,9 @@ public class OfficeDomain {
return new Gson().fromJson(jsonData, OfficeDomain.class); return new Gson().fromJson(jsonData, OfficeDomain.class);
} }
public static Builder create(final int id, final String name, public static Builder create(final int id, final String name, final String nameDecorated, final String externalId,
final String nameDecorated, final String externalId,
final String[] openingDate, final String hierarchy) { final String[] openingDate, final String hierarchy) {
return new Builder(id, name, nameDecorated, externalId, openingDate, return new Builder(id, name, nameDecorated, externalId, openingDate, hierarchy);
hierarchy);
} }
public int getId() { public int getId() {
@@ -139,20 +134,14 @@ public class OfficeDomain {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) { return true; }
return true;
}
if (!(obj instanceof OfficeDomain)) { if (!(obj instanceof OfficeDomain)) { return false; }
return false;
}
OfficeDomain od = (OfficeDomain) obj; OfficeDomain od = (OfficeDomain) obj;
if (this.id == od.getId() && this.name.equals(od.getName()) if (this.id == od.getId() && this.name.equals(od.getName()) && this.nameDecorated.equals(od.getName())
&& this.nameDecorated.equals(od.getName()) && this.externalId.equals(od.getExternalId()) && Arrays.equals(this.openingDate, od.getOpeningDate())
&& this.externalId.equals(od.getExternalId())
&& Arrays.equals(this.openingDate, od.getOpeningDate())
&& this.hierarchy.equals(od.getHierarchy())) { && this.hierarchy.equals(od.getHierarchy())) {
return true; return true;
} }
@@ -35,30 +35,26 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class OfficeHelper { public class OfficeHelper {
private final static Logger LOG = LoggerFactory.getLogger(OfficeHelper.class); private final static Logger LOG = LoggerFactory.getLogger(OfficeHelper.class);
private static final String OFFICE_URL = "/fineract-provider/api/v1/offices"; private static final String OFFICE_URL = "/fineract-provider/api/v1/offices";
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public OfficeHelper(final RequestSpecification requestSpec, public OfficeHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public OfficeDomain retrieveOfficeByID(int id) { public OfficeDomain retrieveOfficeByID(int id) {
Object get = Utils.performServerGet( Object get = Utils.performServerGet(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER, "");
requestSpec, responseSpec, OFFICE_URL + "/" + id + "?"
+ Utils.TENANT_IDENTIFIER, "");
final String json = new Gson().toJson(get); final String json = new Gson().toJson(get);
return new Gson().fromJson(json, new TypeToken<OfficeDomain>() { return new Gson().fromJson(json, new TypeToken<OfficeDomain>() {}.getType());
}.getType());
} }
public Integer createOffice(final String openingDate) { public Integer createOffice(final String openingDate) {
String json = getAsJSON(openingDate); String json = getAsJSON(openingDate);
return Utils.performServerPost(this.requestSpec, this.responseSpec, return Utils.performServerPost(this.requestSpec, this.responseSpec, OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
@@ -69,10 +65,9 @@ public class OfficeHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("openingDate", openingDate); map.put("openingDate", openingDate);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER,
+ "/" + id + "?" + Utils.TENANT_IDENTIFIER,
new Gson().toJson(map), "resourceId"); new Gson().toJson(map), "resourceId");
} }
@@ -83,30 +78,31 @@ public class OfficeHelper {
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en"); map.put("locale", "en");
map.put("openingDate", openingDate); map.put("openingDate", openingDate);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public String importOfficeTemplate(File file){ public String importOfficeTemplate(File file) {
String locale="en"; String locale = "en";
String dateFormat="dd MMMM yyyy"; String dateFormat = "dd MMMM yyyy";
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec,responseSpec,OFFICE_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER, return Utils.performServerTemplatePost(requestSpec, responseSpec, OFFICE_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
null,file,locale,dateFormat); null, file, locale, dateFormat);
} }
public String getOutputTemplateLocation(final String importDocumentId){ public String getOutputTemplateLocation(final String importDocumentId) {
requestSpec.header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_PLAIN); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?" return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec,
+Utils.TENANT_IDENTIFIER,importDocumentId); "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
} }
public Workbook getOfficeWorkBook(final String dateFormat) throws IOException { public Workbook getOfficeWorkBook(final String dateFormat) throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel"); requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
byte[] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,OFFICE_URL+"/downloadtemplate"+"?"+ byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec,
Utils.TENANT_IDENTIFIER+"&dateFormat="+dateFormat); OFFICE_URL + "/downloadtemplate" + "?" + Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
InputStream inputStream= new ByteArrayInputStream(byteArray); InputStream inputStream = new ByteArrayInputStream(byteArray);
Workbook workbook=new HSSFWorkbook(inputStream); Workbook workbook = new HSSFWorkbook(inputStream);
return workbook; return workbook;
} }
} }
@@ -27,8 +27,8 @@ public class PasswordPreferencesHelper {
private static final String PASSWORD_PREFERENCES_URL = "/fineract-provider/api/v1/passwordpreferences"; private static final String PASSWORD_PREFERENCES_URL = "/fineract-provider/api/v1/passwordpreferences";
public static Object updatePasswordPreferences(final RequestSpecification requestSpec, public static Object updatePasswordPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, String validationPolicyId) { String validationPolicyId) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------UPDATE PASSWORD // system.out.println("---------------------------------UPDATE PASSWORD
// PREFERENCE---------------------------------------------"); // PREFERENCE---------------------------------------------");
@@ -37,12 +37,14 @@ public class PasswordPreferencesHelper {
} }
public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec, public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,String invalidValidationPolicyId, String jsonAttributeToGetback) { final ResponseSpecification responseSpec, String invalidValidationPolicyId, String jsonAttributeToGetback) {
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
//system.out // system.out
//.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------"); // .println("---------------------------------UPDATE PASSWORD
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId), // PREFERENCES WITH INVALID
jsonAttributeToGetback); // ID-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL,
updatePreferencesWithInvalidId(invalidValidationPolicyId), jsonAttributeToGetback);
} }
public static String updatePreferencesAsJson(String validationPolicyId) { public static String updatePreferencesAsJson(String validationPolicyId) {
@@ -57,17 +59,15 @@ public class PasswordPreferencesHelper {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static int getActivePasswordPreference(final RequestSpecification requestSpec, public static int getActivePasswordPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) { return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id");
return Utils.performServerGet(requestSpec, responseSpec,
PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id");
} }
public static HashMap<String, Object> getAllPreferences(final RequestSpecification requestSpec, public static HashMap<String, Object> getAllPreferences(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER,
PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER, ""); "");
} }
@@ -29,21 +29,20 @@ import java.util.HashMap;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class PaymentTypeHelper { public class PaymentTypeHelper {
private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?" private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes"; private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes";
public static Integer createPaymentType(final RequestSpecification requestSpec, public static Integer createPaymentType(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String name, final String description, final String name, final String description, final Boolean isCashPayment, final Integer position) {
final Boolean isCashPayment, final Integer position) { // system.out.println("---------------------------------CREATING A
// system.out.println("---------------------------------CREATING A PAYMENT // PAYMENT
// TYPE---------------------------------------------"); // TYPE---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL, return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL,
getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId"); getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId");
} }
public static String getJsonToCreatePaymentType(final String name, final String description, public static String getJsonToCreatePaymentType(final String name, final String description, final Boolean isCashPayment,
final Boolean isCashPayment, final Integer position) { final Integer position) {
HashMap hm = new HashMap(); HashMap hm = new HashMap();
hm.put("name", name); hm.put("name", name);
if (description != null) { if (description != null) {
@@ -59,14 +58,12 @@ public class PaymentTypeHelper {
return new Gson().toJson(hm); return new Gson().toJson(hm);
} }
public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer generatedPaymentTypeID) { final Integer generatedPaymentTypeID) {
// system.out.println("------------------------------CHECK PAYMENT // system.out.println("------------------------------CHECK PAYMENT
// DETAILS------------------------------------\n"); // DETAILS------------------------------------\n");
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER; final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id");
final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL,
"id");
assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN CREATING THE PAYMENT TYPE"); assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN CREATING THE PAYMENT TYPE");
} }
@@ -77,25 +74,26 @@ public class PaymentTypeHelper {
// TYPE---------------------------------------------"); // TYPE---------------------------------------------");
Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, ""); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "");
final String jsonData = new Gson().toJson(get); final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() { return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() {}.getType());
}.getType());
} }
public static HashMap<String, String> updatePaymentType(final int id, HashMap request, public static HashMap<String, String> updatePaymentType(final int id, HashMap request, final RequestSpecification requestSpec,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------UPDATE PAYMENT TYPE " + // system.out.println("---------------------------------UPDATE PAYMENT
// TYPE " +
// id + "---------------------------------------------"); // id + "---------------------------------------------");
HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL, HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL, new Gson().toJson(request),
new Gson().toJson(request), "changes"); "changes");
return hash; return hash;
} }
public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec, public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
// system.out.println("---------------------------------DELETING PAYMENT TYPE " // system.out.println("---------------------------------DELETING PAYMENT
// TYPE "
// + id + "--------------------------------------------"); // + id + "--------------------------------------------");
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId"); return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId");
} }
@@ -49,6 +49,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class ProvisioningIntegrationTest { public class ProvisioningIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(ProvisioningIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(ProvisioningIntegrationTest.class);
private static final String NONE = "1"; private static final String NONE = "1";
private final static int LOANPRODUCTS_SIZE = 10; private final static int LOANPRODUCTS_SIZE = 10;
@@ -59,7 +60,7 @@ public class ProvisioningIntegrationTest {
private LoanTransactionHelper loanTransactionHelper; private LoanTransactionHelper loanTransactionHelper;
@BeforeEach @BeforeEach
public void setup() throws ParseException{ public void setup() throws ParseException {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
@@ -94,33 +95,33 @@ public class ProvisioningIntegrationTest {
} }
ArrayList categories = transactionHelper.retrieveAllProvisioningCategories(); ArrayList categories = transactionHelper.retrieveAllProvisioningCategories();
Assertions.assertTrue(categories.size() > 0) ; Assertions.assertTrue(categories.size() > 0);
Account liability = accountHelper.createLiabilityAccount() ; Account liability = accountHelper.createLiabilityAccount();
Account expense = accountHelper.createExpenseAccount() ; Account expense = accountHelper.createExpenseAccount();
Map requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense); Map requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense);
String provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria); String provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria);
Integer criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson); Integer criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson);
Assertions.assertNotNull(criteriaId); Assertions.assertNotNull(criteriaId);
Map newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId) ; Map newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId);
validateProvisioningCriteria(requestCriteria, newCriteria) ; validateProvisioningCriteria(requestCriteria, newCriteria);
ArrayList definitions = (ArrayList)newCriteria.get("definitions") ; ArrayList definitions = (ArrayList) newCriteria.get("definitions");
for(int i = 0 ; i < definitions.size(); i++) { for (int i = 0; i < definitions.size(); i++) {
Map criteriadefinition = (Map) definitions.get(i) ; Map criteriadefinition = (Map) definitions.get(i);
criteriadefinition.put("provisioningPercentage", Float.valueOf((float)20.0)) ; criteriadefinition.put("provisioningPercentage", Float.valueOf((float) 20.0));
} }
newCriteria.put("locale", "en"); newCriteria.put("locale", "en");
String updateCriteriaString = new Gson().toJson(newCriteria) ; String updateCriteriaString = new Gson().toJson(newCriteria);
Integer criteriaId1 = transactionHelper.updateProvisioningCriteria(criteriaId, updateCriteriaString) ; Integer criteriaId1 = transactionHelper.updateProvisioningCriteria(criteriaId, updateCriteriaString);
Map updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1) ; Map updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1);
validateProvisioningCriteria(newCriteria, updatedCriteria) ; validateProvisioningCriteria(newCriteria, updatedCriteria);
transactionHelper.deleteProvisioningCriteria(criteriaId1) ; transactionHelper.deleteProvisioningCriteria(criteriaId1);
categories = transactionHelper.retrieveAllProvisioningCategories(); categories = transactionHelper.retrieveAllProvisioningCategories();
liability = accountHelper.createLiabilityAccount() ; liability = accountHelper.createLiabilityAccount();
expense = accountHelper.createExpenseAccount() ; expense = accountHelper.createExpenseAccount();
requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense); requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense);
provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria); provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria);
criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson); criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson);
@@ -130,58 +131,58 @@ public class ProvisioningIntegrationTest {
Integer provisioningEntryId = transactionHelper.createProvisioningEntries(provisioningEntryJson); Integer provisioningEntryId = transactionHelper.createProvisioningEntries(provisioningEntryJson);
Assertions.assertNotNull(provisioningEntryId); Assertions.assertNotNull(provisioningEntryId);
transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, "") ; transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, "");
transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, "") ; transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, "");
Map entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId) ; Map entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId);
Assertions.assertTrue((Boolean)entry.get("journalEntry")) ; Assertions.assertTrue((Boolean) entry.get("journalEntry"));
Map provisioningEntry = transactionHelper.retrieveProvisioningEntries(provisioningEntryId) ; Map provisioningEntry = transactionHelper.retrieveProvisioningEntries(provisioningEntryId);
Assertions.assertTrue(((ArrayList)provisioningEntry.get("pageItems")).size() > 0) ; Assertions.assertTrue(((ArrayList) provisioningEntry.get("pageItems")).size() > 0);
} }
private void validateProvisioningCriteria(Map requestCriteria, Map newCriteria) { private void validateProvisioningCriteria(Map requestCriteria, Map newCriteria) {
//criteria name validation // criteria name validation
String requestCriteriaName = (String)requestCriteria.get("criteriaName") ; String requestCriteriaName = (String) requestCriteria.get("criteriaName");
String criteriaName = (String)newCriteria.get("criteriaName") ; String criteriaName = (String) newCriteria.get("criteriaName");
Assertions.assertEquals(criteriaName, requestCriteriaName) ; Assertions.assertEquals(criteriaName, requestCriteriaName);
//loan products validation // loan products validation
ArrayList requestProducts = (ArrayList)requestCriteria.get("loanProducts") ; ArrayList requestProducts = (ArrayList) requestCriteria.get("loanProducts");
ArrayList products = (ArrayList)newCriteria.get("loanProducts") ; ArrayList products = (ArrayList) newCriteria.get("loanProducts");
Assertions.assertEquals(products.size(), requestProducts.size()) ; Assertions.assertEquals(products.size(), requestProducts.size());
ArrayList requestedDefinitions = (ArrayList)requestCriteria.get("definitions") ; ArrayList requestedDefinitions = (ArrayList) requestCriteria.get("definitions");
ArrayList newdefintions = (ArrayList) newCriteria.get("definitions") ; ArrayList newdefintions = (ArrayList) newCriteria.get("definitions");
Assertions.assertEquals(newdefintions.size(), requestedDefinitions.size()) ; Assertions.assertEquals(newdefintions.size(), requestedDefinitions.size());
for(int i = 0 ; i < newdefintions.size() ; i++) { for (int i = 0; i < newdefintions.size(); i++) {
Map requestedMap = (Map)requestedDefinitions.get(i) ; Map requestedMap = (Map) requestedDefinitions.get(i);
Object requestedCategoryId = requestedMap.get("categoryId") ; Object requestedCategoryId = requestedMap.get("categoryId");
boolean found = false ; boolean found = false;
for(int j = 0 ; j < newdefintions.size(); j++) { for (int j = 0; j < newdefintions.size(); j++) {
Map newMap = (Map)newdefintions.get(j) ; Map newMap = (Map) newdefintions.get(j);
Object newCategoryId = newMap.get("categoryId") ; Object newCategoryId = newMap.get("categoryId");
if(requestedCategoryId.equals(newCategoryId)) { if (requestedCategoryId.equals(newCategoryId)) {
found = true ; found = true;
checkProperty("categoryId", requestedMap, newMap) ; checkProperty("categoryId", requestedMap, newMap);
checkProperty("categoryName", requestedMap, newMap) ; checkProperty("categoryName", requestedMap, newMap);
checkProperty("minAge", requestedMap, newMap) ; checkProperty("minAge", requestedMap, newMap);
checkProperty("maxAge", requestedMap, newMap) ; checkProperty("maxAge", requestedMap, newMap);
checkProperty("provisioningPercentage", requestedMap, newMap) ; checkProperty("provisioningPercentage", requestedMap, newMap);
checkProperty("liabilityAccount", requestedMap, newMap) ; checkProperty("liabilityAccount", requestedMap, newMap);
checkProperty("expenseAccount", requestedMap, newMap) ; checkProperty("expenseAccount", requestedMap, newMap);
break ; //internal loop break; // internal loop
} }
} }
if(!found) { if (!found) {
Assertions.fail("No Category found with Id:" + requestedCategoryId); Assertions.fail("No Category found with Id:" + requestedCategoryId);
} }
} }
} }
private void checkProperty(String propertyName, Map requestMap, Map newMap) { private void checkProperty(String propertyName, Map requestMap, Map newMap) {
Object requested = requestMap.get(propertyName) ; Object requested = requestMap.get(propertyName);
Object modified = newMap.get(propertyName) ; Object modified = newMap.get(propertyName);
Assertions.assertEquals(requested, modified) ; Assertions.assertEquals(requested, modified);
} }
private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
@@ -227,19 +228,19 @@ public class ProvisioningIntegrationTest {
private boolean isAlreadyProvisioningEntriesCreated() throws ParseException { private boolean isAlreadyProvisioningEntriesCreated() throws ParseException {
ProvisioningTransactionHelper transactionHelper = new ProvisioningTransactionHelper(requestSpec, responseSpec); ProvisioningTransactionHelper transactionHelper = new ProvisioningTransactionHelper(requestSpec, responseSpec);
Map entries = transactionHelper.retrieveAllProvisioningEntries() ; Map entries = transactionHelper.retrieveAllProvisioningEntries();
ArrayList<Map> pageItems = (ArrayList)entries.get("pageItems") ; ArrayList<Map> pageItems = (ArrayList) entries.get("pageItems");
boolean provisioningetryAlreadyCreated = false ; boolean provisioningetryAlreadyCreated = false;
if(pageItems != null) { if (pageItems != null) {
for(Map item: pageItems) { for (Map item : pageItems) {
String date = (String)item.get("createdDate") ; String date = (String) item.get("createdDate");
DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy"); DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy");
Date date1 = formatter.parse(date) ; Date date1 = formatter.parse(date);
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy"); DateFormat simple = new SimpleDateFormat("dd MMMM yyyy");
String formattedString = simple.format(Utils.getLocalDateOfTenant().toDate()); String formattedString = simple.format(Utils.getLocalDateOfTenant().toDate());
Date currentDate = simple.parse(formattedString) ; Date currentDate = simple.parse(formattedString);
if(date1.getTime() == currentDate.getTime()) { if (date1.getTime() == currentDate.getTime()) {
provisioningetryAlreadyCreated = true ; provisioningetryAlreadyCreated = true;
break; break;
} }
} }
@@ -43,6 +43,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class SchedulerJobHelper { public class SchedulerJobHelper {
private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class); private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification response200Spec; private final ResponseSpecification response200Spec;
@@ -78,7 +79,7 @@ public class SchedulerJobHelper {
final String GET_SCHEDULER_JOB_BY_ID_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER; final String GET_SCHEDULER_JOB_BY_ID_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------"); LOG.info("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------");
final Map<String, Object> response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_JOB_BY_ID_URL, ""); final Map<String, Object> response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_JOB_BY_ID_URL, "");
LOG.info("{}",response.toString()); LOG.info("{}", response.toString());
assertNotNull(response); assertNotNull(response);
return response; return response;
} }
@@ -108,7 +109,7 @@ public class SchedulerJobHelper {
private static String updateSchedulerJobAsJSON(final boolean active) { private static String updateSchedulerJobAsJSON(final boolean active) {
final Map<String, String> map = new HashMap<>(); final Map<String, String> map = new HashMap<>();
map.put("active", Boolean.toString(active)); map.put("active", Boolean.toString(active));
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -133,12 +134,17 @@ public class SchedulerJobHelper {
return (Integer) allSchedulerJobsData.get(jobIndex).get("jobId"); 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. * 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 * @author Michael Vorburger.ch
*/ */
@@ -148,53 +154,54 @@ public class SchedulerJobHelper {
DateTimeFormatter df = DateTimeFormatter.ISO_INSTANT; // FINERACT-926 DateTimeFormatter df = DateTimeFormatter.ISO_INSTANT; // FINERACT-926
Instant beforeExecuteTime = now().truncatedTo(ChronoUnit.SECONDS); 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); updateSchedulerStatus(false);
// Executing Scheduler Job // Executing Scheduler Job
int jobId = getSchedulerJobIdByName(jobName); int jobId = getSchedulerJobIdByName(jobName);
runSchedulerJob(jobId); 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 -> { await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> {
String jobRunStartText = lastRunHistory.get("jobRunStartTime"); String jobRunStartText = lastRunHistory.get("jobRunStartTime");
if (jobRunStartText == null) { if (jobRunStartText == null) { return false; }
return false;
}
Instant jobRunStartTime = df.parse(jobRunStartText, Instant::from); Instant jobRunStartTime = df.parse(jobRunStartText, Instant::from);
return jobRunStartTime.equals(beforeExecuteTime) || jobRunStartTime.isAfter(beforeExecuteTime); return jobRunStartTime.equals(beforeExecuteTime) || jobRunStartTime.isAfter(beforeExecuteTime);
}); });
// Await JobDetailData.lastRunHistory [JobDetailHistoryData] jobRunEndTime to be both set and >= jobRunStartTime (or timeout) // Await JobDetailData.lastRunHistory [JobDetailHistoryData]
Map<String, String> finalLastRunHistory = await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> { // jobRunEndTime to be both set and >= jobRunStartTime (or timeout)
String jobRunEndText = lastRunHistory.get("jobRunEndTime"); Map<String, String> finalLastRunHistory = await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId),
if (jobRunEndText == null) { lastRunHistory -> {
return false; String jobRunEndText = lastRunHistory.get("jobRunEndTime");
} if (jobRunEndText == null) { return false; }
Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from); Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from);
Instant jobRunStartTime = df.parse(lastRunHistory.get("jobRunStartTime"), Instant::from); Instant jobRunStartTime = df.parse(lastRunHistory.get("jobRunStartTime"), Instant::from);
return jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime); return jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime);
}); });
// Verify triggerType // Verify triggerType
assertThat(finalLastRunHistory.get("triggerType"), is("application")); 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"); String status = finalLastRunHistory.get("status");
if (!status.equals("success")) { if (!status.equals("success")) {
fail("Job status is not success: " + finalLastRunHistory.toString()); 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") @SuppressWarnings("unchecked")
private Callable<Map<String, String>> jobLastRunHistorySupplier(int jobId) { private Callable<Map<String, String>> jobLastRunHistorySupplier(int jobId) {
return () -> { return () -> {
Map<String, Object> job = getSchedulerJobById(jobId); Map<String, Object> job = getSchedulerJobById(jobId);
if (job == null) { if (job == null) { return null; }
return null;
}
return (Map<String, String>) job.get("lastRunHistory"); return (Map<String, String>) job.get("lastRunHistory");
}; };
} }
@@ -26,8 +26,9 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@SuppressWarnings({"unused", "rawtypes", "unchecked" }) @SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class StandingInstructionsHelper { public class StandingInstructionsHelper {
private final static Logger LOG = LoggerFactory.getLogger(StandingInstructionsHelper.class); private final static Logger LOG = LoggerFactory.getLogger(StandingInstructionsHelper.class);
private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions"; private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions";
private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory"; private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory";
@@ -90,7 +91,7 @@ public class StandingInstructionsHelper {
map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS); map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS);
map.put("recurrenceOnMonthDay", monthDay); map.put("recurrenceOnMonthDay", monthDay);
String savingsApplicationJSON = new Gson().toJson(map); String savingsApplicationJSON = new Gson().toJson(map);
LOG.info("{}",savingsApplicationJSON); LOG.info("{}", savingsApplicationJSON);
return savingsApplicationJSON; return savingsApplicationJSON;
} }
@@ -113,13 +114,14 @@ public class StandingInstructionsHelper {
return response; 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 final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&transferType="
+ "&transferType=" + transferType; + transferType;
LOG.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}",STANDING_INSTRUCTIONS_HISTORY_URL); LOG.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}", STANDING_INSTRUCTIONS_HISTORY_URL);
final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec, final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec,
STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems"); STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems");
return response; return response;
} }
} }
@@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class SurveyHelper { public class SurveyHelper {
private final static Logger LOG = LoggerFactory.getLogger(SurveyHelper.class); private final static Logger LOG = LoggerFactory.getLogger(SurveyHelper.class);
private static final String FULFIL_SURVEY_URL = "/fineract-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER; private static final String FULFIL_SURVEY_URL = "/fineract-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER;
@@ -38,16 +39,16 @@ public class SurveyHelper {
public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String activationDate) { final String activationDate) {
LOG.info("---------------------------------FULFIL PPI ---------------------------------------------"); LOG.info("---------------------------------FULFIL PPI ---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec,FULFIL_SURVEY_URL, getTestPPIAsJSON(), "clientId"); return Utils.performServerPost(requestSpec, responseSpec, FULFIL_SURVEY_URL, getTestPPIAsJSON(), "clientId");
} }
public static String getTestPPIAsJSON() { public static String getTestPPIAsJSON() {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("date", "2014-05-19 00:00:00"); map.put("date", "2014-05-19 00:00:00");
map.put("ppi_household_members_cd_q1_householdmembers","107"); map.put("ppi_household_members_cd_q1_householdmembers", "107");
map.put("ppi_highestschool_cd_q2_highestschool","112"); map.put("ppi_highestschool_cd_q2_highestschool", "112");
map.put("ppi_businessoccupation_cd_q3_businessoccupation","116"); map.put("ppi_businessoccupation_cd_q3_businessoccupation", "116");
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en"); map.put("locale", "en");
map.put("ppi_habitablerooms_cd_q4_habitablerooms", "120"); 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_towels_cd_q9_towels", "134");
map.put("ppi_fryingpans_cd_q10_fryingpans", "138"); map.put("ppi_fryingpans_cd_q10_fryingpans", "138");
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer generatedClientID) { final Integer generatedClientID) {
LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER; final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?"
+ Utils.TENANT_IDENTIFIER;
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id"); final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id");
assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT"); assertEquals(generatedClientID, responseClientID, "ERROR IN CREATING THE CLIENT");
} }
}
}
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class TaxComponentHelper { public class TaxComponentHelper {
private final static Logger LOG = LoggerFactory.getLogger(TaxComponentHelper.class); private final static Logger LOG = LoggerFactory.getLogger(TaxComponentHelper.class);
private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/component?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/component?" + Utils.TENANT_IDENTIFIER;
@@ -43,7 +44,7 @@ public class TaxComponentHelper {
map.put("creditAccountType", Account.AccountType.LIABILITY.toString()); map.put("creditAccountType", Account.AccountType.LIABILITY.toString());
map.put("creditAcountId", String.valueOf(creditAccountId)); map.put("creditAcountId", String.valueOf(creditAccountId));
} }
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -61,4 +62,4 @@ public class TaxComponentHelper {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix); return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
} }
} }
@@ -29,13 +29,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class TaxGroupHelper { public class TaxGroupHelper {
private final static Logger LOG = LoggerFactory.getLogger(TaxGroupHelper.class); private final static Logger LOG = LoggerFactory.getLogger(TaxGroupHelper.class);
private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/group?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/group?" + Utils.TENANT_IDENTIFIER;
public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Collection<Integer> taxComponentIds) { final Collection<Integer> taxComponentIds) {
LOG.info("---------------------------------CREATING A TAX GROUP---------------------------------------------"); LOG.info("---------------------------------CREATING A TAX GROUP---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds), "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds),
"resourceId");
} }
public static String getTaxGroupAsJSON(final Collection<Integer> taxComponentIds) { public static String getTaxGroupAsJSON(final Collection<Integer> taxComponentIds) {
@@ -66,4 +68,4 @@ public class TaxGroupHelper {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix); 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); LOG.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL);
return; return;
} else { } else {
LOG.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, LOG.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, healthHttpStatus, attempt++);
healthHttpStatus, attempt++);
sleep(3); sleep(3);
} }
} catch (Exception e) { } catch (Exception e) {
LOG.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), LOG.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), attempt++);
attempt++);
lastException = e; lastException = e;
sleep(3); sleep(3);
} }
@@ -99,8 +97,7 @@ public class Utils {
LOG.error("{} still not reachable, giving up", HEALTH_URL, lastException); LOG.error("{} still not reachable, giving up", HEALTH_URL, lastException);
throw new AssertionError(HEALTH_URL + " not reachable", lastException); throw new AssertionError(HEALTH_URL + " not reachable", lastException);
} else { } else {
LOG.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, LOG.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, response.prettyPrint());
response.prettyPrint());
fail(HEALTH_URL + " returned " + response.prettyPrint()); fail(HEALTH_URL + " returned " + response.prettyPrint());
} }
} }
@@ -119,9 +116,8 @@ public class Utils {
try { try {
LOG.info("Logging in, for integration test..."); LOG.info("Logging in, for integration test...");
// system.out.println("-----------------------------------LOGIN-----------------------------------------"); // system.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.given().contentType(ContentType.JSON) String json = RestAssured.given().contentType(ContentType.JSON).body("{\"username\":\"mifos\", \"password\":\"password\"}")
.body("{\"username\":\"mifos\", \"password\":\"password\"}").expect().log().ifError().when() .expect().log().ifError().when().post(LOGIN_URL).asString();
.post(LOGIN_URL).asString();
assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false)); assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false));
String key = JsonPath.with(json).get("base64EncodedAuthenticationKey"); String key = JsonPath.with(json).get("base64EncodedAuthenticationKey");
assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false)); assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false));
@@ -136,63 +132,53 @@ public class Utils {
} }
} }
public static <T> T performServerGet(final RequestSpecification requestSpec, public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String getURL, final String jsonAttributeToGetBack) { final String getURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL) 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(); .andReturn().asString();
if (jsonAttributeToGetBack == null) { if (jsonAttributeToGetBack == null) { return (T) json; }
return (T) json;
}
return (T) from(json).get(jsonAttributeToGetBack); return (T) from(json).get(jsonAttributeToGetBack);
} }
public static String performGetTextResponse(final RequestSpecification requestSpec, public static <T> T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String getURL) { final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn() 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(); .asString();
}
public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String getURL) {
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn()
.asByteArray();
}
public static <T> T performServerPost(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String postURL, final String jsonBodyToSend,
final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().post(postURL).andReturn().asString();
if (jsonAttributeToGetBack == null) {
return (T) json;
}
return (T) from(json).get(jsonAttributeToGetBack); return (T) from(json).get(jsonAttributeToGetBack);
} }
public static <T> T performServerPut(final RequestSpecification requestSpec, public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String putURL, final String jsonBodyToSend, final String deleteURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
final String jsonAttributeToGetBack) { final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when()
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().put(putURL).andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String deleteURL, final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when()
.delete(deleteURL).andReturn().asString(); .delete(deleteURL).andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerDelete(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String deleteURL, final String jsonBodyToSend,
final String jsonAttributeToGetBack) {
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError()
.when().delete(deleteURL).andReturn().asString();
return (T) (jsonAttributeToGetBack == null ? json : from(json).get(jsonAttributeToGetBack)); return (T) (jsonAttributeToGetBack == null ? json : from(json).get(jsonAttributeToGetBack));
} }
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 oldFormat = new SimpleDateFormat("dd MMMMMM yyyy", Locale.US);
final SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd"); final SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
String reformattedStr = ""; String reformattedStr = "";
@@ -250,20 +236,19 @@ public class Utils {
return TimeZone.getTimeZone(TENANT_TIME_ZONE); return TimeZone.getTimeZone(TENANT_TIME_ZONE);
} }
public static String performServerTemplatePost(final RequestSpecification requestSpec, public static String performServerTemplatePost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String postURL, final String legalFormType, final File file, final String postURL, final String legalFormType, final File file, final String locale, final String dateFormat) {
final String locale, final String dateFormat) {
final String importDocumentId = given().spec(requestSpec).queryParam("legalFormType", legalFormType) final String importDocumentId = given().spec(requestSpec).queryParam("legalFormType", legalFormType).multiPart("file", file)
.multiPart("file", file).formParam("locale", locale).formParam("dateFormat", dateFormat).expect() .formParam("locale", locale).formParam("dateFormat", dateFormat).expect().spec(responseSpec).log().ifError().when()
.spec(responseSpec).log().ifError().when().post(postURL).andReturn().asString(); .post(postURL).andReturn().asString();
return importDocumentId; return importDocumentId;
} }
public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec, public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String getURL, final String importDocumentId) { final ResponseSpecification responseSpec, final String getURL, final String importDocumentId) {
final String templateLocation = given().spec(requestSpec).queryParam("importDocumentId", importDocumentId) final String templateLocation = given().spec(requestSpec).queryParam("importDocumentId", importDocumentId).expect()
.expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString(); .spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
return templateLocation.substring(1, templateLocation.length() - 1); return templateLocation.substring(1, templateLocation.length() - 1);
} }
} }
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class WorkingDaysHelper { public class WorkingDaysHelper {
private final static Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class); private final static Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class);
private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays"; private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays";
@@ -50,7 +51,7 @@ public class WorkingDaysHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false); map.put("extendTermForDailyRepayments", false);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -60,7 +61,7 @@ public class WorkingDaysHelper {
map.put("locale", "en"); map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false); map.put("extendTermForDailyRepayments", false);
LOG.info("map : {}" , map); LOG.info("map : {}", map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -69,7 +70,8 @@ public class WorkingDaysHelper {
return (int) workingDays.get("id"); 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, ""); 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 class Account {
public enum AccountType { public enum AccountType {
ASSET("1"), INCOME("4"), EXPENSE("5"), LIABILITY("2"), EQUITY("3"); ASSET("1"), INCOME("4"), EXPENSE("5"), LIABILITY("2"), EQUITY("3");
private final String accountValue; private final String accountValue;
@@ -40,22 +40,22 @@ public class AccountHelper {
public Account createAssetAccount() { public Account createAssetAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsAsset().build(); final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsAsset().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE); this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.ASSET); return new Account(accountID, Account.AccountType.ASSET);
} }
public Account createIncomeAccount() { public Account createIncomeAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsIncome().build(); final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsIncome().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE); this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.INCOME); return new Account(accountID, Account.AccountType.INCOME);
} }
public Account createExpenseAccount() { public Account createExpenseAccount() {
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsExpense().build(); final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsExpense().build();
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL, assetAccountJSON,
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE); this.GL_ACCOUNT_ID_RESPONSE);
return new Account(accountID, Account.AccountType.EXPENSE); return new Account(accountID, Account.AccountType.EXPENSE);
} }
@@ -68,7 +68,8 @@ public class AccountHelper {
public ArrayList getAccountingWithRunningBalances() { public ArrayList getAccountingWithRunningBalances() {
final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts?fetchRunningBalance=true"; final String GET_RUNNING_BALANCE_URL = "/fineract-provider/api/v1/glaccounts?fetchRunningBalance=true";
final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_RUNNING_BALANCE_URL, ""); final ArrayList<HashMap> accountRunningBalance = Utils.performServerGet(this.requestSpec, this.responseSpec,
GET_RUNNING_BALANCE_URL, "");
return accountRunningBalance; return accountRunningBalance;
} }
@@ -37,18 +37,19 @@ public class FinancialActivityAccountHelper {
public Object createFinancialActivityAccount(Integer financialActivityId, Integer glAccountId, public Object createFinancialActivityAccount(Integer financialActivityId, Integer glAccountId,
final ResponseSpecification responseSpecification, String jsonBack) { final ResponseSpecification responseSpecification, String jsonBack) {
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId); String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
return Utils.performServerPost(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?" return Utils.performServerPost(this.requestSpec, responseSpecification,
+ Utils.TENANT_IDENTIFIER, json, jsonBack); FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack);
} }
public Object updateFinancialActivityAccount(Integer financialActivityAccountId, Integer financialActivityId, Integer glAccountId, public Object updateFinancialActivityAccount(Integer financialActivityAccountId, Integer financialActivityId, Integer glAccountId,
final ResponseSpecification responseSpecification, String jsonBack) { final ResponseSpecification responseSpecification, String jsonBack) {
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId); String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
return Utils.performServerPut(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" return Utils.performServerPut(this.requestSpec, responseSpecification,
+ financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack); 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; final String url = FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpecification, url, ""); return Utils.performServerGet(requestSpec, responseSpecification, url, "");
} }
@@ -21,6 +21,7 @@ package org.apache.fineract.integrationtests.common.accounting;
public class JournalEntry { public class JournalEntry {
public enum TransactionType { public enum TransactionType {
CREDIT("CREDIT"), DEBIT("DEBIT"); CREDIT("CREDIT"), DEBIT("DEBIT");
private TransactionType(final String type) { private TransactionType(final String type) {
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class ChargesHelper { public class ChargesHelper {
private final static Logger LOG = LoggerFactory.getLogger(ChargesHelper.class); private final static Logger LOG = LoggerFactory.getLogger(ChargesHelper.class);
private static final String CHARGES_URL = "/fineract-provider/api/v1/charges"; private static final String CHARGES_URL = "/fineract-provider/api/v1/charges";
private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER; private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER;
@@ -168,14 +169,11 @@ public class ChargesHelper {
return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, final String amount) {
final String amount) { return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
return getLoanDisbursementJSON(chargeCalculationType, amount,
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount, public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount, final Integer paymentmode) {
final Integer paymentmode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE); map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE);
map.put("chargePaymentMode", paymentmode); map.put("chargePaymentMode", paymentmode);
@@ -187,18 +185,15 @@ public class ChargesHelper {
} }
public static String getLoanSpecifiedDueDateJSON() { public static String getLoanSpecifiedDueDateJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, ChargesHelper.PENALTY);
ChargesHelper.PENALTY);
} }
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, boolean penalty) {
boolean penalty) { return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, final boolean penalty,
final boolean penalty, final Integer paymentMode) { final Integer paymentMode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE); map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE);
map.put("chargePaymentMode", paymentMode); map.put("chargePaymentMode", paymentMode);
@@ -211,25 +206,22 @@ public class ChargesHelper {
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, final String amount,
final String amount, boolean penalty) { boolean penalty) {
return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanSpecifiedDueDateWithAccountTransferJSON() { public static String getLoanSpecifiedDueDateWithAccountTransferJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, ChargesHelper.PENALTY,
ChargesHelper.PENALTY, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, boolean penalty) {
boolean penalty) { return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty,
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
} }
public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, final boolean penalty,
final boolean penalty, final Integer paymentMode) { final Integer paymentMode) {
final HashMap<String, Object> map = populateDefaultsForLoan(); final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE); map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE);
map.put("chargePaymentMode", paymentMode); map.put("chargePaymentMode", paymentMode);
@@ -242,15 +234,13 @@ public class ChargesHelper {
return chargesCreateJson; return chargesCreateJson;
} }
public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, final String amount,
final String amount, boolean penalty) { boolean penalty) {
return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
public static String getLoanInstallmentFeeJSON() { public static String getLoanInstallmentFeeJSON() {
return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT, ChargesHelper.PENALTY);
ChargesHelper.PENALTY);
} }
public static String getShareAccountActivationChargeJson() { public static String getShareAccountActivationChargeJson() {
@@ -365,40 +355,36 @@ public class ChargesHelper {
return map; return map;
} }
public static Integer createCharges(final RequestSpecification requestSpec, public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String request) { final String request) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
} }
public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec, public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
final ResponseSpecification responseSpec) { return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec,
CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
} }
public static HashMap getChargeById(final RequestSpecification requestSpec, public static HashMap getChargeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer chargeId) { final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
} }
public static HashMap getChargeChanges(final RequestSpecification requestSpec, public static HashMap getChargeChanges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer chargeId) { final Integer chargeId) {
return Utils.performServerGet(requestSpec, responseSpec, return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public static HashMap updateCharges(final RequestSpecification requestSpec, public static HashMap updateCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer chargeId, final String request) { final Integer chargeId, final String request) {
return Utils.performServerPut(requestSpec, responseSpec, return Utils.performServerPut(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec, public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec,
final Integer chargeId) { final Integer chargeId) {
return Utils.performServerDelete(requestSpec, responseSpec, return Utils.performServerDelete(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER,
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static String getModifyChargeJSON() { public static String getModifyChargeJSON() {
@@ -496,10 +482,9 @@ public class ChargesHelper {
return chargesCreateJson; return chargesCreateJson;
} }
public static String applyCharge(RequestSpecification requestSpec, ResponseSpecification responseSpec, public static String applyCharge(RequestSpecification requestSpec, ResponseSpecification responseSpec, String chargeId, String json) {
String chargeId, String json) { return Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json,
return Utils.performServerPost(requestSpec, responseSpec, "status");
CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json, "status");
} }
} }
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositAccountHelper { public class FixedDepositAccountHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountHelper.class); private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; 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 FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts";
private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve"; private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve";
private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval"; private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval";
private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject"; private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject";
@@ -135,17 +135,16 @@ public class FixedDepositAccountHelper {
return fixedDepositAccountJson; return fixedDepositAccountJson;
} }
public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, final RequestSpecification requestSpec,
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final ResponseSpecification responseSpec) {
LOG.info("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------"); LOG.info("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------");
return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, fixedDepositAccountAsJson,
fixedDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final Integer accountID) { final Integer accountID) {
final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
LOG.info("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------"); LOG.info("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------");
return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, ""); return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, "");
} }
@@ -179,8 +178,8 @@ public class FixedDepositAccountHelper {
return annualInterestRate; return annualInterestRate;
} }
public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Integer depositPeriod,
Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval) { double interestPerDay, Integer compoundingInterval, Integer postingInterval) {
Float totalInterest = 0.0f; Float totalInterest = 0.0f;
Float interestEarned = 0.0f; Float interestEarned = 0.0f;
@@ -209,23 +208,22 @@ public class FixedDepositAccountHelper {
return principal; return principal;
} }
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom,
final String validFrom, final String validTo, final String penalInterestType, final String validTo, final String penalInterestType, final String submittedOnDate) {
final String submittedOnDate) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) // .withSubmittedOnDate(submittedOnDate) //
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, return Utils.performServerPut(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID,
final String accountID, final String submittedOnDate, final String validFrom, final String validTo, final String submittedOnDate, final String validFrom, final String validTo, final String numberOfDaysPerYear,
final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType, final String penalInterestType, final String interestCalculationType, final String interestCompoundingPeriodType,
final String interestCompoundingPeriodType, final String interestPostingPeriodType) { final String interestPostingPeriodType) {
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
.withSubmittedOnDate(submittedOnDate) // .withSubmittedOnDate(submittedOnDate) //
@@ -236,63 +234,51 @@ public class FixedDepositAccountHelper {
.build(clientID, productID, penalInterestType); .build(clientID, productID, penalInterestType);
return Utils.performServerPut(this.requestSpec, this.responseSpec, return Utils.performServerPut(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON,
fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
} }
public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) { public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) {
LOG.info( LOG.info("--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------");
"--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------"); return performFixedDepositApplicationActions(createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getApproveFixedDepositAccountAsJSON(approvedOnDate)); getApproveFixedDepositAccountAsJSON(approvedOnDate));
} }
public HashMap undoApproval(final Integer fixedDepositAccountID) { public HashMap undoApproval(final Integer fixedDepositAccountID) {
LOG.info( LOG.info("--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
"--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------");
final String undoBodyJson = "{'note':'UNDO APPROVAL'}"; final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(
createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), undoBodyJson);
undoBodyJson);
} }
public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) { public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) {
LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------"); LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getRejectedFixedDepositAsJSON(rejectedOnDate)); getRejectedFixedDepositAsJSON(rejectedOnDate));
} }
public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) { public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) {
LOG.info( LOG.info("--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
"--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------");
return performFixedDepositApplicationActions( return performFixedDepositApplicationActions(
createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate)); getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate));
} }
public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) { public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) {
LOG.info( LOG.info("---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------");
"---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------"); return performFixedDepositApplicationActions(createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
return performFixedDepositApplicationActions(
createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID),
getActivatedFixedDepositAccountAsJSON(activationDate)); getActivatedFixedDepositAccountAsJSON(activationDate));
} }
public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, final String jsonAttributeToGetBack) {
final String jsonAttributeToGetBack) { LOG.info("---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
LOG.info(
"---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------");
return Utils.performServerDelete(this.requestSpec, this.responseSpec, return Utils.performServerDelete(this.requestSpec, this.responseSpec,
FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) { public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) {
LOG.info( LOG.info("--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
"--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------");
return (Integer) performFixedDepositActions( return (Integer) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId), createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId),
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
@@ -305,21 +291,18 @@ public class FixedDepositAccountHelper {
getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
} }
public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate) {
final String closedOnDate) {
LOG.info("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------"); LOG.info("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------");
return (HashMap) performFixedDepositActions( return (HashMap) performFixedDepositActions(
createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId), createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId),
getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), ""); getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), "");
} }
public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, final String closureType,
final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) { final Integer toSavingsId, final String jsonAttributeToGetBack) {
LOG.info("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------"); LOG.info("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------");
return performFixedDepositActions( return performFixedDepositActions(createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId),
createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId), getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack);
getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId),
jsonAttributeToGetBack);
} }
private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) { private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) {
@@ -399,21 +382,18 @@ public class FixedDepositAccountHelper {
} }
private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) { private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) {
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent, private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent,
final String jsonAttributeToGetBack) { final String jsonAttributeToGetBack) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, jsonAttributeToGetBack);
jsonAttributeToGetBack);
} }
private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, final String jsonToBeSent) {
final String jsonToBeSent) {
HashMap status = null; HashMap status = null;
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDepositAction, jsonToBeSent,
postURLForFixedDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES); CommonConstants.RESPONSE_CHANGES);
if (response != null) { if (response != null) {
status = (HashMap) response.get("status"); status = (HashMap) response.get("status");
} }
@@ -421,8 +401,7 @@ public class FixedDepositAccountHelper {
} }
private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) { private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) {
return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+ Utils.TENANT_IDENTIFIER;
} }
public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec, public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec,
@@ -486,14 +465,12 @@ public class FixedDepositAccountHelper {
} }
private String getDepositAmount() { private String getDepositAmount() {
if (this.newDepositAmount == null) { if (this.newDepositAmount == null) { return DEPOSIT_AMOUNT; }
return DEPOSIT_AMOUNT;
}
return this.newDepositAmount; return this.newDepositAmount;
} }
public FixedDepositAccountHelper withMaturityInstructionId(Integer maturityInstructionId){ public FixedDepositAccountHelper withMaturityInstructionId(Integer maturityInstructionId) {
this.maturityInstructionId = maturityInstructionId; this.maturityInstructionId = maturityInstructionId;
return this; return this;
} }
} }
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class FixedDepositAccountStatusChecker { public class FixedDepositAccountStatusChecker {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountStatusChecker.class); private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountStatusChecker.class);
private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts"; private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts";
@@ -41,8 +42,7 @@ public class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------"); LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"), assertTrue(getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"), "FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE");
"FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
@@ -54,15 +54,13 @@ public class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------"); LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "rejected"), assertTrue(getStatus(fixedDepositStatusHashMap, "rejected"), "ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION");
"ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) {
LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------"); LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"), assertTrue(getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant"), "ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION");
"ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
@@ -78,28 +76,26 @@ public class FixedDepositAccountStatusChecker {
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final ResponseSpecification responseSpec, final String fixedDepositAccountID) { final String fixedDepositAccountID) {
final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?"
+ "?" + Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status"); return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status");
} }
public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "prematureClosed"), assertTrue(getStatus(fixedDepositStatusHashMap, "prematureClosed"), "ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT");
"ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) { public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------"); LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "matured"), assertTrue(getStatus(fixedDepositStatusHashMap, "matured"), "ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT");
"ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString()); LOG.info("{}", fixedDepositStatusHashMap.toString());
} }
private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) { private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) {
return (Boolean) fixedDepositStatusMap.get(fixedDepositStatusString); return (Boolean) fixedDepositStatusMap.get(fixedDepositStatusString);
} }
} }
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unused", "rawtypes" }) @SuppressWarnings({ "unused", "rawtypes" })
public class FixedDepositProductHelper { public class FixedDepositProductHelper {
private final static Logger LOG = LoggerFactory.getLogger(FixedDepositProductHelper.class); private final static Logger LOG = LoggerFactory.getLogger(FixedDepositProductHelper.class);
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -70,7 +71,6 @@ public class FixedDepositProductHelper {
private static final String WHOLE_TERM = "1"; private static final String WHOLE_TERM = "1";
private static final String TILL_PREMATURE_WITHDRAWAL = "2"; private static final String TILL_PREMATURE_WITHDRAWAL = "2";
private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6); private String name = Utils.randomNameGenerator("FIXED_DEPOSIT_PRODUCT_", 6);
private String shortName = Utils.randomNameGenerator("", 4); private String shortName = Utils.randomNameGenerator("", 4);
private String description = Utils.randomNameGenerator("", 20); private String description = Utils.randomNameGenerator("", 20);
@@ -142,14 +142,12 @@ public class FixedDepositProductHelper {
map.put("taxGroupId", taxGroupId); map.put("taxGroupId", taxGroupId);
} }
if (this.accountingRule.equals(CASH_BASED)) { if (this.accountingRule.equals(CASH_BASED)) {
map.putAll(getAccountMappingForCashBased()); map.putAll(getAccountMappingForCashBased());
} }
String FixedDepositProductCreateJson = new Gson().toJson(map); String FixedDepositProductCreateJson = new Gson().toJson(map);
LOG.info("{}",FixedDepositProductCreateJson); LOG.info("{}", FixedDepositProductCreateJson);
return FixedDepositProductCreateJson; return FixedDepositProductCreateJson;
} }
@@ -393,7 +391,6 @@ public class FixedDepositProductHelper {
return this; return this;
} }
private Map<String, String> getAccountMappingForCashBased() { private Map<String, String> getAccountMappingForCashBased() {
final Map<String, String> map = new HashMap<>(); final Map<String, String> map = new HashMap<>();
if (accountList != null) { if (accountList != null) {
@@ -428,10 +425,11 @@ public class FixedDepositProductHelper {
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------"); LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------");
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_PRODUCT_URL + "?" final ArrayList response = Utils.performServerGet(requestSpec, responseSpec,
+ Utils.TENANT_IDENTIFIER, ""); FIXED_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER, "");
return response; return response;
} }
@@ -451,4 +449,4 @@ public class FixedDepositProductHelper {
return response; return response;
} }
} }

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