diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationTest.java index 50c2fa039..456192fe3 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationTest.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationTest.java @@ -40,13 +40,14 @@ public class OfficeIntegrationTest { public void testOfficeModification() { OfficeHelper oh = new OfficeHelper(requestSpec, responseSpec); int officeId = oh.createOffice("01 July 2007"); - OfficeDomain oldOffice = oh.retrieveOfficeByID(officeId); + String name = Utils.randomNameGenerator("New_Office_", 4); + String date = "02 July 2007"; + String[] dateArr = { "2007", "7", "2" }; - oh.updateOffice(officeId, Utils.randomNameGenerator("New_Office_", 4), - "02 July 2007"); + oh.updateOffice(officeId, name, date); OfficeDomain newOffice = oh.retrieveOfficeByID(officeId); - Assert.assertTrue(oldOffice.getName().equals(newOffice.getName())); - Assert.assertTrue(oldOffice.getOpeningDate().equals( - newOffice.getOpeningDate())); + + Assert.assertTrue(name.equals(newOffice.getName())); + Assert.assertArrayEquals(dateArr, newOffice.getOpeningDate()); } } diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java index 5b114e706..7fc4b83a4 100755 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java @@ -14,46 +14,53 @@ import com.jayway.restassured.specification.ResponseSpecification; public class OfficeHelper { - private static final String OFFICE_URL = "/mifosng-provider/api/v1/offices"; - private final RequestSpecification requestSpec; - private final ResponseSpecification responseSpec; + private static final String OFFICE_URL = "/mifosng-provider/api/v1/offices"; + private final RequestSpecification requestSpec; + private final ResponseSpecification responseSpec; - public OfficeHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - this.requestSpec = requestSpec; - this.responseSpec = responseSpec; - } + public OfficeHelper(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { + this.requestSpec = requestSpec; + this.responseSpec = responseSpec; + } - public OfficeDomain retrieveOfficeByID(int id) { - final String json = new Gson().toJson(Utils.performServerGet(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" - + Utils.TENANT_IDENTIFIER, "")); - return new Gson().fromJson(json, new TypeToken() {}.getType()); - } + public OfficeDomain retrieveOfficeByID(int id) { + final String json = new Gson().toJson(Utils.performServerGet( + requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + + Utils.TENANT_IDENTIFIER, "")); + return new Gson().fromJson(json, new TypeToken() { + }.getType()); + } - public Integer createOffice(final String openingDate) { - String json = getAsJSON(openingDate); - return Utils.performServerPost(this.requestSpec, this.responseSpec, OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json, - CommonConstants.RESPONSE_RESOURCE_ID); - } + public Integer createOffice(final String openingDate) { + String json = getAsJSON(openingDate); + return Utils.performServerPost(this.requestSpec, this.responseSpec, + OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json, + CommonConstants.RESPONSE_RESOURCE_ID); + } - public Integer updateOffice(int id, String name, String openingDate) { - final HashMap map = new HashMap<>(); - map.put("name", name); - map.put("openingDate", openingDate); + public Integer updateOffice(int id, String name, String openingDate) { + final HashMap map = new HashMap<>(); + map.put("name", name); + map.put("dateFormat", "dd MMMM yyyy"); + map.put("locale", "en"); + map.put("openingDate", openingDate); - System.out.println("map : " + map); + System.out.println("map : " + map); - return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER, - new Gson().toJson(map), "resourceId"); - } + return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL + + "/" + id + "?" + Utils.TENANT_IDENTIFIER, + new Gson().toJson(map), "resourceId"); + } - public static String getAsJSON(final String openingDate) { - final HashMap map = new HashMap<>(); - map.put("parentId", "1"); - map.put("name", Utils.randomNameGenerator("Office_", 4)); - map.put("dateFormat", "dd MMMM yyyy"); - map.put("locale", "en"); - map.put("openingDate", openingDate); - System.out.println("map : " + map); - return new Gson().toJson(map); - } + public static String getAsJSON(final String openingDate) { + final HashMap map = new HashMap<>(); + map.put("parentId", "1"); + map.put("name", Utils.randomNameGenerator("Office_", 4)); + map.put("dateFormat", "dd MMMM yyyy"); + map.put("locale", "en"); + map.put("openingDate", openingDate); + System.out.println("map : " + map); + return new Gson().toJson(map); + } }