MIFOSX-2047 Updating Integration test case for hooks.Adding test case for update and delete hook.
This commit is contained in:
+21
-2
@@ -5,7 +5,8 @@
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -62,7 +63,7 @@ public class HookIntegrationTest {
|
||||
try {
|
||||
final String json = RestAssured.get(payloadURL.replace("?", "")).asString();
|
||||
final Integer notificationOfficeId = JsonPath.with(json).get("officeId");
|
||||
assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID,
|
||||
Assert.assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID,
|
||||
notificationOfficeId);
|
||||
System.out.println("Notification Office Id - " + notificationOfficeId);
|
||||
i = 6;
|
||||
@@ -80,4 +81,22 @@ public class HookIntegrationTest {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createUpdateAndDeleteHook(){
|
||||
final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?";
|
||||
final String updateURL = "http://localhost";
|
||||
|
||||
Long hookId = this.hookHelper.createHook(payloadURL).longValue();
|
||||
Assert.assertNotNull(hookId);
|
||||
this.hookHelper.verifyHookCreatedOnServer(hookId);
|
||||
System.out.println("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK-------------------------"+hookId);
|
||||
this.hookHelper.updateHook(updateURL, hookId);
|
||||
this.hookHelper.verifyUpdateHook(updateURL, hookId);
|
||||
System.out.println("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK-------------------------"+hookId);
|
||||
this.hookHelper.deleteHook(hookId);
|
||||
this.hookHelper.verifyDeleteHook(hookId);
|
||||
System.out.println("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK-------------------------"+hookId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+39
-1
@@ -5,10 +5,13 @@
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@@ -18,7 +21,7 @@ public class HookHelper {
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String CREATE_HOOK_URL = "/mifosng-provider/api/v1/hooks?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
|
||||
public HookHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
@@ -48,5 +51,40 @@ public class HookHelper {
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public Integer updateHook(final String payloadURL, final Long hookId) {
|
||||
System.out.println("---------------------------------UPDATING HOOK---------------------------------------------");
|
||||
final String UPDATE_HOOK_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, UPDATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId");
|
||||
}
|
||||
|
||||
public Integer deleteHook(final Long hookId) {
|
||||
System.out.println("---------------------------------DELETING HOOK---------------------------------------------");
|
||||
final String DELETE_HOOK_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, DELETE_HOOK_URL, "resourceId");
|
||||
}
|
||||
|
||||
public void verifyHookCreatedOnServer(final Long hookId) {
|
||||
System.out.println("------------------------------CHECK CREATE HOOK DETAILS------------------------------------\n");
|
||||
final String GET_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseHookId = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "id");
|
||||
assertEquals(hookId.toString(), responseHookId.toString());
|
||||
}
|
||||
|
||||
public void verifyUpdateHook(final String updateURL, final Long hookId) {
|
||||
System.out.println("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n");
|
||||
final String GET_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
ArrayList map = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "config");
|
||||
HashMap<String, String> hash = (HashMap<String, String>) map.get(1);
|
||||
assertEquals(updateURL, hash.get("fieldValue"));
|
||||
}
|
||||
|
||||
public void verifyDeleteHook(final Long hookId) {
|
||||
System.out.println("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n");
|
||||
final String GET_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
ArrayList array = Utils.performServerGet(this.requestSpec, responseSpec404, GET_URL, "errors");
|
||||
HashMap<String, String> map = (HashMap<String, String>)array.get(0);
|
||||
assertEquals("error.msg.hook.identifier.not.found",map.get("userMessageGlobalisationCode"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user