aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.cds/src
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2020-08-27 08:44:12 -0400
committerPamela Dragosh <pdragosh@research.att.com>2020-08-27 14:29:09 -0400
commitf456cc5c8e1efd15edb6da718e1428d8fd7c66c5 (patch)
treeb7b4ba3fc6255b056e00f6e203d7ec8fd6a7c194 /models-interactions/model-actors/actor.cds/src
parent68a60a45f27287a4a523c82ef466cbeec655f641 (diff)
Remove Target and TargetType
The dependency should have been removed in the last review to remove SDC and policy-yaml legacy code. It was revealed that usage of TargetType and Type were spread out over the actor code. Those fields are represented differently in the new TOSCA Operational Policy Type, so fields were created to capture those values to be used by actor code. Issue-ID: POLICY-2428 Change-Id: Ib783526a518ca7942ae9e38019bd343639f4dd98 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.cds/src')
-rw-r--r--models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java6
-rw-r--r--models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java9
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java6
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java44
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java7
5 files changed, 37 insertions, 35 deletions
diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java
index d0f5bd2b4..4da23f1a8 100644
--- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java
+++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java
@@ -23,7 +23,7 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.policy.cds.api.CdsProcessorListener;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
-import org.onap.policy.controlloop.policy.PolicyResult;
+import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,12 +61,12 @@ public class CdsActorServiceManager implements CdsProcessorListener {
LOGGER.info("CDS is processing the message: {}", message);
break;
case EVENT_COMPONENT_EXECUTED:
- outcome.setResult(PolicyResult.SUCCESS);
+ outcome.setResult(OperationResult.SUCCESS);
outcome.setResponse(message);
future.complete(outcome);
break;
default:
- outcome.setResult(PolicyResult.FAILURE);
+ outcome.setResult(OperationResult.FAILURE);
outcome.setResponse(message);
future.complete(outcome);
break;
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 d3842441d..c04453b7c 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
@@ -50,11 +50,11 @@ import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actor.cds.request.CdsActionRequest;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture;
-import org.onap.policy.controlloop.policy.TargetType;
/**
* Operation that uses gRPC to send request to CDS.
@@ -111,7 +111,7 @@ public class GrpcOperation extends OperationPartial {
super(params, config, Collections.emptyList());
this.config = config;
- if (TargetType.PNF.equals(params.getTarget().getType())) {
+ if (TargetType.PNF.equals(params.getTargetType())) {
aaiRequestor = this::getPnf;
aaiConverter = this::convertPnfToAaiProperties;
} else {
@@ -122,7 +122,7 @@ public class GrpcOperation extends OperationPartial {
@Override
public List<String> getPropertyNames() {
- return (TargetType.PNF.equals(params.getTarget().getType()) ? PNF_PROPERTY_NAMES : VNF_PROPERTY_NAMES);
+ return (TargetType.PNF.equals(params.getTargetType()) ? PNF_PROPERTY_NAMES : VNF_PROPERTY_NAMES);
}
/**
@@ -259,7 +259,8 @@ public class GrpcOperation extends OperationPartial {
AaiCqResponse aaicq = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY);
- genericVnf = aaicq.getGenericVnfByModelInvariantId(params.getTarget().getResourceID());
+ genericVnf = aaicq.getGenericVnfByModelInvariantId(params.getTargetEntityIds()
+ .get(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID));
if (genericVnf == null) {
throw new IllegalArgumentException("Target generic vnf could not be found");
}
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java
index 908b05c08..07a05e6b8 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java
@@ -36,7 +36,7 @@ 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.ExecutionServiceOutput;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
-import org.onap.policy.controlloop.policy.PolicyResult;
+import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
public class GrpcActorServiceManagerTest {
@@ -61,7 +61,7 @@ public class GrpcActorServiceManagerTest {
output = ExecutionServiceOutput.newBuilder().setStatus(status).build();
manager.onMessage(output);
OperationOutcome outcome = future.get(2, TimeUnit.SECONDS);
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertSame(output, outcome.getResponse());
}
@@ -82,7 +82,7 @@ public class GrpcActorServiceManagerTest {
output = ExecutionServiceOutput.newBuilder().setStatus(status).build();
manager.onMessage(output);
OperationOutcome outcome = future.get(2, TimeUnit.SECONDS);
- assertEquals(PolicyResult.FAILURE, outcome.getResult());
+ assertEquals(OperationResult.FAILURE, outcome.getResult());
assertSame(output, outcome.getResponse());
}
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
index 512349555..709e179e6 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
@@ -69,11 +69,10 @@ import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.policy.PolicyResult;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.simulators.CdsSimulator;
import org.onap.policy.simulators.Util;
@@ -102,7 +101,8 @@ public class GrpcOperationTest {
private CdsServerProperties cdsProps;
private VirtualControlLoopEvent onset;
private PseudoExecutor executor;
- private Target target;
+ private TargetType targetType;
+ private Map<String, String> targetEntityIds;
private ControlLoopOperationParams params;
private GrpcConfig config;
private CompletableFuture<OperationOutcome> cqFuture;
@@ -143,17 +143,18 @@ public class GrpcOperationTest {
// Setup executor
executor = new PseudoExecutor();
- target = new Target();
- target.setType(TargetType.VM);
- target.setResourceID(RESOURCE_ID);
+ targetType = TargetType.VM;
+ targetEntityIds = new HashMap<>();
+ targetEntityIds.put(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, RESOURCE_ID);
cqFuture = new CompletableFuture<>();
when(context.obtain(eq(AaiCqResponse.CONTEXT_KEY), any())).thenReturn(cqFuture);
when(context.getEvent()).thenReturn(onset);
- params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation(GrpcOperation.NAME)
- .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target)
- .build();
+ params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
+ .operation(GrpcOperation.NAME).context(context).actorService(new ActorService())
+ .targetEntity(TARGET_ENTITY).targetType(targetType).targetEntityIds(targetEntityIds)
+ .build();
}
/**
@@ -167,7 +168,8 @@ public class GrpcOperationTest {
Map<String, Object> payload = Map.of("artifact_name", "my_artifact", "artifact_version", "1.0");
params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe")
- .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target)
+ .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY)
+ .targetType(targetType).targetEntityIds(targetEntityIds)
.retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload).build();
cdsProps.setHost("localhost");
@@ -185,7 +187,7 @@ public class GrpcOperationTest {
};
OperationOutcome outcome = operation.start().get();
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof ExecutionServiceOutput);
}
@@ -200,7 +202,8 @@ public class GrpcOperationTest {
Map<String, Object> payload = Map.of("artifact_name", "my_artifact", "artifact_version", "1.0");
params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe")
- .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target)
+ .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY)
+ .targetType(targetType).targetEntityIds(targetEntityIds)
.retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload).preprocessed(true).build();
cdsProps.setHost("localhost");
@@ -215,7 +218,7 @@ public class GrpcOperationTest {
operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES, Collections.emptyMap());
OperationOutcome outcome = operation.start().get();
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof ExecutionServiceOutput);
}
@@ -239,7 +242,7 @@ public class GrpcOperationTest {
/*
* check PNF case
*/
- target.setType(TargetType.PNF);
+ params = params.toBuilder().targetType(TargetType.PNF).build();
operation = new GrpcOperation(params, config);
// @formatter:off
@@ -334,7 +337,7 @@ public class GrpcOperationTest {
cqFuture.complete(params.makeOutcome(null));
assertTrue(executor.runAll(100));
- assertEquals(PolicyResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult());
+ assertEquals(OperationResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult());
assertTrue(future3.isDone());
}
@@ -345,7 +348,7 @@ public class GrpcOperationTest {
public void testStartPreprocessorAsyncPnf() throws InterruptedException, ExecutionException, TimeoutException {
AtomicBoolean guardStarted = new AtomicBoolean();
- target.setType(TargetType.PNF);
+ params = params.toBuilder().targetType(TargetType.PNF).build();
operation = new GrpcOperation(params, config) {
@Override
@@ -362,7 +365,7 @@ public class GrpcOperationTest {
cqFuture.complete(params.makeOutcome(null));
assertTrue(executor.runAll(100));
- assertEquals(PolicyResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult());
+ assertEquals(OperationResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult());
assertTrue(future3.isDone());
}
@@ -390,7 +393,7 @@ public class GrpcOperationTest {
@Test
public void testStartOperationAsyncPnf() throws Exception {
- target.setType(TargetType.PNF);
+ targetType = TargetType.PNF;
ControlLoopEventContext context = new ControlLoopEventContext(onset);
loadPnfData(context);
@@ -447,7 +450,8 @@ public class GrpcOperationTest {
ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
.operation(GrpcOperation.NAME).context(context).actorService(new ActorService())
- .targetEntity(TARGET_ENTITY).target(target).payload(payloadMap).build();
+ .targetEntity(TARGET_ENTITY).targetType(targetType).targetEntityIds(targetEntityIds)
+ .payload(payloadMap).build();
GrpcConfig config = new GrpcConfig(executor, cdsProps);
operation = new GrpcOperation(params, config);
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java
index cfb20ab6c..11121c0b3 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java
@@ -32,12 +32,11 @@ import org.onap.policy.cds.properties.CdsServerProperties;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
public class GrpcOperatorTest {
@@ -88,10 +87,8 @@ public class GrpcOperatorTest {
public void testBuildOperation() {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
ControlLoopEventContext context = new ControlLoopEventContext(event);
- Target target = new Target();
- target.setType(TargetType.VM);
ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
- .operation(GrpcOperation.NAME).context(context).target(target).build();
+ .operation(GrpcOperation.NAME).context(context).targetType(TargetType.VM).build();
// not configured yet
assertThatIllegalStateException().isThrownBy(() -> operation.buildOperation(params));