aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-04-16 18:51:40 -0400
committerJim Hahn <jrh3@att.com>2020-04-16 18:51:40 -0400
commitbed21af59885a954e3facf7226c4678f4b69b153 (patch)
treefd6afa35a22b24fb1745ab2de8f17cf778ed41a6 /models-interactions/model-actors
parent955b479749ef6127a63498dcc147aa4c387137aa (diff)
CDS Operator should be generic
Like the SDNR Operator, the CDS Operator should work regardless of the operation name. Issue-ID: POLICY-2504 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I9a77838462bc5b91e2d95e7dcf1f8822bd45f04c
Diffstat (limited to 'models-interactions/model-actors')
-rw-r--r--models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java13
-rw-r--r--models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java3
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java12
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/resources/service.yaml2
4 files changed, 26 insertions, 4 deletions
diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java
index e3b91f2c4..9e136f09e 100644
--- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java
@@ -48,14 +48,15 @@ import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actor.cds.request.CdsActionRequest;
+import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.actorserviceprovider.impl.ActorImpl;
import org.onap.policy.controlloop.policy.Policy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * CDS Actor service-provider implementation. This is a deploy dark feature for El-Alto
- * release.
+ * CDS is an unusual actor in that it uses a single, generic operator to initiate all
+ * operation types. The action taken is always the same, only the operation name changes.
*/
public class CdsActorServiceProvider extends ActorImpl {
@@ -70,6 +71,14 @@ public class CdsActorServiceProvider extends ActorImpl {
addOperator(new GrpcOperator(CdsActorConstants.CDS_ACTOR, GrpcOperation.NAME, GrpcOperation::new));
}
+ @Override
+ public Operator getOperator(String name) {
+ /*
+ * All operations are managed by the same operator, regardless of the name.
+ */
+ return super.getOperator(GrpcOperation.NAME);
+ }
+
// TODO old code: remove lines down to **HERE**
/**
diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java
index e57bc041f..702802d48 100644
--- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java
+++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
+ * 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.
@@ -51,7 +52,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
@Getter
public class GrpcOperation extends OperationPartial {
- public static final String NAME = "gRPC";
+ public static final String NAME = "any";
private CdsProcessorGrpcClient client;
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java
index 9c59e5648..73787da3f 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.controlloop.actor.cds;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
@@ -57,6 +58,7 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.cds.CdsActorServiceProvider.CdsActorServiceManager;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actor.test.BasicActor;
+import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.policy.Policy;
public class CdsActorServiceProviderTest extends BasicActor {
@@ -135,6 +137,16 @@ public class CdsActorServiceProviderTest extends BasicActor {
}
@Test
+ public void testGetOperator() {
+ CdsActorServiceProvider sp = new CdsActorServiceProvider();
+
+ // should always return the same operator regardless of the name
+ Operator oper = sp.getOperator("unknown");
+ assertNotNull(oper);
+ assertSame(oper, sp.getOperator("another"));
+ }
+
+ @Test
public void testConstructRequestWhenMissingCdsParamsInPolicyPayload() {
policy.setPayload(new HashMap<>());
Optional<ExecutionServiceInput> cdsRequestOpt = cdsActor.constructRequest(onset, operation, policy, aaiParams);
diff --git a/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml b/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml
index d48b4542f..0d3c76f48 100644
--- a/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml
+++ b/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml
@@ -19,7 +19,7 @@
#
actors:
CDS:
- gRPC:
+ any:
timeout: 10
port: 6700
host: my-host