renaming ambiguously named test helper methos

This commit is contained in:
Vishwas Babu A J
2014-12-08 15:23:50 -08:00
parent 872cbdf441
commit 7c64de0a1c
2 changed files with 59 additions and 53 deletions
@@ -5,6 +5,11 @@
*/
package org.mifosplatform.integrationtests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import java.util.HashMap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -12,22 +17,15 @@ import org.mifosplatform.integrationtests.common.ClientHelper;
import org.mifosplatform.integrationtests.common.GroupHelper;
import org.mifosplatform.integrationtests.common.StaffHelper;
import org.mifosplatform.integrationtests.common.Utils;
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
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 org.mifosplatform.integrationtests.common.accounting.Account;
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
import java.util.HashMap;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
/**
* Group Test for checking Group: Creation, Activation, Client Association,
@@ -38,11 +36,10 @@ public class GroupTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
private String principal = "10000.00";
private String accountingRule = "1";
private String numberOfRepayments = "5";
private String interestRatePerPeriod = "18";
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() {
@@ -73,29 +70,32 @@ public class GroupTest {
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);
// 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(){
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);
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());
Integer updateGroupId = GroupHelper.updateGroup(this.requestSpec, this.responseSpec, updateGroupName, groupID.toString());
//create client and add client to group
// 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) ;
// create staff
Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
System.out.println("--------------creating first staff with id-------------" + createStaffId1);
Assert.assertNotNull(createStaffId1);
@@ -103,45 +103,43 @@ public class GroupTest {
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);
// 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);
final Integer loanId = this.applyForLoanApplication(clientID, loanProductId, this.principal);
this.loanTransactionHelper.approveLoan("20 September 2014",loanId);
this.loanTransactionHelper.disburseLoan("20 September 2014",loanId);
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.getClient(this.requestSpec,this.responseSpec,clientID.toString());
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
// 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);
assertEquals("Verify if client inherited staff assigned above", assignStaffAndInheritStaffForClientAccounts.get("staffId"),
getClientStaffId);
//assert if clients loan officer has changed
// 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);
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.principal)
.withNumberOfRepayments(this.numberOfRepayments).withinterestRatePerPeriod(this.interestRatePerPeriod)
.withInterestRateFrequencyTypeAsYear().build(null);
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
@@ -23,7 +23,7 @@ public class ClientHelper {
private static final String CLOSE_CLIENT_COMMAND = "close";
private static final String REACTIVATE_CLIENT_COMMAND = "reactivate";
private static final String REJECT_CLIENT_COMMAND = "reject";
private static final String ACTIVATE_CLIENT_COMMAND ="activate";
private static final String ACTIVATE_CLIENT_COMMAND = "activate";
private static final String WITHDRAW_CLIENT_COMMAND = "withdraw";
public static final String CREATED_DATE = "27 November 2014";
@@ -62,7 +62,8 @@ public class ClientHelper {
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes");
}
public static Integer getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId) {
public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String clientId) {
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
}
@@ -124,6 +125,7 @@ public class ClientHelper {
return clientJson;
}
private String getReactivateClientAsJSON() {
final HashMap<String, String> map = new HashMap<>();
map.put("locale", CommonConstants.locale);
@@ -134,6 +136,7 @@ public class ClientHelper {
return clientJson;
}
private String getRejectClientAsJSON() {
final HashMap<String, String> map = new HashMap<>();
map.put("locale", CommonConstants.locale);
@@ -145,6 +148,7 @@ public class ClientHelper {
return clientJson;
}
private String getActivateClientAsJSON() {
final HashMap<String, String> map = new HashMap<>();
map.put("locale", CommonConstants.locale);
@@ -167,6 +171,7 @@ public class ClientHelper {
return clientJson;
}
public HashMap closeClient(final Integer clientId) {
System.out.println("--------------------------------- CLOSE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
@@ -176,19 +181,22 @@ public class ClientHelper {
System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
}
public HashMap rejectClient(final Integer clientId) {
System.out.println("--------------------------------- REJECT CLIENT -------------------------------");
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
}
public HashMap activateClient(final Integer clientId) {
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(), clientId);
}
public HashMap withdrawClient(final Integer clientId) {
System.out.println("--------------------------------- WITHDRAWN CLIENT -------------------------------");
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
}
private String createClientOperationURL(final String command, final Integer clientId) {
return CLIENT_URL + "/" + clientId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
}