diff options
71 files changed, 373 insertions, 99 deletions
diff --git a/models-base/pom.xml b/models-base/pom.xml index 5cd00b346..d9cd648f2 100644 --- a/models-base/pom.xml +++ b/models-base/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-base</artifactId> diff --git a/models-dao/pom.xml b/models-dao/pom.xml index 8d1b7237f..a3567eced 100644 --- a/models-dao/pom.xml +++ b/models-dao/pom.xml @@ -25,7 +25,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-dao</artifactId> diff --git a/models-decisions/pom.xml b/models-decisions/pom.xml index f9d609ade..8592f078b 100644 --- a/models-decisions/pom.xml +++ b/models-decisions/pom.xml @@ -25,7 +25,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-decisions</artifactId> diff --git a/models-errors/pom.xml b/models-errors/pom.xml index 3fa4baa75..8420540e3 100644 --- a/models-errors/pom.xml +++ b/models-errors/pom.xml @@ -25,7 +25,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-errors</artifactId> diff --git a/models-examples/pom.xml b/models-examples/pom.xml index f9a5fa79f..ccfba3915 100644 --- a/models-examples/pom.xml +++ b/models-examples/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-examples</artifactId> diff --git a/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml b/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml index 382999f10..95c87e129 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml @@ -111,7 +111,7 @@ data_types: onap.datatypes.drools.controller.relation: derived_from: tosca.datatypes.Root properties: - controllerName: + name: type: string required: true description: the name of drools controller policy 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> diff --git a/models-pap/pom.xml b/models-pap/pom.xml index c78275343..8abed9a34 100644 --- a/models-pap/pom.xml +++ b/models-pap/pom.xml @@ -25,7 +25,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-pap</artifactId> diff --git a/models-pdp/pom.xml b/models-pdp/pom.xml index fdb5022db..8190476f2 100644 --- a/models-pdp/pom.xml +++ b/models-pdp/pom.xml @@ -25,7 +25,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-pdp</artifactId> diff --git a/models-provider/pom.xml b/models-provider/pom.xml index 362552ca8..2cb4091a7 100644 --- a/models-provider/pom.xml +++ b/models-provider/pom.xml @@ -23,7 +23,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-provider</artifactId> diff --git a/models-sim/models-sim-dmaap/pom.xml b/models-sim/models-sim-dmaap/pom.xml index bb71eef42..487cec796 100644 --- a/models-sim/models-sim-dmaap/pom.xml +++ b/models-sim/models-sim-dmaap/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-sim</artifactId> - <version>2.3.2-SNAPSHOT</version> + <version>2.3.5-SNAPSHOT</version> </parent> <artifactId>policy-models-sim-dmaap</artifactId> diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java index 11da57582..9719ae93f 100644 --- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java +++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/models-sim/packages/models-simulator-docker/pom.xml b/models-sim/packages/models-simulator-docker/pom.xml index c6f4717c0..b9c181fc5 100644 --- a/models-sim/packages/models-simulator-docker/pom.xml +++ b/models-sim/packages/models-simulator-docker/pom.xml @@ -1,6 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2020 Bell Canada. + Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,8 +24,8 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.models.sim</groupId> - <artifactId>policy-models-sim</artifactId> - <version>2.3.2-SNAPSHOT</version> + <artifactId>models-sim-packages</artifactId> + <version>2.3.5-SNAPSHOT</version> </parent> <artifactId>models-simulator-docker</artifactId> @@ -43,6 +44,8 @@ <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry> <docker.push.registry>nexus3.onap.org:10003</docker.push.registry> <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format> + <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. --> + <sonar.skip>true</sonar.skip> </properties> <build> @@ -166,7 +169,7 @@ <dependency> <groupId>org.onap.policy.models.sim</groupId> <artifactId>models-simulator-tarball</artifactId> - <version>2.3.2-SNAPSHOT</version> + <version>${project.version}</version> <classifier>tarball</classifier> <type>tar.gz</type> </dependency> diff --git a/models-sim/packages/models-simulator-tarball/pom.xml b/models-sim/packages/models-simulator-tarball/pom.xml index 9fb1fb5fd..c8c20880d 100644 --- a/models-sim/packages/models-simulator-tarball/pom.xml +++ b/models-sim/packages/models-simulator-tarball/pom.xml @@ -3,6 +3,7 @@ ONAP ================================================================================ Copyright (C) 2020 Bell Canada. + Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -26,8 +27,8 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.models.sim</groupId> - <artifactId>policy-models-sim</artifactId> - <version>2.3.2-SNAPSHOT</version> + <artifactId>models-sim-packages</artifactId> + <version>2.3.5-SNAPSHOT</version> </parent> <artifactId>models-simulator-tarball</artifactId> @@ -35,11 +36,16 @@ <name>${project.artifactId}</name> <description>A module that runs all "simulators", including DMaaP.</description> + <properties> + <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. --> + <sonar.skip>true</sonar.skip> + </properties> + <dependencies> <dependency> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-simulators</artifactId> - <version>2.3.2-SNAPSHOT</version> + <version>${project.version}</version> </dependency> </dependencies> diff --git a/models-sim/packages/models-simulator-tarball/src/main/assembly.xml b/models-sim/packages/models-simulator-tarball/src/main/assembly.xml index 9a2fd65df..47395e122 100644 --- a/models-sim/packages/models-simulator-tarball/src/main/assembly.xml +++ b/models-sim/packages/models-simulator-tarball/src/main/assembly.xml @@ -46,5 +46,14 @@ <outputDirectory>etc${file.separator}ssl</outputDirectory> <lineEnding>keep</lineEnding> </fileSet> + <fileSet> + <directory>${project.basedir}/src/main/resources/etc + </directory> + <includes> + <include>*.xml</include> + </includes> + <outputDirectory>etc</outputDirectory> + <lineEnding>unix</lineEnding> + </fileSet> </fileSets> </assembly> diff --git a/models-sim/packages/models-simulator-tarball/src/main/resources/etc/logback.xml b/models-sim/packages/models-simulator-tarball/src/main/resources/etc/logback.xml new file mode 100644 index 000000000..131b0fe33 --- /dev/null +++ b/models-sim/packages/models-simulator-tarball/src/main/resources/etc/logback.xml @@ -0,0 +1,42 @@ +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2020 AT&T Intellectual Property. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= +--> + +<configuration scan="true" scanPeriod="30 seconds" debug="false"> + + <!-- + This is only used for testing and only a snapshot docker image is generated, + thus it is not necessary for the messages to following the ONAP standard. + Therefore, keeping it short so it's easier to wade through the output. + + Also sending all output to stdout instead of to a log file; it can be viewed + via "docker logs" or captured by kubernetes. + --> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <Pattern>%d %level %msg%n</Pattern> + </encoder> + </appender> + + <root level="INFO"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration> diff --git a/models-sim/packages/pom.xml b/models-sim/packages/pom.xml index 14922559d..ceabde62e 100644 --- a/models-sim/packages/pom.xml +++ b/models-sim/packages/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-sim</artifactId> - <version>2.3.2-SNAPSHOT</version> + <version>2.3.5-SNAPSHOT</version> </parent> <artifactId>models-sim-packages</artifactId> diff --git a/models-sim/policy-models-sim-pdp/pom.xml b/models-sim/policy-models-sim-pdp/pom.xml index 18d6160db..22425dfa1 100644 --- a/models-sim/policy-models-sim-pdp/pom.xml +++ b/models-sim/policy-models-sim-pdp/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-sim</artifactId> - <version>2.3.2-SNAPSHOT</version> + <version>2.3.5-SNAPSHOT</version> </parent> <artifactId>policy-models-sim-pdp</artifactId> <name>policy-models-sim-pdp</name> diff --git a/models-sim/policy-models-simulators/pom.xml b/models-sim/policy-models-simulators/pom.xml index 9cd19e4c6..c129783aa 100644 --- a/models-sim/policy-models-simulators/pom.xml +++ b/models-sim/policy-models-simulators/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-sim</artifactId> - <version>2.3.2-SNAPSHOT</version> + <version>2.3.5-SNAPSHOT</version> </parent> <artifactId>policy-models-simulators</artifactId> diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java index a0fafbc9b..f82423c11 100644 --- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java +++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java @@ -83,18 +83,22 @@ public class Main extends ServiceManagerContainer { } DmaapSimParameterGroup dmaapProv = params.getDmaapProvider(); - String dmaapName = dmaapProv.getName(); - String provName = dmaapName.replace("simulator", "provider"); + String dmaapName = (dmaapProv != null ? dmaapProv.getName() : null); // dmaap provider - AtomicReference<DmaapSimProvider> provRef = new AtomicReference<>(); - addAction(provName, () -> provRef.set(buildDmaapProvider(dmaapProv)), () -> provRef.get().shutdown()); + if (dmaapProv != null) { + String provName = dmaapName.replace("simulator", "provider"); + AtomicReference<DmaapSimProvider> provRef = new AtomicReference<>(); + addAction(provName, () -> provRef.set(buildDmaapProvider(dmaapProv)), () -> provRef.get().shutdown()); + } CdsServerParameters cdsServer = params.getGrpcServer(); // Cds Simulator - AtomicReference<CdsSimulator> cdsSim = new AtomicReference<>(); - addAction(cdsServer.getName(), () -> cdsSim.set(buildCdsSimulator(cdsServer)), () -> cdsSim.get().stop()); + if (cdsServer != null) { + AtomicReference<CdsSimulator> cdsSim = new AtomicReference<>(); + addAction(cdsServer.getName(), () -> cdsSim.set(buildCdsSimulator(cdsServer)), () -> cdsSim.get().stop()); + } // REST server simulators // @formatter:off @@ -276,7 +280,7 @@ public class Main extends ServiceManagerContainer { props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SWAGGER_SUFFIX, "false"); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true"); - if (dmaapName.equals(params.getName())) { + if (dmaapName != null && dmaapName.equals(params.getName())) { props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER, String.join(",", CambriaMessageBodyHandler.class.getName(), GsonMessageBodyHandler.class.getName(), diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java index 788829f36..4b60d5e45 100644 --- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java +++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java @@ -27,14 +27,14 @@ import lombok.Getter; import org.onap.policy.common.endpoints.parameters.TopicParameters; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.BeanValidator; -import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.common.parameters.ObjectValidationResult; +import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup; /** * Simulator parameters. */ @Getter -@NotNull public class SimulatorParameters { /** @@ -77,6 +77,24 @@ public class SimulatorParameters { public BeanValidationResult validate(String containerName) { BeanValidationResult result = new BeanValidator().validateTop(containerName, this); + if (dmaapProvider != null) { + // do not want full validation of the provider, so validate the relevant + // fields ourselves + BeanValidationResult subResult = new BeanValidationResult("dmaapProvider", dmaapProvider); + subResult.validateNotNull("name", dmaapProvider.getName()); + if (dmaapProvider.getTopicSweepSec() < 1) { + ObjectValidationResult fieldResult = + new ObjectValidationResult("topicSweepSec", dmaapProvider.getTopicSweepSec(), + ValidationStatus.INVALID, "is below the minimum value: 1"); + subResult.addResult(fieldResult); + } + result.addResult(subResult); + } + + if (grpcServer != null) { + result.addResult(grpcServer.validate()); + } + result.validateList("restServers", restServers, params -> params.validate("restServers")); result.validateList("topicServers", topicServers, params -> params.validate("topicServers")); diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java index e9e8cbdec..f5598e2e1 100644 --- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java +++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java @@ -109,7 +109,7 @@ public class MainTest { @Test public void testConstructor() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> new Main("invalidSimParameters.json")) + assertThatIllegalArgumentException().isThrownBy(() -> new Main("invalidDmaapProvider.json")) .withMessage("invalid simulator parameters"); } @@ -125,7 +125,7 @@ public class MainTest { Main.main(new String[] {PARAMETER_FILE}); // don't need to wait long, because buildXxx() does the wait for us - for (int port = 6666; port <= 6670; ++port) { + for (int port : new int[] {6666, 6667, 6668, 6669, 6670, 6680}) { assertTrue("simulator on port " + port, NetworkUtil.isTcpPortOpen(HOST, port, 1, 100)); } @@ -133,6 +133,13 @@ public class MainTest { checkAai(); } + @Test + public void testMainMinimalParameters() { + Main.main(new String[] {"minParameters.json"}); + assertNotNull(Main.getInstance()); + assertTrue(Main.getInstance().isAlive()); + } + private void checkAai() throws HttpClientConfigException { BusTopicParams params = BusTopicParams.builder().clientName("client").hostname(HOST).port(6666).useHttps(true) .allowSelfSignedCerts(true).basePath("aai").build(); diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java index 5294ca483..8094ca419 100644 --- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java +++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java @@ -20,6 +20,7 @@ package org.onap.policy.models.simulators; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -34,14 +35,51 @@ public class SimulatorParametersTest { @Test public void testValidate() throws CoderException { - // some fields missing - BeanValidationResult result = new SimulatorParameters().validate("InvalidParams"); - assertFalse(result.isValid()); - assertNotNull(result.getResult()); - - // everything populated SimulatorParameters params = new StandardCoder().decode(new File("src/test/resources/simParameters.json"), SimulatorParameters.class); assertNull(params.validate("ValidParams").getResult()); } + + @Test + public void testValidateEmptyRestServer() throws CoderException { + SimulatorParameters params = new StandardCoder() + .decode(new File("src/test/resources/emptyRestServer.json"), SimulatorParameters.class); + assertNull(params.validate("ValidParams").getResult()); + } + + @Test + public void testValidateInvalidDmaapProvider() throws CoderException { + SimulatorParameters params = new StandardCoder() + .decode(new File("src/test/resources/invalidDmaapProvider.json"), SimulatorParameters.class); + BeanValidationResult result = params.validate("InvalidDmaapParams"); + assertFalse(result.isValid()); + assertNotNull(result.getResult()); + } + + @Test + public void testValidateInvalidDmaapName() throws CoderException { + SimulatorParameters params = new StandardCoder().decode( + new File("src/test/resources/invalidDmaapName.json"), SimulatorParameters.class); + BeanValidationResult result = params.validate("InvalidDmaapParams"); + assertFalse(result.isValid()); + assertThat(result.getResult()).contains("item \"name\" value \"null\""); + } + + @Test + public void testValidateInvalidTopicSweep() throws CoderException { + SimulatorParameters params = new StandardCoder().decode( + new File("src/test/resources/invalidTopicSweep.json"), SimulatorParameters.class); + BeanValidationResult result = params.validate("InvalidDmaapParams"); + assertFalse(result.isValid()); + assertThat(result.getResult()).contains("topicSweepSec"); + } + + @Test + public void testValidateInvalidGrpcServer() throws CoderException { + SimulatorParameters params = new StandardCoder() + .decode(new File("src/test/resources/invalidGrpcServer.json"), SimulatorParameters.class); + BeanValidationResult result = params.validate("InvalidGrpcParams"); + assertFalse(result.isValid()); + assertNotNull(result.getResult()); + } } diff --git a/models-sim/policy-models-simulators/src/test/resources/emptyRestServer.json b/models-sim/policy-models-simulators/src/test/resources/emptyRestServer.json new file mode 100644 index 000000000..4a86253da --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/emptyRestServer.json @@ -0,0 +1,11 @@ +{ + "dmaapProvider": { + "name": "DMaaP simulator", + "topicSweepSec": 300, + "restServerParameters": {} + }, + "restServers": [], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidDmaapName.json b/models-sim/policy-models-simulators/src/test/resources/invalidDmaapName.json new file mode 100644 index 000000000..889c4c844 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/invalidDmaapName.json @@ -0,0 +1,10 @@ +{ + "dmaapProvider": { + "name": null, + "topicSweepSec":300 + }, + "restServers": [], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidDmaapProvider.json b/models-sim/policy-models-simulators/src/test/resources/invalidDmaapProvider.json new file mode 100644 index 000000000..ff6790144 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/invalidDmaapProvider.json @@ -0,0 +1,7 @@ +{ + "dmaapProvider": {}, + "restServers": [], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidGrpcServer.json b/models-sim/policy-models-simulators/src/test/resources/invalidGrpcServer.json new file mode 100644 index 000000000..86e425364 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/invalidGrpcServer.json @@ -0,0 +1,7 @@ +{ + "grpcServer": {}, + "restServers": [], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidSimParameters.json b/models-sim/policy-models-simulators/src/test/resources/invalidSimParameters.json deleted file mode 100644 index 2c63c0851..000000000 --- a/models-sim/policy-models-simulators/src/test/resources/invalidSimParameters.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidTopicSweep.json b/models-sim/policy-models-simulators/src/test/resources/invalidTopicSweep.json new file mode 100644 index 000000000..11a37d5c4 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/invalidTopicSweep.json @@ -0,0 +1,10 @@ +{ + "dmaapProvider": { + "name": "DMaaP simulator", + "topicSweepSec":0 + }, + "restServers": [], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/minParameters.json b/models-sim/policy-models-simulators/src/test/resources/minParameters.json new file mode 100644 index 000000000..c7ea49874 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/minParameters.json @@ -0,0 +1,14 @@ +{ + "restServers": [ + { + "name": "A&AI simulator", + "providerClass": "org.onap.policy.simulators.AaiSimulatorJaxRs", + "host": "localhost", + "port": 6766, + "https": true + } + ], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/simParameters.json b/models-sim/policy-models-simulators/src/test/resources/simParameters.json index 1d1c0aad7..df8de6ff7 100644 --- a/models-sim/policy-models-simulators/src/test/resources/simParameters.json +++ b/models-sim/policy-models-simulators/src/test/resources/simParameters.json @@ -1,10 +1,7 @@ { "dmaapProvider": { "name": "DMaaP simulator", - "topicSweepSec": 300, - "restServerParameters": { - - } + "topicSweepSec": 300 }, "restServers": [ { diff --git a/models-sim/pom.xml b/models-sim/pom.xml index ce9cfae06..40eb2a199 100644 --- a/models-sim/pom.xml +++ b/models-sim/pom.xml @@ -25,7 +25,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> <groupId>org.onap.policy.models.sim</groupId> diff --git a/models-tosca/pom.xml b/models-tosca/pom.xml index 9c79ee0a2..5369120bd 100644 --- a/models-tosca/pom.xml +++ b/models-tosca/pom.xml @@ -25,7 +25,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-tosca</artifactId> @@ -33,7 +33,7 @@ <groupId>org.onap.policy.models</groupId> <artifactId>policy-models</artifactId> - <version>2.3.2-SNAPSHOT</version> + <version>2.3.5-SNAPSHOT</version> <packaging>pom</packaging> <name>policy-models</name> diff --git a/releases/2.3.2.yaml b/releases/2.3.2.yaml new file mode 100644 index 000000000..775ce71a4 --- /dev/null +++ b/releases/2.3.2.yaml @@ -0,0 +1,4 @@ +distribution_type: 'maven' +version: '2.3.2' +project: 'policy-models' +log_dir: 'policy-models-maven-stage-master/493/' diff --git a/releases/2.3.3.yaml b/releases/2.3.3.yaml new file mode 100644 index 000000000..bf62bbaec --- /dev/null +++ b/releases/2.3.3.yaml @@ -0,0 +1,4 @@ +distribution_type: 'maven' +version: '2.3.3' +project: 'policy-models' +log_dir: 'policy-models-maven-stage-master/495/' diff --git a/releases/2.3.4.yaml b/releases/2.3.4.yaml new file mode 100644 index 000000000..164a967f5 --- /dev/null +++ b/releases/2.3.4.yaml @@ -0,0 +1,4 @@ +distribution_type: 'maven' +version: '2.3.4' +project: 'policy-models' +log_dir: 'policy-models-maven-stage-master/496/' diff --git a/version.properties b/version.properties index 16dbea1c3..c0e0acab4 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=2 minor=3 -patch=2 +patch=5 base_version=${major}.${minor}.${patch} |