summaryrefslogtreecommitdiffstats
path: root/test/mocks/sniroemulator
diff options
context:
space:
mode:
authorGeora Barsky <georab@amdocs.com>2017-10-27 23:51:26 -0400
committerGeora Barsky <georab@amdocs.com>2017-10-28 00:00:35 -0400
commit853f3ea0756f7bf3b685f1decb0101878fdebe1d (patch)
tree5678e1758dd8888dd7502c75439cd39257649dd1 /test/mocks/sniroemulator
parent505b09580abcfe9ad3cf147e7047e2352e5c2e7e (diff)
Sniro Emulator - Fix SO CallBack URL
Modify SNIRO emulator to use the callback URL included in the request Change-Id: Ida9cf0099c984a0c0ca19bd5850164640b649827 JIRA-ID: INT-311 Signed-off-by: Geora Barsky <georab@amdocs.com>
Diffstat (limited to 'test/mocks/sniroemulator')
-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);
}
}