aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/MockApplication.java2
-rw-r--r--test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/extension/Webhooks.java13
2 files changed, 14 insertions, 1 deletions
diff --git a/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/MockApplication.java b/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/MockApplication.java
index 714d3a340..5977a8a2f 100644
--- a/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/MockApplication.java
+++ b/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/MockApplication.java
@@ -93,7 +93,7 @@ public class MockApplication {
// Register extension
options.extensions("org.onap.integration.test.mocks.sniroemulator.extension.Webhooks");
// Register notifier
- options.notifier(new ConsoleNotifier(true));
+ options.notifier(new ConsoleNotifier(true));
wireMockServer = new WireMockServer(options);
wireMockServer.enableRecordMappings(mappingsFileSource, filesFileSource);
diff --git a/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/extension/Webhooks.java b/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/extension/Webhooks.java
index e3fc286cb..e1e172668 100644
--- a/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/extension/Webhooks.java
+++ b/test/mocks/sniroemulator/src/main/java/org/onap/integration/test/mocks/sniroemulator/extension/Webhooks.java
@@ -19,6 +19,8 @@
*/
package org.onap.integration.test.mocks.sniroemulator.extension;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
import com.github.tomakehurst.wiremock.common.Notifier;
import com.github.tomakehurst.wiremock.core.Admin;
import com.github.tomakehurst.wiremock.extension.Parameters;
@@ -32,8 +34,11 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.util.EntityUtils;
+import com.github.tomakehurst.wiremock.common.Json;
+
import java.io.IOException;
+import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -62,13 +67,20 @@ public class Webhooks extends PostServeAction {
final WebhookDefinition definition = parameters.as(WebhookDefinition.class);
final Notifier notifier = notifier();
+
scheduler.schedule(
new Runnable() {
@Override
public void run() {
+ JsonNode node = Json.node(serveEvent.getRequest().getBodyAsString());
+ String callBackUrl = node.get("requestInfo").get("callbackUrl").asText();
+ notifier.info("!!! Call Back Url : \n" + callBackUrl);
+ definition.withUrl(callBackUrl);
HttpUriRequest request = buildRequest(definition);
try {
+ // notifier.info("This is a request: \n" + Json.prettyPrint(serveEvent.getRequest().getBodyAsString()));
+
HttpResponse response = httpClient.execute(request);
notifier.info(
String.format("Webhook %s request to %s returned status %s\n\n%s",
@@ -86,6 +98,7 @@ public class Webhooks extends PostServeAction {
)
);
} catch (IOException e) {
+ e.printStackTrace();
throwUnchecked(e);
}
}