aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.cds/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-08-18 09:39:19 -0400
committerJim Hahn <jrh3@att.com>2020-08-18 17:11:52 -0400
commit8722cb8a654ddcdcb472546a58809e041fe84eba (patch)
treeeba3aee017377733f6a44840a58fc322f7e4f807 /models-interactions/model-actors/actor.cds/src
parentca3827f43ada2b160f6966d205ca97d4402a0935 (diff)
Make targetEntity a property
The target entity is not always known when an Operation is first constructed, thus it should be treated as an Operation property instead of being included within the ControlLoopParams. Started the process of moving it from the Params to the properties. Also fixed a bug in custom query - it was setting the outcome response to the String response instead of setting it to the AaiCqResponse object. Also added logging when an Operation's properties are set. Issue-ID: POLICY-2746 Change-Id: I56c0cd90985f6140363548b0b8d031471b586e88 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.cds/src')
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java34
1 files changed, 16 insertions, 18 deletions
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 2e9935f82..512349555 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
@@ -151,9 +151,9 @@ public class GrpcOperationTest {
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).target(target)
+ .build();
}
/**
@@ -166,10 +166,9 @@ 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).retry(0)
- .timeoutSec(5).executor(blockingExecutor).payload(payload).build();
+ params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe")
+ .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target)
+ .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload).build();
cdsProps.setHost("localhost");
cdsProps.setPort(sim.getPort());
@@ -181,7 +180,7 @@ public class GrpcOperationTest {
@Override
protected CompletableFuture<OperationOutcome> startGuardAsync() {
// indicate that guard completed successfully
- return CompletableFuture.completedFuture(params.makeOutcome());
+ return CompletableFuture.completedFuture(params.makeOutcome(null));
}
};
@@ -200,10 +199,9 @@ 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).retry(0)
- .timeoutSec(5).executor(blockingExecutor).payload(payload).preprocessed(true).build();
+ params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe")
+ .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target)
+ .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload).preprocessed(true).build();
cdsProps.setHost("localhost");
cdsProps.setPort(sim.getPort());
@@ -260,8 +258,7 @@ public class GrpcOperationTest {
operation = new GrpcOperation(params, config);
// in neither property nor context
- assertThatIllegalArgumentException().isThrownBy(() -> operation.getPnfData())
- .withMessage("missing PNF data");
+ assertThatIllegalArgumentException().isThrownBy(() -> operation.getPnfData()).withMessage("missing PNF data");
// only in context
Pnf pnf = new Pnf();
@@ -335,7 +332,7 @@ public class GrpcOperationTest {
assertTrue(guardStarted.get());
verify(context).obtain(eq(AaiCqResponse.CONTEXT_KEY), any());
- cqFuture.complete(params.makeOutcome());
+ cqFuture.complete(params.makeOutcome(null));
assertTrue(executor.runAll(100));
assertEquals(PolicyResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult());
assertTrue(future3.isDone());
@@ -363,7 +360,7 @@ public class GrpcOperationTest {
assertTrue(guardStarted.get());
verify(context).obtain(eq(AaiGetPnfOperation.getKey(TARGET_ENTITY)), any());
- cqFuture.complete(params.makeOutcome());
+ cqFuture.complete(params.makeOutcome(null));
assertTrue(executor.runAll(100));
assertEquals(PolicyResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult());
assertTrue(future3.isDone());
@@ -415,7 +412,8 @@ public class GrpcOperationTest {
@Test
public void testStartOperationAsyncError() throws Exception {
operation = new GrpcOperation(params, config);
- assertThatIllegalArgumentException().isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome(null)));
}
@Test
@@ -457,7 +455,7 @@ public class GrpcOperationTest {
assertEquals(1000, operation.getTimeoutMs(0));
assertEquals(2000, operation.getTimeoutMs(2));
operation.generateSubRequestId(1);
- CompletableFuture<OperationOutcome> future3 = operation.startOperationAsync(1, params.makeOutcome());
+ CompletableFuture<OperationOutcome> future3 = operation.startOperationAsync(1, params.makeOutcome(null));
assertNotNull(future3);
}