aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src/test
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.so/src/test
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.so/src/test')
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java22
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java50
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java15
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java15
4 files changed, 47 insertions, 55 deletions
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
index 3541333c0..d2e2872d5 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
@@ -34,9 +34,10 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.Util;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
-import org.onap.policy.controlloop.policy.Target;
import org.onap.policy.simulators.SoSimulatorJaxRs;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequestParameters;
@@ -65,7 +66,8 @@ public abstract class BasicSoOperation extends BasicHttpOperation {
@Mock
protected HttpPollingConfig config;
- protected Target target;
+ protected TargetType targetType;
+ protected Map<String, String> targetEntities = new HashMap<>();
protected SoResponse response;
/**
@@ -144,14 +146,16 @@ public abstract class BasicSoOperation extends BasicHttpOperation {
protected void makeContext() {
super.makeContext();
- target = new Target();
- target.setModelCustomizationId(MODEL_CUSTOM_ID);
- target.setModelInvariantId(MODEL_INVAR_ID);
- target.setModelName(MODEL_NAME);
- target.setModelVersion(MODEL_VERSION);
- target.setModelVersionId(MODEL_VERS_ID);
+ targetType = TargetType.VNF;
- params = params.toBuilder().target(target).build();
+ targetEntities = new HashMap<>();
+ targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID, MODEL_CUSTOM_ID);
+ targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID, MODEL_INVAR_ID);
+ targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_NAME, MODEL_NAME);
+ targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION, MODEL_VERSION);
+ targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION_ID, MODEL_VERS_ID);
+
+ params = params.toBuilder().targetType(targetType).targetEntityIds(targetEntities).build();
}
@Override
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
index e364246e4..464e5d162 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
@@ -35,9 +35,9 @@ import java.time.LocalDateTime;
import java.time.Month;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
-import java.util.function.Consumer;
import java.util.function.Supplier;
import org.junit.Before;
import org.junit.Test;
@@ -52,7 +52,8 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
-import org.onap.policy.controlloop.policy.PolicyResult;
+import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.so.SoModelInfo;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequestInfo;
@@ -73,6 +74,7 @@ public class SoOperationTest extends BasicSoOperation {
/**
* Sets up.
*/
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -90,7 +92,7 @@ public class SoOperationTest extends BasicSoOperation {
assertTrue(oper.isUsePolling());
// check when Target is null
- params = params.toBuilder().target(null).build();
+ params = params.toBuilder().targetType(null).build();
assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config, PROP_NAMES) {})
.withMessageContaining("Target information");
}
@@ -98,23 +100,23 @@ public class SoOperationTest extends BasicSoOperation {
@Test
public void testValidateTarget() {
// check when various fields are null
- verifyNotNull("modelCustomizationId", target::getModelCustomizationId, target::setModelCustomizationId);
- verifyNotNull("modelInvariantId", target::getModelInvariantId, target::setModelInvariantId);
- verifyNotNull("modelVersionId", target::getModelVersionId, target::setModelVersionId);
+ verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID, targetEntities);
+ verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID, targetEntities);
+ verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION_ID, targetEntities);
// verify it's still valid
assertThatCode(() -> new VfModuleCreate(params, config)).doesNotThrowAnyException();
}
- private void verifyNotNull(String expectedText, Supplier<String> getter, Consumer<String> setter) {
- String originalValue = getter.get();
+ private void verifyNotNull(String expectedText, Map<String, String> targetEntities) {
+ String originalValue = targetEntities.get(expectedText);
// try with null
- setter.accept(null);
+ targetEntities.put(expectedText, null);
assertThatIllegalArgumentException().isThrownBy(() -> new VfModuleCreate(params, config))
.withMessageContaining(expectedText);
- setter.accept(originalValue);
+ targetEntities.put(expectedText, originalValue);
}
@Test
@@ -178,7 +180,7 @@ public class SoOperationTest extends BasicSoOperation {
assertTrue(executor.runAll(100));
assertTrue(future2.isDone());
- assertEquals(PolicyResult.SUCCESS, future2.get().getResult());
+ assertEquals(OperationResult.SUCCESS, future2.get().getResult());
// verify that the count was stored
Integer vfcount = context.getProperty(VF_COUNT_KEY);
@@ -219,49 +221,33 @@ public class SoOperationTest extends BasicSoOperation {
public void testSetOutcome() {
// success case
when(rawResponse.getStatus()).thenReturn(200);
- assertSame(outcome, oper.setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response));
+ assertSame(outcome, oper.setOutcome(outcome, OperationResult.SUCCESS, rawResponse, response));
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals("200 " + ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
assertSame(response, outcome.getResponse());
// failure case
when(rawResponse.getStatus()).thenReturn(500);
- assertSame(outcome, oper.setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response));
+ assertSame(outcome, oper.setOutcome(outcome, OperationResult.FAILURE, rawResponse, response));
- assertEquals(PolicyResult.FAILURE, outcome.getResult());
+ assertEquals(OperationResult.FAILURE, outcome.getResult());
assertEquals("500 " + ControlLoopOperation.FAILED_MSG, outcome.getMessage());
assertSame(response, outcome.getResponse());
}
@Test
public void testPrepareSoModelInfo() throws CoderException {
- verifyMissingModelInfo(target::getModelCustomizationId, target::setModelCustomizationId);
- verifyMissingModelInfo(target::getModelInvariantId, target::setModelInvariantId);
- verifyMissingModelInfo(target::getModelName, target::setModelName);
- verifyMissingModelInfo(target::getModelVersion, target::setModelVersion);
- verifyMissingModelInfo(target::getModelVersionId, target::setModelVersionId);
-
// valid data
SoModelInfo info = oper.prepareSoModelInfo();
verifyRequest("model.json", info);
// try with null target
- params = params.toBuilder().target(null).build();
+ params = params.toBuilder().targetType(null).build();
assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config, PROP_NAMES) {})
.withMessageContaining("missing Target");
}
- private void verifyMissingModelInfo(Supplier<String> getter, Consumer<String> setter) {
- String original = getter.get();
-
- setter.accept(null);
- assertThatIllegalArgumentException().isThrownBy(() -> oper.prepareSoModelInfo())
- .withMessage("missing VF Module model");
-
- setter.accept(original);
- }
-
@Test
public void testConstructRequestInfo() throws CoderException {
SoRequestInfo info = oper.constructRequestInfo();
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
index 9d80343e6..f1741d677 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
@@ -54,10 +54,10 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
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.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
-import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoResponse;
@@ -83,6 +83,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
destroyAfterClass();
}
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -104,7 +105,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
oper = new VfModuleCreate(params, config);
outcome = oper.start().get();
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof SoResponse);
}
@@ -146,7 +147,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
// run the operation
outcome = oper.start().get();
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof SoResponse);
int count = oper.getProperty(OperationProperties.DATA_VF_COUNT);
@@ -159,7 +160,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
assertEquals(VfModuleCreate.NAME, oper.getName());
// verify that target validation is done
- params = params.toBuilder().target(null).build();
+ params = params.toBuilder().targetType(null).build();
assertThatIllegalArgumentException().isThrownBy(() -> new VfModuleCreate(params, config))
.withMessageContaining("Target information");
}
@@ -220,7 +221,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
provideCqResponse(makeCqResponse());
assertTrue(executor.runAll(100));
assertTrue(future2.isDone());
- assertEquals(PolicyResult.SUCCESS, future2.get().getResult());
+ assertEquals(OperationResult.SUCCESS, future2.get().getResult());
}
@Test
@@ -264,7 +265,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
CompletableFuture<OperationOutcome> future2 = oper.start();
outcome = future2.get(5, TimeUnit.SECONDS);
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
SoResponse resp = outcome.getResponse();
assertNotNull(resp);
@@ -296,7 +297,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
CompletableFuture<OperationOutcome> future2 = oper.start();
outcome = future2.get(5, TimeUnit.SECONDS);
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
}
@Test
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
index 9335f0141..2ab1dbe83 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
@@ -67,10 +67,10 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
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.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
-import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoResponse;
@@ -108,6 +108,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
/**
* Sets up.
*/
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -133,7 +134,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
oper = new VfModuleDelete(params, config);
outcome = oper.start().get();
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof SoResponse);
}
@@ -167,7 +168,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
// run the operation
outcome = oper.start().get();
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof SoResponse);
int count = oper.getProperty(OperationProperties.DATA_VF_COUNT);
@@ -180,7 +181,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
assertEquals(VfModuleDelete.NAME, oper.getName());
// verify that target validation is done
- params = params.toBuilder().target(null).build();
+ params = params.toBuilder().targetType(null).build();
assertThatIllegalArgumentException().isThrownBy(() -> new MyOperation(params, config))
.withMessageContaining("Target information");
}
@@ -239,7 +240,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
provideCqResponse(makeCqResponse());
assertTrue(executor.runAll(100));
assertTrue(future2.isDone());
- assertEquals(PolicyResult.SUCCESS, future2.get().getResult());
+ assertEquals(OperationResult.SUCCESS, future2.get().getResult());
}
@Test
@@ -281,7 +282,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
CompletableFuture<OperationOutcome> future2 = oper.start();
outcome = future2.get(5, TimeUnit.SECONDS);
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
SoResponse resp = outcome.getResponse();
assertNotNull(resp);
@@ -315,7 +316,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
CompletableFuture<OperationOutcome> future2 = oper.start();
outcome = future2.get(5, TimeUnit.SECONDS);
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
}
@Test