aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/controller-usecases/src/test
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2020-08-28 17:28:37 +0000
committerGerrit Code Review <gerrit@onap.org>2020-08-28 17:28:37 +0000
commit383201bf1f1c81a6affd1cf4ad22121869b95513 (patch)
tree07ddcab3dda5431b8f3edba2a60e486732e12cc3 /controlloop/common/controller-usecases/src/test
parentffdf210ad1e3f18dcc612e2587ed6d3742ab1e24 (diff)
parent3052f10337897ea25983f35f4158c5626febbe7d (diff)
Merge "Use ToscaPolicy instead of legacy Policy"
Diffstat (limited to 'controlloop/common/controller-usecases/src/test')
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java51
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java9
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java43
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java57
4 files changed, 61 insertions, 99 deletions
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java
index 238ac3d70..efa27a6ec 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java
@@ -39,10 +39,9 @@ import org.mockito.MockitoAnnotations;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
public class GetTargetEntityOperation2Test {
private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id";
@@ -59,7 +58,6 @@ public class GetTargetEntityOperation2Test {
private ControlLoopOperationParams params;
private VirtualControlLoopEvent event;
- private Target target;
private GenericVnf vnf;
private GetTargetEntityOperation2 oper;
@@ -74,13 +72,10 @@ public class GetTargetEntityOperation2Test {
event.setTarget("pnf.pnf-name");
event.setAai(Map.of("pnf.pnf-name", MY_PNF));
- target = new Target();
- target.setType(TargetType.PNF);
-
vnf = new GenericVnf();
vnf.setVnfId(MY_VNF);
- when(params.getTarget()).thenReturn(target);
+ when(params.getTargetType()).thenReturn(TargetType.PNF);
when(params.getActor()).thenReturn(MY_ACTOR);
when(params.getOperation()).thenReturn(MY_OPERATION);
@@ -124,24 +119,12 @@ public class GetTargetEntityOperation2Test {
}
/**
- * Tests detmTarget() when the target is {@code null}.
- */
- @Test
- public void testDetmTargetNull() {
- remakeWithoutData();
- when(params.getTarget()).thenReturn(null);
-
- assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
- .withMessage("The target is null");
- }
-
- /**
* Tests detmTarget() when the target type is {@code null}.
*/
@Test
public void testDetmTargetNullType() {
remakeWithoutData();
- target.setType(null);
+ when(params.getTargetType()).thenReturn(null);
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
.withMessage("The target type is null");
@@ -152,7 +135,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmTargetVm() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
verifyTarget(MY_VNF);
@@ -163,7 +146,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmTargetVnf() {
- target.setType(TargetType.VNF);
+ when(params.getTargetType()).thenReturn(TargetType.VNF);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
verifyTarget(MY_VNF);
@@ -175,7 +158,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmTargetVfModule() {
- target.setType(TargetType.VFMODULE);
+ when(params.getTargetType()).thenReturn(TargetType.VFMODULE);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
verifyTarget(MY_VNF);
@@ -186,7 +169,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmTargetUnknownType() {
- target.setType(TargetType.VFC);
+ when(params.getTargetType()).thenReturn(TargetType.VFC);
enrichTarget(VSERVER_NAME);
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
.withMessage("The target type is not supported");
@@ -223,7 +206,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVfModuleTargetNullTarget() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(null);
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()).withMessage("Target is null");
}
@@ -233,7 +216,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVfModuleTargetVserverName() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
verifyTarget(MY_VNF);
@@ -244,7 +227,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVfModuleTargetVnfId() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(GENERIC_VNF_ID);
assertThat(oper.getPropertyNames()).isEmpty();
verifyTarget(MY_VNF);
@@ -256,7 +239,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVfModuleTargetVnfName() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(GENERIC_VNF_ID);
// set this AFTER setting enrichment data
@@ -271,7 +254,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVfModuleTargetUnknown() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(VSERVER_NAME);
event.setTarget("unknown-vnf");
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
@@ -283,7 +266,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVfModuleTargetMissingEnrichment() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(VSERVER_NAME);
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
.withMessage("Enrichment data is missing " + VSERVER_NAME);
@@ -294,7 +277,7 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVnfNameHaveData() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(GENERIC_VNF_NAME);
event.setAai(Map.of(GENERIC_VNF_ID, MY_VNF));
assertThat(oper.getPropertyNames()).isEmpty();
@@ -306,14 +289,14 @@ public class GetTargetEntityOperation2Test {
*/
@Test
public void testDetmVnfNameNoData() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(GENERIC_VNF_NAME);
assertThat(oper.getPropertyNames()).isEqualTo(List.of(UsecasesConstants.AAI_DEFAULT_GENERIC_VNF));
}
@Test
public void testSetProperty() {
- target.setType(TargetType.VM);
+ when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(GENERIC_VNF_NAME);
// not a property of interest - should be ignored
@@ -336,7 +319,7 @@ public class GetTargetEntityOperation2Test {
}
private void remakeWithoutData() {
- target.setType(TargetType.VNF);
+ when(params.getTargetType()).thenReturn(TargetType.VNF);
event.setTarget(GENERIC_VNF_NAME);
oper = new GetTargetEntityOperation2(stepContext, event, params);
}
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java
index dfbedc2c7..42fd9e4e4 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java
@@ -39,10 +39,9 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
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.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
public class LockOperation2Test {
private static final String MY_PNF = "my-pnf";
@@ -56,7 +55,6 @@ public class LockOperation2Test {
private ControlLoopOperationParams params;
private VirtualControlLoopEvent event;
- private Target target;
private CompletableFuture<OperationOutcome> future;
private GenericVnf vnf;
private LockOperation2 oper;
@@ -72,9 +70,6 @@ public class LockOperation2Test {
event.setTarget("pnf.pnf-name");
event.setAai(Map.of("pnf.pnf-name", MY_PNF));
- target = new Target();
- target.setType(TargetType.PNF);
-
future = new CompletableFuture<>();
vnf = new GenericVnf();
@@ -82,7 +77,7 @@ public class LockOperation2Test {
when(stepContext.requestLock(anyString())).thenReturn(future);
- when(params.getTarget()).thenReturn(target);
+ when(params.getTargetType()).thenReturn(TargetType.PNF);
when(params.getActor()).thenReturn(MY_ACTOR);
when(params.getOperation()).thenReturn(MY_OPERATION);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
index 05bc03a60..6681c3ef3 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
@@ -66,19 +66,18 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
+import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult;
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.Operator;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.controlloop.eventmanager.ActorConstants;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2;
import org.onap.policy.controlloop.ophistory.OperationHistoryDataManager;
-import org.onap.policy.controlloop.policy.FinalResult;
-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.drools.apps.controller.usecases.UsecasesEventManager.NewEventStatus;
import org.onap.policy.drools.apps.controller.usecases.step.AaiCqStep2;
import org.onap.policy.drools.apps.controller.usecases.step.AaiGetPnfStep2;
@@ -137,7 +136,6 @@ public class UsecasesEventManagerTest {
private Step2 stepb;
private List<LockImpl> locks;
- private Target target;
private ToscaPolicy tosca;
private ControlLoopParams params;
private VirtualControlLoopEvent event;
@@ -163,10 +161,7 @@ public class UsecasesEventManagerTest {
event.setAai(new TreeMap<>(Map.of(UsecasesConstants.VSERVER_VSERVER_NAME, MY_TARGET)));
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setClosedLoopControlName(CL_NAME);
- event.setTargetType(TargetType.VNF.toString());
-
- target = new Target();
- target.setType(TargetType.VNF);
+ event.setTargetType(ControlLoopTargetType.VNF);
params = new ControlLoopParams();
params.setClosedLoopControlName(CL_NAME);
@@ -299,14 +294,14 @@ public class UsecasesEventManagerTest {
@Test
public void testAbort() {
- mgr.abort(UsecasesEventManager.State.DONE, FinalResult.FINAL_FAILURE_GUARD, "some message");
+ mgr.abort(UsecasesEventManager.State.DONE, OperationFinalResult.FINAL_FAILURE_GUARD, "some message");
assertEquals(UsecasesEventManager.State.DONE, mgr.getState());
- assertEquals(FinalResult.FINAL_FAILURE_GUARD, mgr.getFinalResult());
+ assertEquals(OperationFinalResult.FINAL_FAILURE_GUARD, mgr.getFinalResult());
assertEquals("some message", mgr.getFinalMessage());
// try null state
- assertThatThrownBy(() -> mgr.abort(null, FinalResult.FINAL_FAILURE_GUARD, ""))
+ assertThatThrownBy(() -> mgr.abort(null, OperationFinalResult.FINAL_FAILURE_GUARD, ""))
.isInstanceOf(NullPointerException.class).hasMessageContaining("finalState");
}
@@ -325,7 +320,7 @@ public class UsecasesEventManagerTest {
mgr.addToHistory(outcome);
// indicate success and load next policy
- mgr.loadNextPolicy(PolicyResult.SUCCESS);
+ mgr.loadNextPolicy(OperationResult.SUCCESS);
assertEquals("OperationB", mgr.getSteps().poll().getOperationName());
assertNull(mgr.getFinalResult());
@@ -334,8 +329,8 @@ public class UsecasesEventManagerTest {
assertThat(mgr.getFullHistory()).hasSize(1);
// indicate failure - should go to final failure
- mgr.loadNextPolicy(PolicyResult.FAILURE);
- assertEquals(FinalResult.FINAL_FAILURE, mgr.getFinalResult());
+ mgr.loadNextPolicy(OperationResult.FAILURE);
+ assertEquals(OperationFinalResult.FINAL_FAILURE, mgr.getFinalResult());
}
@Test
@@ -354,7 +349,8 @@ public class UsecasesEventManagerTest {
assertSame(actors, params2.getActorService());
assertSame(REQ_ID, params2.getRequestId());
assertSame(ForkJoinPool.commonPool(), params2.getExecutor());
- assertNotNull(params2.getTarget());
+ assertNotNull(params2.getTargetType());
+ assertNotNull(params2.getTargetEntityIds());
assertEquals(Integer.valueOf(300), params2.getTimeoutSec());
assertEquals(Integer.valueOf(0), params2.getRetry());
assertThat(params2.getPayload()).isEmpty();
@@ -508,7 +504,10 @@ public class UsecasesEventManagerTest {
*/
@Test
public void testLoadPreprocessorStepsNeedTargetEntity() {
- stepa = new Step2(mgr, ControlLoopOperationParams.builder().target(target).build(), event) {
+ stepa = new Step2(mgr,
+ ControlLoopOperationParams.builder()
+ .targetType(TargetType.toTargetType(event.getTargetType()))
+ .targetEntityIds(Map.of()).build(), event) {
@Override
public List<String> getPropertyNames() {
return List.of(OperationProperties.AAI_TARGET_ENTITY);
@@ -586,7 +585,7 @@ public class UsecasesEventManagerTest {
@Test
public void testIsAbort() {
OperationOutcome outcome = makeCompletedOutcome();
- outcome.setResult(PolicyResult.FAILURE);
+ outcome.setResult(OperationResult.FAILURE);
// closed loop timeout
outcome.setActor(ActorConstants.CL_TIMEOUT_ACTOR);
@@ -597,7 +596,7 @@ public class UsecasesEventManagerTest {
assertTrue(mgr.isAbort(outcome));
// no effect for success
- outcome.setResult(PolicyResult.SUCCESS);
+ outcome.setResult(OperationResult.SUCCESS);
assertFalse(mgr.isAbort(outcome));
}
@@ -673,7 +672,7 @@ public class UsecasesEventManagerTest {
assertThat(notif.getHistory()).hasSize(3);
// indicate success and load the next policy - should clear the partial history
- mgr.loadNextPolicy(PolicyResult.SUCCESS);
+ mgr.loadNextPolicy(OperationResult.SUCCESS);
// check notification
notif = mgr.makeNotification();
@@ -691,7 +690,7 @@ public class UsecasesEventManagerTest {
assertThat(notif.getHistory()).hasSize(2);
// indicate failure - should go to final state
- mgr.loadNextPolicy(PolicyResult.FAILURE);
+ mgr.loadNextPolicy(OperationResult.FAILURE);
// check notification
notif = mgr.makeNotification();
@@ -1016,7 +1015,7 @@ public class UsecasesEventManagerTest {
outcome.setActor(SIMPLE_ACTOR);
outcome.setOperation(SIMPLE_OPERATION);
outcome.setMessage(OUTCOME_MSG);
- outcome.setResult(PolicyResult.SUCCESS);
+ outcome.setResult(OperationResult.SUCCESS);
outcome.setStart(Instant.now());
outcome.setTarget(MY_TARGET);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
index 75fe486ed..d01e2b5a0 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -62,26 +63,21 @@ import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
+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.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager2;
import org.onap.policy.controlloop.eventmanager.StepContext;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
public class Step2Test {
private static final UUID REQ_ID = UUID.randomUUID();
- private static final String POLICY_ID = "my-policy";
private static final String POLICY_ACTOR = "my-actor";
private static final String POLICY_OPERATION = "my-operation";
private static final String MY_TARGET = "my-target";
private static final String PAYLOAD_KEY = "payload-key";
private static final String PAYLOAD_VALUE = "payload-value";
- private static final Integer POLICY_RETRY = 3;
- private static final Integer POLICY_TIMEOUT = 20;
private static final String NO_SLASH = "noslash";
private static final String ONE_SLASH = "/one";
@@ -99,9 +95,7 @@ public class Step2Test {
private AaiCqResponse aaicq;
private CompletableFuture<OperationOutcome> future;
- private Target target;
private Map<String, String> payload;
- private Policy policy;
private VirtualControlLoopEvent event;
private ControlLoopEventContext context;
private BlockingQueue<OperationOutcome> starts;
@@ -128,20 +122,8 @@ public class Step2Test {
when(stepContext.getProperty(AaiCqResponse.CONTEXT_KEY)).thenReturn(aaicq);
- target = new Target();
- target.setType(TargetType.VM);
-
payload = Map.of(PAYLOAD_KEY, PAYLOAD_VALUE);
- policy = new Policy();
- policy.setId(POLICY_ID);
- policy.setActor(POLICY_ACTOR);
- policy.setRecipe(POLICY_OPERATION);
- policy.setTarget(target);
- policy.setPayload(payload);
- policy.setRetry(POLICY_RETRY);
- policy.setTimeout(POLICY_TIMEOUT);
-
event = new VirtualControlLoopEvent();
event.setRequestId(REQ_ID);
event.setTarget(ControlLoopOperationManager2.VSERVER_VSERVER_NAME);
@@ -152,10 +134,13 @@ public class Step2Test {
starts = new LinkedBlockingQueue<>();
completions = new LinkedBlockingQueue<>();
+ Map<String, String> entityIds = new HashMap<>();
+
params = ControlLoopOperationParams.builder().actor(POLICY_ACTOR).actorService(actors)
.completeCallback(completions::add).context(context).executor(ForkJoinPool.commonPool())
.operation(POLICY_OPERATION).payload(new TreeMap<>(payload)).startCallback(starts::add)
- .target(target).targetEntity(MY_TARGET).build();
+ .targetType(TargetType.VM).targetEntityIds(entityIds).targetEntity(MY_TARGET)
+ .build();
step = new Step2(stepContext, params, event);
step.init();
@@ -268,7 +253,7 @@ public class Step2Test {
@Test
public void testLoadResourceVnf_testGetResourceVnf() {
- target.setResourceID("my-resource");
+ params.getTargetEntityIds().put(Step2.TARGET_RESOURCE_ID, "my-resource");
GenericVnf data = new GenericVnf();
when(aaicq.getGenericVnfByModelInvariantId("my-resource")).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_RESOURCE_VNF));
@@ -277,12 +262,12 @@ public class Step2Test {
verify(policyOperation).setProperty(OperationProperties.AAI_RESOURCE_VNF, data);
// missing resource ID
- target.setResourceID(null);
+ params.getTargetEntityIds().put(Step2.TARGET_RESOURCE_ID, null);
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
.withMessageContaining("missing Target resource ID");
- // missing target
- params = params.toBuilder().target(null).build();
+ // missing target entity IDs
+ params = params.toBuilder().targetEntityIds(null).build();
step = new Step2(stepContext, params, event);
step.init();
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
@@ -315,7 +300,7 @@ public class Step2Test {
@Test
public void testLoadVnf_testGetVnf() {
- target.setModelInvariantId("my-model-invariant");
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "my-model-invariant");
GenericVnf data = new GenericVnf();
when(aaicq.getGenericVnfByVfModuleModelInvariantId("my-model-invariant")).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_VNF));
@@ -324,12 +309,12 @@ public class Step2Test {
verify(policyOperation).setProperty(OperationProperties.AAI_VNF, data);
// missing model invariant ID
- target.setModelInvariantId(null);
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, null);
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
.withMessageContaining("missing modelInvariantId");
// missing target
- params = params.toBuilder().target(null).build();
+ params = params.toBuilder().targetEntityIds(null).build();
step = new Step2(stepContext, params, event);
step.init();
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
@@ -338,7 +323,7 @@ public class Step2Test {
@Test
public void testLoadVnfModel_testGetVnfModel() {
- target.setModelInvariantId("my-model-invariant");
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "my-model-invariant");
GenericVnf vnf = new GenericVnf();
when(aaicq.getGenericVnfByVfModuleModelInvariantId("my-model-invariant")).thenReturn(vnf);
@@ -388,9 +373,9 @@ public class Step2Test {
@Test
public void testLoadVfCount_testGetVfCount() {
- target.setModelCustomizationId("vf-count-customization");
- target.setModelInvariantId("vf-count-invariant");
- target.setModelVersionId("vf-count-version");
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_CUSTOMIZATION_ID, "vf-count-customization");
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "vf-count-invariant");
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_VERSION_ID, "vf-count-version");
when(aaicq.getVfModuleCount("vf-count-customization", "vf-count-invariant", "vf-count-version")).thenReturn(11);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.DATA_VF_COUNT));
@@ -398,22 +383,22 @@ public class Step2Test {
verify(policyOperation).setProperty(OperationProperties.DATA_VF_COUNT, 11);
// missing model version id
- target.setModelVersionId(null);
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_VERSION_ID, null);
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
.withMessageContaining("missing target modelVersionId");
// missing model invariant id
- target.setModelInvariantId(null);
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, null);
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
.withMessageContaining("missing target modelInvariantId");
// missing model customization id
- target.setModelCustomizationId(null);
+ params.getTargetEntityIds().put(Step2.TARGET_MODEL_CUSTOMIZATION_ID, null);
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
.withMessageContaining("missing target modelCustomizationId");
// missing target
- params = params.toBuilder().target(null).build();
+ params = params.toBuilder().targetEntityIds(null).build();
step = new Step2(stepContext, params, event);
step.init();
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())