summaryrefslogtreecommitdiffstats
path: root/models-interactions
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions')
-rw-r--r--models-interactions/model-actors/actor.aai/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java3
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java5
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiUtil.java2
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java1
-rw-r--r--models-interactions/model-actors/actor.appc/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.appclcm/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.cds/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/resources/org/onap/policy/simulators/cds/my_artifact-subscribe.json27
-rw-r--r--models-interactions/model-actors/actor.guard/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.sdnc/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.sdnr/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.so/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.test/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.vfc/pom.xml2
-rw-r--r--models-interactions/model-actors/actorServiceProvider/pom.xml2
-rw-r--r--models-interactions/model-actors/pom.xml2
-rw-r--r--models-interactions/model-impl/aai/pom.xml2
-rw-r--r--models-interactions/model-impl/appc/pom.xml2
-rw-r--r--models-interactions/model-impl/appclcm/pom.xml2
-rw-r--r--models-interactions/model-impl/cds/pom.xml2
-rw-r--r--models-interactions/model-impl/events/pom.xml2
-rw-r--r--models-interactions/model-impl/guard/pom.xml2
-rw-r--r--models-interactions/model-impl/pom.xml2
-rw-r--r--models-interactions/model-impl/rest/pom.xml2
-rw-r--r--models-interactions/model-impl/sdnc/pom.xml2
-rw-r--r--models-interactions/model-impl/sdnr/pom.xml2
-rw-r--r--models-interactions/model-impl/so/pom.xml2
-rw-r--r--models-interactions/model-impl/vfc/pom.xml2
-rw-r--r--models-interactions/model-simulators/pom.xml2
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java67
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java2
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java26
-rw-r--r--models-interactions/pom.xml2
34 files changed, 133 insertions, 52 deletions
diff --git a/models-interactions/model-actors/actor.aai/pom.xml b/models-interactions/model-actors/actor.aai/pom.xml
index 4b2dc453b..521d7bceb 100644
--- a/models-interactions/model-actors/actor.aai/pom.xml
+++ b/models-interactions/model-actors/actor.aai/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.aai</artifactId>
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java
index d89d8350a..a4b30652d 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
@@ -70,8 +69,6 @@ public class AaiGetPnfOperation extends AaiGetOperation {
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
Map<String, Object> headers = makeHeaders();
- headers.put("Accept", MediaType.APPLICATION_JSON);
-
StringBuilder str = new StringBuilder(getClient().getBaseUrl());
String path = getPath() + URI_SEP + URLEncoder.encode(getTargetEntity(), StandardCharsets.UTF_8);
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java
index fe1179833..add9c647a 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java
@@ -24,7 +24,6 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
@@ -65,9 +64,7 @@ public class AaiGetTenantOperation extends AaiGetOperation {
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
- Map<String, Object> headers = makeHeaders();
-
- headers.put("Accept", MediaType.APPLICATION_JSON);
+ final Map<String, Object> headers = makeHeaders();
StringBuilder str = new StringBuilder(getClient().getBaseUrl());
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiUtil.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiUtil.java
index 14edc3aa1..c44e9d80d 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiUtil.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiUtil.java
@@ -22,6 +22,7 @@ package org.onap.policy.controlloop.actor.aai;
import java.util.HashMap;
import java.util.Map;
+import javax.ws.rs.core.MediaType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
/**
@@ -44,6 +45,7 @@ public class AaiUtil {
headers.put("X-FromAppId", "POLICY");
headers.put("X-TransactionId", params.getRequestId().toString());
+ headers.put("Accept", MediaType.APPLICATION_JSON);
return headers;
}
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java
index 1f481ae0f..9479d063b 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java
@@ -70,5 +70,6 @@ public abstract class BasicAaiOperation extends BasicHttpOperation {
protected void verifyHeaders(Map<String, Object> headers) {
assertEquals("POLICY", headers.get("X-FromAppId").toString());
assertEquals(params.getRequestId().toString(), headers.get("X-TransactionId"));
+ assertEquals("application/json", headers.get("Accept").toString());
}
}
diff --git a/models-interactions/model-actors/actor.appc/pom.xml b/models-interactions/model-actors/actor.appc/pom.xml
index 765f764e0..74b208ea7 100644
--- a/models-interactions/model-actors/actor.appc/pom.xml
+++ b/models-interactions/model-actors/actor.appc/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.appc</artifactId>
diff --git a/models-interactions/model-actors/actor.appclcm/pom.xml b/models-interactions/model-actors/actor.appclcm/pom.xml
index e4c48cfd5..1450fb618 100644
--- a/models-interactions/model-actors/actor.appclcm/pom.xml
+++ b/models-interactions/model-actors/actor.appclcm/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.appclcm</artifactId>
diff --git a/models-interactions/model-actors/actor.cds/pom.xml b/models-interactions/model-actors/actor.cds/pom.xml
index a01c32b4f..a46780779 100644
--- a/models-interactions/model-actors/actor.cds/pom.xml
+++ b/models-interactions/model-actors/actor.cds/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.cds</artifactId>
<dependencies>
diff --git a/models-interactions/model-actors/actor.cds/src/test/resources/org/onap/policy/simulators/cds/my_artifact-subscribe.json b/models-interactions/model-actors/actor.cds/src/test/resources/org/onap/policy/simulators/cds/my_artifact-subscribe.json
new file mode 100644
index 000000000..307ee9316
--- /dev/null
+++ b/models-interactions/model-actors/actor.cds/src/test/resources/org/onap/policy/simulators/cds/my_artifact-subscribe.json
@@ -0,0 +1,27 @@
+{
+ "commonHeader": {
+ "timestamp": "2020-03-20T14:00:25.217Z",
+ "requestId": "123456-1000",
+ "subRequestId": "sub-123456-1000",
+ "flag": {
+ },
+ "originatorId": "sdnc"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "my_artifact",
+ "blueprintVersion": "1.0.0",
+ "actionName": "subscribe",
+ "mode": "sync"
+ },
+ "status": {
+ "code": 200,
+ "message": "success",
+ "eventType": "EVENT_COMPONENT_EXECUTED",
+ "timestamp": "2020-07-02T14:56:25.608Z"
+ },
+ "payload": {
+ "subscription-response": {
+ "status": "success"
+ }
+ }
+} \ No newline at end of file
diff --git a/models-interactions/model-actors/actor.guard/pom.xml b/models-interactions/model-actors/actor.guard/pom.xml
index cf2b2ff1a..9c82ecc52 100644
--- a/models-interactions/model-actors/actor.guard/pom.xml
+++ b/models-interactions/model-actors/actor.guard/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.guard</artifactId>
diff --git a/models-interactions/model-actors/actor.sdnc/pom.xml b/models-interactions/model-actors/actor.sdnc/pom.xml
index 37df2b7f7..9fa01027b 100644
--- a/models-interactions/model-actors/actor.sdnc/pom.xml
+++ b/models-interactions/model-actors/actor.sdnc/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.sdnc</artifactId>
diff --git a/models-interactions/model-actors/actor.sdnr/pom.xml b/models-interactions/model-actors/actor.sdnr/pom.xml
index 813e11399..9e0613e57 100644
--- a/models-interactions/model-actors/actor.sdnr/pom.xml
+++ b/models-interactions/model-actors/actor.sdnr/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.sdnr</artifactId>
diff --git a/models-interactions/model-actors/actor.so/pom.xml b/models-interactions/model-actors/actor.so/pom.xml
index 78599f203..96a9510da 100644
--- a/models-interactions/model-actors/actor.so/pom.xml
+++ b/models-interactions/model-actors/actor.so/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.so</artifactId>
diff --git a/models-interactions/model-actors/actor.test/pom.xml b/models-interactions/model-actors/actor.test/pom.xml
index 4c3b7d94d..4c83822fa 100644
--- a/models-interactions/model-actors/actor.test/pom.xml
+++ b/models-interactions/model-actors/actor.test/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.test</artifactId>
diff --git a/models-interactions/model-actors/actor.vfc/pom.xml b/models-interactions/model-actors/actor.vfc/pom.xml
index d03ff5cc8..54a8fb80a 100644
--- a/models-interactions/model-actors/actor.vfc/pom.xml
+++ b/models-interactions/model-actors/actor.vfc/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actor.vfc</artifactId>
diff --git a/models-interactions/model-actors/actorServiceProvider/pom.xml b/models-interactions/model-actors/actorServiceProvider/pom.xml
index 3c2ad0aa2..b2570f3e5 100644
--- a/models-interactions/model-actors/actorServiceProvider/pom.xml
+++ b/models-interactions/model-actors/actorServiceProvider/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>actorServiceProvider</artifactId>
diff --git a/models-interactions/model-actors/pom.xml b/models-interactions/model-actors/pom.xml
index 4e30c5901..0d0679c5d 100644
--- a/models-interactions/model-actors/pom.xml
+++ b/models-interactions/model-actors/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models-interactions</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
diff --git a/models-interactions/model-impl/aai/pom.xml b/models-interactions/model-impl/aai/pom.xml
index 6a823be47..c33dc5459 100644
--- a/models-interactions/model-impl/aai/pom.xml
+++ b/models-interactions/model-impl/aai/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>aai</artifactId>
diff --git a/models-interactions/model-impl/appc/pom.xml b/models-interactions/model-impl/appc/pom.xml
index 51f131b84..09c066c26 100644
--- a/models-interactions/model-impl/appc/pom.xml
+++ b/models-interactions/model-impl/appc/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>appc</artifactId>
diff --git a/models-interactions/model-impl/appclcm/pom.xml b/models-interactions/model-impl/appclcm/pom.xml
index 6d438b93e..60b9aee24 100644
--- a/models-interactions/model-impl/appclcm/pom.xml
+++ b/models-interactions/model-impl/appclcm/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>appclcm</artifactId>
diff --git a/models-interactions/model-impl/cds/pom.xml b/models-interactions/model-impl/cds/pom.xml
index 347bad645..73ca43c5c 100644
--- a/models-interactions/model-impl/cds/pom.xml
+++ b/models-interactions/model-impl/cds/pom.xml
@@ -25,7 +25,7 @@
<parent>
<artifactId>model-impl</artifactId>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>cds</artifactId>
diff --git a/models-interactions/model-impl/events/pom.xml b/models-interactions/model-impl/events/pom.xml
index 89bfd84d5..e543d0352 100644
--- a/models-interactions/model-impl/events/pom.xml
+++ b/models-interactions/model-impl/events/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>events</artifactId>
diff --git a/models-interactions/model-impl/guard/pom.xml b/models-interactions/model-impl/guard/pom.xml
index 19e1c6795..6626c5910 100644
--- a/models-interactions/model-impl/guard/pom.xml
+++ b/models-interactions/model-impl/guard/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>guard</artifactId>
diff --git a/models-interactions/model-impl/pom.xml b/models-interactions/model-impl/pom.xml
index 8ea0b7751..dd068ee56 100644
--- a/models-interactions/model-impl/pom.xml
+++ b/models-interactions/model-impl/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models-interactions</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
diff --git a/models-interactions/model-impl/rest/pom.xml b/models-interactions/model-impl/rest/pom.xml
index 72a081e4b..2c0d5ab86 100644
--- a/models-interactions/model-impl/rest/pom.xml
+++ b/models-interactions/model-impl/rest/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>rest</artifactId>
diff --git a/models-interactions/model-impl/sdnc/pom.xml b/models-interactions/model-impl/sdnc/pom.xml
index 54b2b384f..997d25f93 100644
--- a/models-interactions/model-impl/sdnc/pom.xml
+++ b/models-interactions/model-impl/sdnc/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>sdnc</artifactId>
diff --git a/models-interactions/model-impl/sdnr/pom.xml b/models-interactions/model-impl/sdnr/pom.xml
index 311472520..c2e4a024b 100644
--- a/models-interactions/model-impl/sdnr/pom.xml
+++ b/models-interactions/model-impl/sdnr/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>sdnr</artifactId>
diff --git a/models-interactions/model-impl/so/pom.xml b/models-interactions/model-impl/so/pom.xml
index 9a9a8aba0..a6f8bc3fa 100644
--- a/models-interactions/model-impl/so/pom.xml
+++ b/models-interactions/model-impl/so/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>so</artifactId>
diff --git a/models-interactions/model-impl/vfc/pom.xml b/models-interactions/model-impl/vfc/pom.xml
index 014a646e2..f9137d37f 100644
--- a/models-interactions/model-impl/vfc/pom.xml
+++ b/models-interactions/model-impl/vfc/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>vfc</artifactId>
diff --git a/models-interactions/model-simulators/pom.xml b/models-interactions/model-simulators/pom.xml
index e496fc0f7..2a1fe2d07 100644
--- a/models-interactions/model-simulators/pom.xml
+++ b/models-interactions/model-simulators/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models-interactions</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.models.policy-models-interactions</groupId>
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java
index 3418780bc..222bd7fee 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java
@@ -29,18 +29,26 @@ import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.StreamObserver;
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.time.Instant;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput.Builder;
import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CdsSimulator implements Runnable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CdsSimulator.class);
-public class CdsSimulator {
@Getter
private final int port;
@@ -77,16 +85,15 @@ public class CdsSimulator {
@Override
public StreamObserver<ExecutionServiceInput> process(
- final StreamObserver<ExecutionServiceOutput> responseObserver) {
+ final StreamObserver<ExecutionServiceOutput> responseObserver) {
return new StreamObserver<ExecutionServiceInput>() {
@Override
public void onNext(final ExecutionServiceInput executionServiceInput) {
+ LOGGER.info("Received request input to CDS: {}", executionServiceInput);
try {
- String responseString = getResponseString(executionServiceInput, countOfSuccesfulEvents);
- Builder builder = ExecutionServiceOutput.newBuilder();
- JsonFormat.parser().ignoringUnknownFields().merge(responseString, builder);
+ Builder builder = getResponse(executionServiceInput, countOfSuccesfulEvents);
TimeUnit.MILLISECONDS.sleep(requestedResponseDelayMs);
responseObserver.onNext(builder.build());
} catch (InvalidProtocolBufferException e) {
@@ -111,13 +118,25 @@ public class CdsSimulator {
};
server = NettyServerBuilder.forAddress(new InetSocketAddress(host, port)).addService(testCdsBlueprintServerImpl)
- .build();
+ .build();
}
+ /**
+ * Start the server.
+ *
+ * @throws IOException IO exception.
+ */
public void start() throws IOException {
server.start();
+ // The grpc server uses daemon threads by default. Hence the application will exit as soon the main thread
+ // completes. So, wrap the server in a non-daemon thread and call awaitTermination to keep the thread alive
+ // until the server is terminated.
+ new Thread(this).start();
}
+ /**
+ * Stop the server.
+ */
public void stop() {
server.shutdown();
}
@@ -127,9 +146,11 @@ public class CdsSimulator {
*
* @param executionServiceInput service input
* @param countOfSuccesfulEvents number of successive successful events
- * @return responseString
+ * @return builder for ExecutionServiceOutput response
+ * @throws InvalidProtocolBufferException when response string cannot be converted
*/
- public String getResponseString(ExecutionServiceInput executionServiceInput, int countOfSuccesfulEvents) {
+ public Builder getResponse(ExecutionServiceInput executionServiceInput, int countOfSuccesfulEvents)
+ throws InvalidProtocolBufferException {
String resourceName = "DefaultResponseEvent";
if (!StringUtils.isBlank(executionServiceInput.getActionIdentifiers().getActionName())) {
ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
@@ -141,11 +162,33 @@ public class CdsSimulator {
} else {
resourceName = resourceName + ".json";
}
+ LOGGER.info("Fetching response from {}", resourceName);
String responseString = ResourceUtils.getResourceAsString(resourceLocation + resourceName);
- if (responseString == null) {
- responseString = ResourceUtils.getResourceAsString(resourceLocation
- + "DefaultResponseEvent.json");
+ Builder builder = ExecutionServiceOutput.newBuilder();
+ if (null == responseString) {
+ LOGGER.info("Expected response file {} not found in {}", resourceName, resourceLocation);
+ ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+ builder.setCommonHeader(executionServiceInput.getCommonHeader());
+ builder.setActionIdentifiers(actionIdentifiers);
+ builder.setPayload(executionServiceInput.getPayload());
+ builder.setStatus(Status.newBuilder().setCode(500).setMessage("failure")
+ .setErrorMessage("failed to get get cba file name(" + actionIdentifiers.getBlueprintName()
+ + "), version(" + actionIdentifiers.getBlueprintVersion() + ") from db : file check failed.")
+ .setEventType(EventType.EVENT_COMPONENT_FAILURE).setTimestamp(Instant.now().toString()));
+ } else {
+ LOGGER.debug("Returning response from CDS Simulator: {}", responseString);
+ JsonFormat.parser().ignoringUnknownFields().merge(responseString, builder);
+ }
+ return builder;
+ }
+
+ @Override
+ public void run() {
+ try {
+ server.awaitTermination();
+ } catch (InterruptedException e) {
+ LOGGER.info("gRPC server is terminated");
+ Thread.currentThread().interrupt();
}
- return responseString;
}
}
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
index efc40367b..d9fb52bd9 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -52,7 +52,7 @@ public class Util {
private static final String CANNOT_PROCESS_PARAMETERS = "cannot parse parameters ";
private static final String CANNOT_CONNECT = "cannot connect to port ";
- private static final String LOCALHOST = "localhost";
+ public static final String LOCALHOST = "localhost";
private Util() {
// Prevent instantiation of this class
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
index fea03e3e4..07ec0dc04 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
@@ -24,6 +24,7 @@ package org.onap.policy.simulators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import com.google.protobuf.util.JsonFormat;
import io.grpc.ManagedChannel;
import io.grpc.internal.DnsNameResolverProvider;
import io.grpc.internal.PickFirstLoadBalancerProvider;
@@ -42,9 +43,11 @@ import org.junit.Test;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput.Builder;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
public class CdsSimulatorTest {
@@ -52,9 +55,15 @@ public class CdsSimulatorTest {
private CdsSimulator sim;
+ /**
+ * Starts the simulator, allocating a unique port for each test so we don't have to
+ * wait for the prior server to shut down.
+ */
@Before
public void setUp() throws Exception {
- sim = Util.buildCdsSim();
+ int port = NetworkUtil.allocPort();
+ sim = new CdsSimulator(Util.LOCALHOST, port);
+ sim.start();
}
@After
@@ -65,8 +74,10 @@ public class CdsSimulatorTest {
@Test
public void test() throws Exception {
String reqstr = IOUtils.toString(getClass().getResource("cds/cds.request.json"), StandardCharsets.UTF_8);
- ExecutionServiceInput request = coder.decode(reqstr, ExecutionServiceInput.class);
- ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", sim.getPort())
+ Builder builder = ExecutionServiceInput.newBuilder();
+ JsonFormat.parser().ignoringUnknownFields().merge(reqstr, builder);
+ ExecutionServiceInput request = builder.build();
+ ManagedChannel channel = NettyChannelBuilder.forAddress(Util.LOCALHOST, sim.getPort())
.nameResolverFactory(new DnsNameResolverProvider())
.loadBalancerFactory(new PickFirstLoadBalancerProvider()).usePlaintext().build();
@@ -117,13 +128,16 @@ public class CdsSimulatorTest {
}
@Test
- public void testGetResponseString() throws IOException, CoderException, ParseException {
- CdsSimulator cdsSimulator = new CdsSimulator("localhost", sim.getPort());
+ public void testGetResponse() throws IOException, CoderException, ParseException {
+ CdsSimulator cdsSimulator = new CdsSimulator(Util.LOCALHOST, sim.getPort());
String reqstr = ResourceUtils.getResourceAsString(
"org/onap/policy/simulators/cds/cds.request.json");
String responseqstr = ResourceUtils.getResourceAsString(
"org/onap/policy/simulators/cds/pm_control-create-subscription.json");
ExecutionServiceInput request = coder.decode(reqstr, ExecutionServiceInput.class);
- assertEquals(responseqstr, cdsSimulator.getResponseString(request, 0));
+ org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput.Builder esoBuilder =
+ ExecutionServiceOutput.newBuilder();
+ JsonFormat.parser().ignoringUnknownFields().merge(responseqstr, esoBuilder);
+ assertEquals(esoBuilder.toString(), cdsSimulator.getResponse(request, 0).toString());
}
}
diff --git a/models-interactions/pom.xml b/models-interactions/pom.xml
index d0e7f4411..e0f5ab5dc 100644
--- a/models-interactions/pom.xml
+++ b/models-interactions/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models</artifactId>
- <version>2.3.2-SNAPSHOT</version>
+ <version>2.3.5-SNAPSHOT</version>
</parent>
<artifactId>policy-models-interactions</artifactId>
<packaging>pom</packaging>