Merge pull request #1257 from AJLiu/develop

Fixed Failing Test Case
This commit is contained in:
Vishwas Babu A J
2015-01-20 22:09:58 -08:00
2 changed files with 49 additions and 41 deletions
@@ -40,13 +40,14 @@ public class OfficeIntegrationTest {
public void testOfficeModification() { public void testOfficeModification() {
OfficeHelper oh = new OfficeHelper(requestSpec, responseSpec); OfficeHelper oh = new OfficeHelper(requestSpec, responseSpec);
int officeId = oh.createOffice("01 July 2007"); 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), oh.updateOffice(officeId, name, date);
"02 July 2007");
OfficeDomain newOffice = oh.retrieveOfficeByID(officeId); OfficeDomain newOffice = oh.retrieveOfficeByID(officeId);
Assert.assertTrue(oldOffice.getName().equals(newOffice.getName()));
Assert.assertTrue(oldOffice.getOpeningDate().equals( Assert.assertTrue(name.equals(newOffice.getName()));
newOffice.getOpeningDate())); Assert.assertArrayEquals(dateArr, newOffice.getOpeningDate());
} }
} }
@@ -18,31 +18,38 @@ public class OfficeHelper {
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
public OfficeHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public OfficeHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec; this.requestSpec = requestSpec;
this.responseSpec = responseSpec; this.responseSpec = responseSpec;
} }
public OfficeDomain retrieveOfficeByID(int id) { public OfficeDomain retrieveOfficeByID(int id) {
final String json = new Gson().toJson(Utils.performServerGet(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" final String json = new Gson().toJson(Utils.performServerGet(
requestSpec, responseSpec, OFFICE_URL + "/" + id + "?"
+ Utils.TENANT_IDENTIFIER, "")); + Utils.TENANT_IDENTIFIER, ""));
return new Gson().fromJson(json, new TypeToken<OfficeDomain>() {}.getType()); return new Gson().fromJson(json, new TypeToken<OfficeDomain>() {
}.getType());
} }
public Integer createOffice(final String openingDate) { public Integer createOffice(final String openingDate) {
String json = getAsJSON(openingDate); String json = getAsJSON(openingDate);
return Utils.performServerPost(this.requestSpec, this.responseSpec, OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json, return Utils.performServerPost(this.requestSpec, this.responseSpec,
OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
} }
public Integer updateOffice(int id, String name, String openingDate) { public Integer updateOffice(int id, String name, String openingDate) {
final HashMap map = new HashMap<>(); final HashMap map = new HashMap<>();
map.put("name", name); map.put("name", name);
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en");
map.put("openingDate", openingDate); 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, return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL
+ "/" + id + "?" + Utils.TENANT_IDENTIFIER,
new Gson().toJson(map), "resourceId"); new Gson().toJson(map), "resourceId");
} }