You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ma...@apache.org on 2016/01/28 06:46:55 UTC

[10/51] [partial] incubator-fineract git commit: initial code push

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4b1ec9ef/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
new file mode 100644
index 0000000..aa39e4e
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map.Entry;
+
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.CommonConstants;
+import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
+import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
+import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
+public class FlexibleSavingsInterestPostingIntegrationTest {
+
+    public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private SavingsProductHelper savingsProductHelper;
+    private SavingsAccountHelper savingsAccountHelper;
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+        this.savingsProductHelper = new SavingsProductHelper();
+    }
+
+    @Test
+    public void testSavingsInterestPostingAtPeriodEnd() {
+        // client activation, savings activation and 1st transaction date
+        final String startDate = "01 December 2013";
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, startDate);
+        Assert.assertNotNull(clientID);
+
+        // Configuring global config flags
+        configureInterestPosting(true, 4);
+
+        final Integer savingsId = createSavingsAccount(clientID, startDate);
+
+        Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate,
+                CommonConstants.RESPONSE_RESOURCE_ID);
+
+        /***
+         * Perform Post interest transaction and verify the posted transaction
+         * date
+         */
+        this.savingsAccountHelper.postInterestForSavings(savingsId);
+        HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
+        ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
+        HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
+        for (Entry<String, Object> entry : interestPostingTransaction.entrySet())
+            System.out.println(entry.getKey() + "-" + entry.getValue().toString());
+        // 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily
+        // balance
+        // 33.7016 obtained from formula in excel provided by Subramanya
+        assertEquals("Equality check for interest posted amount", "33.7016", interestPostingTransaction.get("amount").toString());
+        assertEquals("Date check for Interest Posting transaction", "[2014, 3, 31]", interestPostingTransaction.get("date").toString());
+
+    }
+
+    private Integer createSavingsAccount(final Integer clientID, final String startDate) {
+        final Integer savingsProductID = createSavingsProduct();
+        Assert.assertNotNull(savingsProductID);
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID, savingsProductID,
+                ACCOUNT_TYPE_INDIVIDUAL, startDate);
+        Assert.assertNotNull(savingsId);
+        HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavingsOnDate(savingsId, startDate);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+        savingsStatusHashMap = this.savingsAccountHelper.activateSavingsAccount(savingsId, startDate);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+        return savingsId;
+    }
+
+    private void configureInterestPosting(final Boolean periodEndEnable, final Integer financialYearBeginningMonth) {
+        final ArrayList<HashMap> globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(globalConfig);
+
+        // Updating flag for interest posting at period end
+        Integer periodEndConfigId = (Integer) globalConfig.get(10).get("id");
+        Assert.assertNotNull(periodEndConfigId);
+
+        HashMap periodEndConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
+                periodEndConfigId.toString());
+        Assert.assertNotNull(periodEndConfigData);
+
+        Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
+
+        if (enabled != periodEndEnable)
+            periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
+                    periodEndConfigId.toString(), periodEndEnable);
+
+        // Updating value for financial year beginning month
+        Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
+        Assert.assertNotNull(financialYearBeginningConfigId);
+
+        HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec,
+                this.responseSpec, financialYearBeginningConfigId.toString());
+        Assert.assertNotNull(financialYearBeginningConfigData);
+
+        financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
+                financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString());
+        Assert.assertNotNull(financialYearBeginningConfigId);
+    }
+
+    private Integer createSavingsProduct() {
+        final String savingsProductJSON = this.savingsProductHelper.withInterestCompoundingPeriodTypeAsDaily()
+                .withInterestPostingPeriodTypeAsAnnual().withInterestCalculationPeriodTypeAsDailyBalance().build();
+        return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
+    }
+
+    // Reset configuration fields
+    @After
+    public void tearDown() {
+        configureInterestPosting(false, 1);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4b1ec9ef/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java
new file mode 100644
index 0000000..0c2deeb
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java
@@ -0,0 +1,347 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertEquals;
+
+import com.google.gson.Gson;
+
+import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.funds.FundsHelper;
+import org.apache.fineract.integrationtests.common.funds.FundsResourceHandler;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+import java.util.*;
+
+/**
+ * Funds Integration Test for checking Funds Application.
+ */
+public class FundsIntegrationTest {
+
+    private ResponseSpecification statusOkResponseSpec;
+    private RequestSpecification requestSpec;
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.statusOkResponseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+    }
+
+    @Test
+    public void testCreateFund() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+    }
+
+    @Test
+    public void testCreateFundWithEmptyName() {
+        FundsHelper fh = FundsHelper
+                         .create(null)
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
+        final Long fundID = createFund(jsonData, this.requestSpec, responseSpec);
+        Assert.assertNull(fundID);
+    }
+
+    @Test
+    public void testCreateFundWithEmptyExternalId() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(null)
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+    }
+
+    @Test
+    public void testCreateFundWithDuplicateName() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        FundsHelper fh2 = FundsHelper
+                         .create(fh.getName())
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        jsonData = fh2.toJSON();
+
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
+        final Long fundID2 = createFund(jsonData, this.requestSpec, responseSpec);
+        Assert.assertNull(fundID2);
+    }
+
+    @Test
+    public void testCreateFundWithDuplicateExternalId() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        FundsHelper fh2 = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(fh.getExternalId())
+                         .build();
+        jsonData = fh2.toJSON();
+
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
+        final Long fundID2 = createFund(jsonData, this.requestSpec, responseSpec);
+        Assert.assertNull(fundID2);
+    }
+
+    @Test
+    public void testCreateFundWithInvalidName() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 120))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
+        final Long fundID = createFund(jsonData, this.requestSpec, responseSpec);
+        Assert.assertNull(fundID);
+    }
+
+    @Test
+    public void testCreateFundWithInvalidExternalId() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 120))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
+        final Long fundID = createFund(jsonData, this.requestSpec, responseSpec);
+        Assert.assertNull(fundID);
+    }
+
+    @Test
+    public void testRetrieveFund() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        jsonData = FundsResourceHandler.retrieveFund(fundID, this.requestSpec, this.statusOkResponseSpec);
+        FundsHelper fh2 = FundsHelper.fromJSON(jsonData);
+
+        assertEquals(fh.getName(), fh2.getName());
+    }
+
+    @Test
+    public void testRetrieveAllFunds() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        List<FundsHelper> fhList = FundsResourceHandler.retrieveAllFunds(this.requestSpec, this.statusOkResponseSpec);
+
+        Assert.assertNotNull(fhList);
+        Assert.assertThat(fhList.size(), greaterThanOrEqualTo(1));
+        Assert.assertThat(fhList, hasItem(fh));
+    }
+
+    @Test
+    public void testRetrieveUnknownFund() {
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
+        String jsonData = FundsResourceHandler.retrieveFund(Long.MAX_VALUE, this.requestSpec, responseSpec);
+        HashMap<String, String> map = new Gson().fromJson(jsonData, HashMap.class);
+        assertEquals(map.get("userMessageGlobalisationCode"), "error.msg.resource.not.found");
+    }
+
+    @Test
+    public void testUpdateFund() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        String newName = Utils.randomNameGenerator("", 10);
+        String newExternalId = Utils.randomNameGenerator("fund-", 5);
+        FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, this.statusOkResponseSpec);
+
+        Assert.assertEquals(newName, fh2.getName());
+        Assert.assertEquals(newExternalId, fh2.getExternalId());
+    }
+
+    @Test
+    public void testUpdateUnknownFund() {
+        String newName = Utils.randomNameGenerator("", 10);
+        String newExternalId = Utils.randomNameGenerator("fund-", 5);
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
+        FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec,
+                responseSpec);
+        Assert.assertNull(fh);
+    }
+
+    @Test
+    public void testUpdateFundWithInvalidNewName() {
+        FundsHelper fh = FundsHelper
+                        .create(Utils.randomNameGenerator("", 10))
+                        .externalId(Utils.randomNameGenerator("fund-", 5))
+                        .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        String newName = Utils.randomNameGenerator("", 120);
+        String newExternalId = Utils.randomNameGenerator("fund-", 5);
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
+        FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec,
+                responseSpec);
+
+        Assert.assertNull(fh2);
+    }
+
+    @Test
+    public void testUpdateFundWithNewExternalId() {
+        FundsHelper fh = FundsHelper
+                         .create(Utils.randomNameGenerator("", 10))
+                         .externalId(Utils.randomNameGenerator("fund-", 5))
+                         .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        String newExternalId = Utils.randomNameGenerator("fund-", 5);
+        FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, null, newExternalId, this.requestSpec, this.statusOkResponseSpec);
+
+        Assert.assertEquals(newExternalId, fh2.getExternalId());
+    }
+
+    @Test
+    public void testUpdateFundWithInvalidNewExternalId() {
+        FundsHelper fh = FundsHelper
+                .create(Utils.randomNameGenerator("", 10))
+                .externalId(Utils.randomNameGenerator("fund-", 5))
+                .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        String newName = Utils.randomNameGenerator("", 10);
+        String newExternalId = Utils.randomNameGenerator("fund-", 120);
+        ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
+        FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec,
+                responseSpec);
+
+        Assert.assertNull(fh2);
+    }
+
+    @Test
+    public void testUpdateFundWithNewName() {
+        FundsHelper fh = FundsHelper
+                .create(Utils.randomNameGenerator("", 10))
+                .externalId(Utils.randomNameGenerator("fund-", 5))
+                .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        String newName = Utils.randomNameGenerator("", 10);
+        FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, null, this.requestSpec, this.statusOkResponseSpec);
+
+        Assert.assertEquals(newName, fh2.getName());
+    }
+
+    @Test
+    public void testUpdateFundWithEmptyParams() {
+        FundsHelper fh = FundsHelper
+                .create(Utils.randomNameGenerator("", 10))
+                .externalId(Utils.randomNameGenerator("fund-", 5))
+                .build();
+        String jsonData = fh.toJSON();
+
+        final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
+        Assert.assertNotNull(fundID);
+
+        FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, null, null, this.requestSpec, this.statusOkResponseSpec);
+
+        Assert.assertNull(fh2.getName());
+        Assert.assertNull(fh2.getExternalId());
+
+        // assert that there was no change in
+        // the name and external ID of the fund
+        jsonData = FundsResourceHandler.retrieveFund(fundID, this.requestSpec, this.statusOkResponseSpec);
+        FundsHelper fh3 = new Gson().fromJson(jsonData, FundsHelper.class);
+
+        Assert.assertEquals(fh.getName(), fh3.getName());
+        Assert.assertEquals(fh.getExternalId(), fh3.getExternalId());
+    }
+
+    private Long createFund(final String fundJSON,
+                            final RequestSpecification requestSpec,
+                            final ResponseSpecification responseSpec) {
+        String fundId = String.valueOf(FundsResourceHandler.createFund(fundJSON, requestSpec, responseSpec));
+        if (fundId.equals("null")) {
+            // Invalid JSON data parameters
+            return null;
+        }
+
+        return new Long(fundId);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4b1ec9ef/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java
new file mode 100644
index 0000000..b8d42d4
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java
@@ -0,0 +1,221 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.fineract.integrationtests.common.CommonConstants;
+import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+@SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
+public class GlobalConfigurationTest {
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private GlobalConfigurationHelper globalConfigurationHelper;
+    private ResponseSpecification httpStatusForidden;
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+        this.httpStatusForidden = new ResponseSpecBuilder().expectStatusCode(403).build();
+    }
+
+    @Test
+    public void testGlobalConfigurations() {
+        this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
+
+        // Retrieving All Global Configuration details
+        final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
+                this.responseSpec);
+        Assert.assertNotNull(globalConfig);
+
+        String configName = "penalty-wait-period";
+        for (Integer configIndex = 0; configIndex < (globalConfig.size() - 1); configIndex++) {
+            if (globalConfig.get(configIndex).get("name").equals(configName)) {
+                Integer configId = (Integer) globalConfig.get(configIndex).get("id");
+                Assert.assertNotNull(configId);
+
+                HashMap configDataBefore = this.globalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
+                        configId.toString());
+                Assert.assertNotNull(configDataBefore);
+
+                Integer value = (Integer) configDataBefore.get("value") + 1;
+
+                // Updating Value for penalty-wait-period Global Configuration
+                configId = this.globalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
+                        configId.toString(), value.toString());
+                Assert.assertNotNull(configId);
+
+                HashMap configDataAfter = this.globalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
+                        configId.toString());
+
+                // Verifying Value for penalty-wait-period after Updation
+                Assert.assertEquals("Verifying Global Config Value after Updation", value, configDataAfter.get("value"));
+
+                // Updating Enabled Flag for penalty-wait-period Global
+                // Configuration
+                Boolean enabled = (Boolean) globalConfig.get(configIndex).get("enabled");
+
+                if (enabled == true) {
+                    enabled = false;
+                } else {
+                    enabled = true;
+                }
+
+                configId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
+                        configId.toString(), enabled);
+
+                configDataAfter = this.globalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
+                        configId.toString());
+
+                // Verifying Enabled Flag for penalty-wait-period after Updation
+                Assert.assertEquals("Verifying Enabled Flag Global Config after Updation", enabled, configDataAfter.get("enabled"));
+                break;
+            }
+        }
+    }
+
+    @Test
+    public void testGlobalConfigurationIsCacheEnabled() {
+        this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
+
+        // Retrieving Is Cache Enabled Global Configuration details
+        ArrayList<HashMap> isCacheGlobalConfig = this.globalConfigurationHelper.getGlobalConfigurationIsCacheEnabled(this.requestSpec,
+                this.responseSpec);
+        Assert.assertNotNull(isCacheGlobalConfig);
+
+        for (Integer cacheType = 0; cacheType <= ((isCacheGlobalConfig.size()) - 1); cacheType++) {
+
+            // Retrieving Is Cache Enabled Global Configuration details
+            isCacheGlobalConfig = this.globalConfigurationHelper.getGlobalConfigurationIsCacheEnabled(this.requestSpec, this.responseSpec);
+            Assert.assertNotNull(isCacheGlobalConfig);
+
+            HashMap cacheTypeAsHashMap = (HashMap) isCacheGlobalConfig.get(cacheType).get("cacheType");
+            Integer cacheTypeId = (Integer) cacheTypeAsHashMap.get("id");
+            String cacheTypeValue = (String) cacheTypeAsHashMap.get("value");
+            Boolean enabled = (Boolean) isCacheGlobalConfig.get(cacheType).get("enabled");
+
+            if (cacheTypeValue.compareTo("No cache") == 0 && enabled == true) {
+                cacheTypeId += 1;
+            } else if (cacheTypeValue.compareTo("Single node") == 0 && enabled == true) {
+                cacheTypeId -= 1;
+            }
+
+            HashMap changes = this.globalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec,
+                    this.responseSpec, cacheTypeId.toString());
+            Assert.assertEquals("Verifying Is Cache Enabled Global Config after Updation", cacheTypeId, changes.get("cacheType"));
+        }
+    }
+    
+    @Test
+	public void testGlobalConfigForcePasswordResetDays() {
+
+		// Retrieving All Global Configuration details
+		final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper
+				.getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
+		Assert.assertNotNull(globalConfig);
+
+		String configName = "force-password-reset-days";
+		String newValue = "0";
+		String newBooleanValue = "true";
+
+		for (Integer configIndex = 0; configIndex < (globalConfig.size() - 1); configIndex++) {
+			if (globalConfig.get(configIndex).get("name").equals(configName)) {
+				Integer configId = (Integer) globalConfig.get(configIndex).get(
+						"id");
+				Assert.assertNotNull(configId);
+
+				/*
+				 * Update force-password-reset-days with value as 0 and Enable
+				 * as true - failure case
+				 */
+				ArrayList error = (ArrayList) this.globalConfigurationHelper
+						.updatePasswordResetDaysForGlobalConfiguration(
+								this.requestSpec, this.httpStatusForidden,
+								configId, newValue, newBooleanValue,
+								CommonConstants.RESPONSE_ERROR);
+				HashMap hash = (HashMap) error.get(0);
+
+				Assert.assertEquals(
+						"Force 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));
+
+				/*
+				 * Update force-password-reset-days with value as 50 and Enable
+				 * as true - success case
+				 */
+				final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper
+						.updatePasswordResetDaysForGlobalConfiguration(
+								this.requestSpec, this.responseSpec, configId,
+								"50", newBooleanValue, "changes");
+				Assert.assertNotNull(updateSuccess);
+
+				/* Update with value as 0 and Enable as false - success case */
+				final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper
+						.updatePasswordResetDaysForGlobalConfiguration(
+								this.requestSpec, this.responseSpec, configId,
+								newValue, "false", "changes");
+				Assert.assertNotNull(updateSuccess1);
+
+				/* Update without sending value and Enable as true - failure case*/
+				ArrayList failure = (ArrayList) this.globalConfigurationHelper
+						.updatePasswordResetDaysForGlobalConfiguration(
+								this.requestSpec, this.httpStatusForidden, configId,
+								null, newBooleanValue, CommonConstants.RESPONSE_ERROR);
+				HashMap failureHash = (HashMap) failure.get(0);
+				Assert.assertEquals(
+						"Force 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));
+
+				break;
+			}
+		}
+		/* Update other global configuration property */
+		String otherConfigName = "maker-checker";
+		for (Integer configIndex = 0; configIndex < (globalConfig.size() - 1); configIndex++) {
+			if (globalConfig.get(configIndex).get("name")
+					.equals(otherConfigName)) {
+				String configId = (globalConfig.get(configIndex).get("id"))
+						.toString();
+				Integer updateConfigId = this.globalConfigurationHelper
+						.updateValueForGlobalConfiguration(this.requestSpec,
+								this.responseSpec, configId, newValue);
+				Assert.assertNotNull(updateConfigId);
+				break;
+			}
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4b1ec9ef/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupLoanIntegrationTest.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupLoanIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupLoanIntegrationTest.java
new file mode 100644
index 0000000..e6f6227
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupLoanIntegrationTest.java
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.GroupHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
+import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
+import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+/**
+ * Group Loan Integration Test for checking Loan Application Repayment Schedule.
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class GroupLoanIntegrationTest {
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private LoanTransactionHelper loanTransactionHelper;
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+    }
+
+    @Test
+    public void checkGroupLoanCreateAndDisburseFlow() {
+        this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+
+        final Integer loanProductID = createLoanProduct();
+        final Integer loanID = applyForLoanApplication(groupID, loanProductID);
+        final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
+                loanID);
+        verifyLoanRepaymentSchedule(loanSchedule);
+
+    }
+
+    private Integer createLoanProduct() {
+        System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
+        final String loanProductJSON = new LoanProductTestBuilder() //
+                .withPrincipal("12,000.00") //
+                .withNumberOfRepayments("4") //
+                .withRepaymentAfterEvery("1") //
+                .withRepaymentTypeAsMonth() //
+                .withinterestRatePerPeriod("1") //
+                .withInterestRateFrequencyTypeAsMonths() //
+                .withAmortizationTypeAsEqualInstallments() //
+                .withInterestTypeAsDecliningBalance() //
+                .build(null);
+        return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
+    }
+
+    private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID) {
+        System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
+        final String loanApplicationJSON = new LoanApplicationTestBuilder() //
+                .withPrincipal("12,000.00") //
+                .withLoanTermFrequency("4") //
+                .withLoanTermFrequencyAsMonths() //
+                .withNumberOfRepayments("4") //
+                .withRepaymentEveryAfter("1") //
+                .withRepaymentFrequencyTypeAsMonths() //
+                .withInterestRatePerPeriod("2") //
+                .withAmortizationTypeAsEqualInstallments() //
+                .withInterestTypeAsDecliningBalance() //
+                .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
+                .withExpectedDisbursementDate("20 September 2011") //
+                .withSubmittedOnDate("20 September 2011") //
+                .withLoanType("group").build(groupID.toString(), loanProductID.toString(), null);
+        System.out.println(loanApplicationJSON);
+        return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
+    }
+
+    private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
+        System.out.println("--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------");
+
+        assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2011, 10, 20)),
+                loanSchedule.get(1).get("dueDate"));
+        assertEquals("Checking for Principal Due for 1st Month", new Float("2911.49"), loanSchedule.get(1).get("principalOriginalDue"));
+        assertEquals("Checking for Interest Due for 1st Month", new Float("240.00"), loanSchedule.get(1).get("interestOriginalDue"));
+
+        assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2011, 11, 20)),
+                loanSchedule.get(2).get("dueDate"));
+        assertEquals("Checking for Principal Due for 2nd Month", new Float("2969.72"), loanSchedule.get(2).get("principalDue"));
+        assertEquals("Checking for Interest Due for 2nd Month", new Float("181.77"), loanSchedule.get(2).get("interestOriginalDue"));
+
+        assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2011, 12, 20)),
+                loanSchedule.get(3).get("dueDate"));
+        assertEquals("Checking for Principal Due for 3rd Month", new Float("3029.11"), loanSchedule.get(3).get("principalDue"));
+        assertEquals("Checking for Interest Due for 3rd Month", new Float("122.38"), loanSchedule.get(3).get("interestOriginalDue"));
+
+        assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2012, 1, 20)),
+                loanSchedule.get(4).get("dueDate"));
+        assertEquals("Checking for Principal Due for 4th Month", new Float("3089.68"), loanSchedule.get(4).get("principalDue"));
+        assertEquals("Checking for Interest Due for 4th Month", new Float("61.79"), loanSchedule.get(4).get("interestOriginalDue"));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4b1ec9ef/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
new file mode 100644
index 0000000..1c9ffee
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
@@ -0,0 +1,553 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.CommonConstants;
+import org.apache.fineract.integrationtests.common.GroupHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
+import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
+import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
+import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import org.joda.time.LocalDate;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+/**
+ * Group Savings Integration Test for checking Savings Application.
+ */
+@SuppressWarnings({ "rawtypes", "unused" })
+public class GroupSavingsIntegrationTest {
+
+    public static final String DEPOSIT_AMOUNT = "2000";
+    public static final String WITHDRAW_AMOUNT = "1000";
+    public static final String WITHDRAW_AMOUNT_ADJUSTED = "500";
+    public static final String MINIMUM_OPENING_BALANCE = "1000.0";
+    public static final String ACCOUNT_TYPE_GROUP = "GROUP";
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private SavingsAccountHelper savingsAccountHelper;
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+    }
+
+    @Test
+    public void testSavingsAccount() {
+        this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        Assert.assertNotNull(groupID);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        Assert.assertNotNull(groupID);
+
+        final String minBalanceForInterestCalculation = null;
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
+        Assert.assertNotNull(savingsProductID);
+
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
+        Assert.assertNotNull(savingsId);
+
+        HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(groupID, savingsProductID, savingsId, ACCOUNT_TYPE_GROUP);
+        Assert.assertTrue(modifications.containsKey("submittedOnDate"));
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+
+        final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        this.savingsAccountHelper.calculateInterestForSavings(savingsId);
+        HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        assertEquals(summaryBefore, summary);
+
+        this.savingsAccountHelper.postInterestForSavings(savingsId);
+        summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        Assert.assertFalse(summaryBefore.equals(summary));
+
+        final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSavingsAccount_CLOSE_APPLICATION() {
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+        final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
+        final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        Assert.assertNotNull(groupID);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        Assert.assertNotNull(groupID);
+
+        final String minBalanceForInterestCalculation = null;
+        final String minRequiredBalance = "1000.0";
+        final String enforceMinRequiredBalance = "true";
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
+        Assert.assertNotNull(savingsProductID);
+
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
+        Assert.assertNotNull(savingsId);
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+
+        DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
+        Calendar todaysDate = Calendar.getInstance();
+        final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
+        String withdrawBalance = "false";
+        ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
+                savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
+        assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
+                savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        withdrawBalance = "true";
+        savingsStatusHashMap =  this.savingsAccountHelper.closeSavingsAccount(savingsId, withdrawBalance);
+        SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSavingsAccount_DELETE_APPLICATION() {
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+
+        SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
+                new ResponseSpecBuilder().build());
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        Assert.assertNotNull(groupID);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        Assert.assertNotNull(groupID);
+
+        final String minBalanceForInterestCalculation = null;
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
+        Assert.assertNotNull(savingsProductID);
+
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
+        Assert.assertNotNull(savingsId);
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        List<HashMap> error1 = (List<HashMap>) savingsAccountHelperValidationError.deleteSavingsApplication(savingsId,
+                CommonConstants.RESPONSE_ERROR);
+        assertEquals("validation.msg.savingsaccount.delete.not.in.submittedandpendingapproval.state",
+                error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        savingsStatusHashMap = this.savingsAccountHelper.undoApproval(savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        this.savingsAccountHelper.deleteSavingsApplication(savingsId, CommonConstants.RESPONSE_RESOURCE_ID);
+
+        List<HashMap> error = savingsAccountHelperValidationError.getSavingsCollectionAttribute(savingsId, CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.saving.account.id.invalid", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSavingsAccount_REJECT_APPLICATION() {
+
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+
+        SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
+                new ResponseSpecBuilder().build());
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        Assert.assertNotNull(groupID);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        Assert.assertNotNull(groupID);
+
+        final String minBalanceForInterestCalculation = null;
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
+        Assert.assertNotNull(savingsProductID);
+
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
+        Assert.assertNotNull(savingsId);
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        List<HashMap> error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId,
+                SavingsAccountHelper.CREATED_DATE_PLUS_ONE);
+        assertEquals("validation.msg.savingsaccount.reject.not.in.submittedandpendingapproval.state",
+                error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        savingsStatusHashMap = this.savingsAccountHelper.undoApproval(savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId, SavingsAccountHelper.getFutureDate());
+        assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date",
+                error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId, SavingsAccountHelper.CREATED_DATE_MINUS_ONE);
+        assertEquals("validation.msg.savingsaccount.reject.cannot.be.before.submittal.date",
+                error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        savingsStatusHashMap = this.savingsAccountHelper.rejectApplication(savingsId);
+        SavingsStatusChecker.verifySavingsIsRejected(savingsStatusHashMap);
+    }
+
+    @Test
+    public void testSavingsAccount_WITHDRAW_APPLICATION() {
+
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        Assert.assertNotNull(groupID);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        Assert.assertNotNull(groupID);
+
+        final String minBalanceForInterestCalculation = null;
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
+        Assert.assertNotNull(savingsProductID);
+
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
+        Assert.assertNotNull(savingsId);
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.withdrawApplication(savingsId);
+        SavingsStatusChecker.verifySavingsIsWithdrawn(savingsStatusHashMap);
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSavingsAccountTransactions() {
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+        SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
+                new ResponseSpecBuilder().build());
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        Assert.assertNotNull(groupID);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        Assert.assertNotNull(groupID);
+
+        final String minBalanceForInterestCalculation = null;
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
+        Assert.assertNotNull(savingsProductID);
+
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
+        Assert.assertNotNull(savingsId);
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        List<HashMap> error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "100",
+                SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.savingsaccount.transaction.account.is.not.active",
+                error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        error = (List) savingsAccountHelperValidationError.depositToSavingsAccount(savingsId, "100", SavingsAccountHelper.TRANSACTION_DATE,
+                CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.savingsaccount.transaction.account.is.not.active",
+                error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+
+        HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        Float balance = new Float(MINIMUM_OPENING_BALANCE);
+        assertEquals("Verifying opening Balance", balance, summary.get("accountBalance"));
+
+        Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
+                SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
+        balance += new Float(DEPOSIT_AMOUNT);
+        assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT), depositTransaction.get("amount"));
+        assertEquals("Verifying Balance after Deposit", balance, depositTransaction.get("runningBalance"));
+
+        Integer withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT,
+                SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
+        balance -= new Float(WITHDRAW_AMOUNT);
+        assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount"));
+        assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
+
+        Integer newWithdrawTransactionId = this.savingsAccountHelper.updateSavingsAccountTransaction(savingsId, withdrawTransactionId,
+                WITHDRAW_AMOUNT_ADJUSTED);
+        HashMap newWithdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, newWithdrawTransactionId);
+        balance = balance + new Float(WITHDRAW_AMOUNT) - new Float(WITHDRAW_AMOUNT_ADJUSTED);
+        assertEquals("Verifying adjusted Amount", new Float(WITHDRAW_AMOUNT_ADJUSTED), newWithdrawTransaction.get("amount"));
+        assertEquals("Verifying Balance after adjust", balance, newWithdrawTransaction.get("runningBalance"));
+        summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        assertEquals("Verifying Adjusted Balance", balance, summary.get("accountBalance"));
+        withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
+        Assert.assertTrue((Boolean) withdrawTransaction.get("reversed"));
+
+        this.savingsAccountHelper.undoSavingsAccountTransaction(savingsId, newWithdrawTransactionId);
+        newWithdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
+        Assert.assertTrue((Boolean) newWithdrawTransaction.get("reversed"));
+        summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        balance += new Float(WITHDRAW_AMOUNT_ADJUSTED);
+        assertEquals("Verifying Balance After Undo Transaction", balance, summary.get("accountBalance"));
+
+        error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "5000",
+                SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.savingsaccount.transaction.insufficient.account.balance",
+                error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "5000",
+                SavingsAccountHelper.getFutureDate(), CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.savingsaccount.transaction.in.the.future", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        error = (List) savingsAccountHelperValidationError.depositToSavingsAccount(savingsId, "5000", SavingsAccountHelper.getFutureDate(),
+                CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.savingsaccount.transaction.in.the.future", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "5000",
+                SavingsAccountHelper.CREATED_DATE_MINUS_ONE, CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.savingsaccount.transaction.before.activation.date",
+                error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+        error = (List) savingsAccountHelperValidationError.depositToSavingsAccount(savingsId, "5000",
+                SavingsAccountHelper.CREATED_DATE_MINUS_ONE, CommonConstants.RESPONSE_ERROR);
+        assertEquals("error.msg.savingsaccount.transaction.before.activation.date",
+                error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSavingsAccountCharges() {
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
+        Assert.assertNotNull(groupID);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        Assert.assertNotNull(groupID);
+
+        final String minBalanceForInterestCalculation = null;
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
+        Assert.assertNotNull(savingsProductID);
+
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
+        Assert.assertNotNull(savingsId);
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        final Integer withdrawalChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
+                ChargesHelper.getSavingsWithdrawalFeeJSON());
+        Assert.assertNotNull(withdrawalChargeId);
+
+        this.savingsAccountHelper.addChargesForSavings(savingsId, withdrawalChargeId);
+        ArrayList<HashMap> chargesPendingState = this.savingsAccountHelper.getSavingsCharges(savingsId);
+        Assert.assertEquals(1, chargesPendingState.size());
+
+        Integer savingsChargeId = (Integer) chargesPendingState.get(0).get("id");
+        HashMap chargeChanges = this.savingsAccountHelper.updateCharges(savingsChargeId, savingsId);
+        Assert.assertTrue(chargeChanges.containsKey("amount"));
+
+        Integer deletedChargeId = this.savingsAccountHelper.deleteCharge(savingsChargeId, savingsId);
+        assertEquals(savingsChargeId, deletedChargeId);
+
+        chargesPendingState = this.savingsAccountHelper.getSavingsCharges(savingsId);
+        Assert.assertTrue(chargesPendingState == null || chargesPendingState.size() == 0);
+
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+
+        final Integer chargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsAnnualFeeJSON());
+        Assert.assertNotNull(chargeId);
+
+        ArrayList<HashMap> charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
+        Assert.assertTrue(charges == null || charges.size() == 0);
+
+        this.savingsAccountHelper.addChargesForSavings(savingsId, chargeId);
+        charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
+        Assert.assertEquals(1, charges.size());
+
+        HashMap savingsChargeForPay = charges.get(0);
+        SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat, Locale.US);
+        Calendar cal = Calendar.getInstance();
+        List dates = (List) savingsChargeForPay.get("dueDate");
+        cal.set(Calendar.YEAR, (Integer) dates.get(0));
+        cal.set(Calendar.MONTH, (Integer) dates.get(1) - 1);
+        cal.set(Calendar.DAY_OF_MONTH, (Integer) dates.get(2));
+
+        this.savingsAccountHelper.payCharge((Integer) savingsChargeForPay.get("id"), savingsId,
+                ((Float) savingsChargeForPay.get("amount")).toString(), sdf.format(cal.getTime()));
+        HashMap paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
+        assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
+
+        final Integer monthlyFeechargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
+                ChargesHelper.getSavingsMonthlyFeeJSON());
+        Assert.assertNotNull(monthlyFeechargeId);
+
+        this.savingsAccountHelper.addChargesForSavings(savingsId, monthlyFeechargeId);
+        charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
+        Assert.assertEquals(2, charges.size());
+
+        HashMap savingsChargeForWaive = charges.get(1);
+        this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
+        HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
+        assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
+
+        this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
+        waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
+        BigDecimal totalWaiveAmount = BigDecimal.valueOf(Double.valueOf((Float) savingsChargeForWaive.get("amount")));
+        totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
+        assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
+        
+        final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsWeeklyFeeJSON());
+        Assert.assertNotNull(weeklyFeeId);
+        
+        this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId);
+        charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
+        Assert.assertEquals(3, charges.size());
+
+        savingsChargeForPay = charges.get(2);
+        cal = Calendar.getInstance();
+        dates = (List) savingsChargeForPay.get("dueDate");
+        cal.set(Calendar.YEAR, (Integer) dates.get(0));
+        cal.set(Calendar.MONTH, (Integer) dates.get(1) - 1);
+        cal.set(Calendar.DAY_OF_MONTH, (Integer) dates.get(2));
+
+        // Depositing huge amount as scheduler job deducts the fee amount
+        Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "100000",
+                SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        Assert.assertNotNull(depositTransactionId);
+
+        this.savingsAccountHelper.payCharge((Integer) savingsChargeForPay.get("id"), savingsId,
+                ((Float) savingsChargeForPay.get("amount")).toString(), sdf.format(cal.getTime()));
+        paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
+        assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
+        List nextDueDates = (List) paidCharge.get("dueDate");
+        LocalDate nextDueDate = new LocalDate((Integer) nextDueDates.get(0), (Integer) nextDueDates.get(1), (Integer) nextDueDates.get(2));
+        LocalDate expectedNextDueDate = new LocalDate((Integer) dates.get(0), (Integer) dates.get(1), (Integer) dates.get(2))
+                .plusWeeks((Integer) paidCharge.get("feeInterval"));
+        assertEquals(expectedNextDueDate, nextDueDate);
+        cal = Calendar.getInstance();
+        
+        this.savingsAccountHelper.closeSavingsAccountAndGetBackRequiredField(savingsId, "true", null, sdf.format(cal.getTime()));
+        
+    }
+
+    public static Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
+            final String minOpenningBalance, final String minBalanceForInterestCalculation, final String minRequiredBalance,
+            final String enforceMinRequiredBalance) {
+        System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
+        SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
+        final String savingsProductJSON = savingsProductHelper //
+                .withInterestCompoundingPeriodTypeAsDaily() //
+                .withInterestPostingPeriodTypeAsMonthly() //
+                .withInterestCalculationPeriodTypeAsDailyBalance() //
+                .withMinBalanceForInterestCalculation(minBalanceForInterestCalculation) //
+                .withMinRequiredBalance(minRequiredBalance) //
+                .withEnforceMinRequiredBalance(enforceMinRequiredBalance) //
+                .withMinimumOpenningBalance(minOpenningBalance).build();
+        return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4b1ec9ef/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java
new file mode 100755
index 0000000..49b4d4c
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.HashMap;
+
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.GroupHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
+import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
+import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
+import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+/**
+ * Group Test for checking Group: Creation, Activation, Client Association,
+ * Updating & Deletion
+ */
+public class GroupTest {
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private LoanTransactionHelper loanTransactionHelper;
+    private final String principal = "10000.00";
+    private final String accountingRule = "1";
+    private final String numberOfRepayments = "5";
+    private final String interestRatePerPeriod = "18";
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+        this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
+
+    }
+
+    @Test
+    public void checkGroupFunctions() {
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
+        GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
+
+        groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString());
+        GroupHelper.verifyGroupActivatedOnServer(this.requestSpec, this.responseSpec, groupID, true);
+
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupID, clientID);
+
+        groupID = GroupHelper.disAssociateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        GroupHelper.verifyEmptyGroupMembers(this.requestSpec, this.responseSpec, groupID);
+
+        final String updatedGroupName = GroupHelper.randomNameGenerator("Group-", 5);
+        groupID = GroupHelper.updateGroup(this.requestSpec, this.responseSpec, updatedGroupName, groupID.toString());
+        GroupHelper.verifyGroupDetails(this.requestSpec, this.responseSpec, groupID, "name", updatedGroupName);
+
+        // NOTE: removed as consistently provides false positive result on
+        // cloudbees server.
+        // groupID = GroupHelper.createGroup(this.requestSpec,
+        // this.responseSpec);
+        // GroupHelper.deleteGroup(this.requestSpec, this.responseSpec,
+        // groupID.toString());
+        // GroupHelper.verifyGroupDeleted(this.requestSpec, this.responseSpec,
+        // groupID);
+    }
+
+    @Test
+    public void assignStaffToGroup() {
+        Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
+        GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
+
+        final String updateGroupName = Utils.randomNameGenerator("Savings Group Help_", 5);
+        groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString());
+        Integer updateGroupId = GroupHelper.updateGroup(this.requestSpec, this.responseSpec, updateGroupName, groupID.toString());
+
+        // create client and add client to group
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
+        GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupID, clientID);
+
+        // create staff
+        Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
+        System.out.println("--------------creating first staff with id-------------" + createStaffId1);
+        Assert.assertNotNull(createStaffId1);
+
+        Integer createStaffId2 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
+        System.out.println("--------------creating second staff with id-------------" + createStaffId2);
+        Assert.assertNotNull(createStaffId2);
+
+        // assign staff "createStaffId1" to group
+        HashMap assignStaffGroupId = (HashMap) GroupHelper.assignStaff(this.requestSpec, this.responseSpec, groupID.toString(),
+                createStaffId1.longValue());
+        assertEquals("Verify assigned staff id is the same as id sent", assignStaffGroupId.get("staffId"), createStaffId1);
+
+        // assign staff "createStaffId2" to client
+        final HashMap assignStaffToClientChanges = (HashMap) ClientHelper.assignStaffToClient(this.requestSpec, this.responseSpec,
+                clientID.toString(), createStaffId2.toString());
+        assertEquals("Verify assigned staff id is the same as id sent", assignStaffToClientChanges.get("staffId"), createStaffId2);
+
+        final Integer loanProductId = this.createLoanProduct();
+
+        final Integer loanId = this.applyForLoanApplication(clientID, loanProductId, this.principal);
+
+        this.loanTransactionHelper.approveLoan("20 September 2014", loanId);
+        this.loanTransactionHelper.disburseLoan("20 September 2014", loanId);
+
+        final HashMap assignStaffAndInheritStaffForClientAccounts = (HashMap) GroupHelper.assignStaffInheritStaffForClientAccounts(
+                this.requestSpec, this.responseSpec, groupID.toString(), createStaffId1.toString());
+        final Integer getClientStaffId = ClientHelper.getClientsStaffId(this.requestSpec, this.responseSpec, clientID.toString());
+
+        // assert if client staff officer has change Note client was assigned
+        // staff with createStaffId2
+        assertNotEquals("Verify if client stuff has changed", assignStaffAndInheritStaffForClientAccounts.get("staffId"), createStaffId2);
+        assertEquals("Verify if client inherited staff assigned above", assignStaffAndInheritStaffForClientAccounts.get("staffId"),
+                getClientStaffId);
+
+        // assert if clients loan officer has changed
+        final Integer loanOfficerId = this.loanTransactionHelper.getLoanOfficerId(loanId.toString());
+        assertEquals("Verify if client loan inherited staff", assignStaffAndInheritStaffForClientAccounts.get("staffId"), loanOfficerId);
+
+    }
+
+    private Integer createLoanProduct() {
+        final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.principal)
+                .withNumberOfRepayments(this.numberOfRepayments).withinterestRatePerPeriod(this.interestRatePerPeriod)
+                .withInterestRateFrequencyTypeAsYear().build(null);
+        return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
+    }
+
+    private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) {
+        System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
+        final String loanApplicationJSON = new LoanApplicationTestBuilder() //
+                .withPrincipal(principal) //
+                .withLoanTermFrequency("4") //
+                .withLoanTermFrequencyAsMonths() //
+                .withNumberOfRepayments("4") //
+                .withRepaymentEveryAfter("1") //
+                .withRepaymentFrequencyTypeAsMonths() //
+                .withInterestRatePerPeriod("2") //
+                .withAmortizationTypeAsEqualInstallments() //
+                .withInterestTypeAsDecliningBalance() //
+                .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
+                .withExpectedDisbursementDate("20 September 2014") //
+                .withSubmittedOnDate("20 September 2014") //
+                .build(clientID.toString(), loanProductID.toString(), null);
+        return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
+    }
+
+}
\ No newline at end of file