aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-simulators/src/main/java
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2020-03-23 12:22:15 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-23 12:22:15 +0000
commit09ca398afe3ecebcbf9ed53a03919372831986b3 (patch)
tree6f2c2d8cd83b9ed38fddfc886a579d50eda335e9 /models-interactions/model-simulators/src/main/java
parente8af063efc33258c32d5843d6b3aad7df0216a95 (diff)
parentf3fe0b63bc3bf7efdfce815bf17034291f8ff265 (diff)
Merge "Bug fixes in models simulators"
Diffstat (limited to 'models-interactions/model-simulators/src/main/java')
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLegacyTopicServer.java9
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/TopicServer.java11
2 files changed, 19 insertions, 1 deletions
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLegacyTopicServer.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLegacyTopicServer.java
index 5ebd3bd2a..0c259783d 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLegacyTopicServer.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLegacyTopicServer.java
@@ -36,6 +36,15 @@ public class AppcLegacyTopicServer extends TopicServer<Request> {
@Override
protected String process(Request request) {
+ /*
+ * The request and response are on the same topic, thus this may be invoked with a
+ * request or with a response object. If the "action" is null, then we know it's a
+ * response.
+ */
+ if (request.getAction() == null) {
+ return null;
+ }
+
String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appc/appc.legacy.success.json");
return response.replace("${replaceMe}", request.getCommonHeader().getSubRequestId());
}
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/TopicServer.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/TopicServer.java
index 0abe5f421..4c01511da 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/TopicServer.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/TopicServer.java
@@ -65,8 +65,17 @@ public abstract class TopicServer<Q> implements TopicListener {
throw new IllegalArgumentException("cannot decode request from " + source.getTopic());
}
- sink.send(process(req));
+ String resp = process(req);
+ if (resp != null) {
+ sink.send(resp);
+ }
}
+ /**
+ * Processes a request.
+ *
+ * @param request request to be processed
+ * @return the response, or {@code null} if no response is to be sent
+ */
protected abstract String process(Q request);
}