summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.sdnc/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-08-21 13:43:08 -0400
committerJim Hahn <jrh3@att.com>2020-10-27 14:55:15 -0400
commit19ef8b24a98c09a349e6ae7309f535a0135463f6 (patch)
treed988e5a58865ae6f3a38dcb31e4f195f18e59946 /models-interactions/model-actors/actor.sdnc/src/test
parent6b29d2c19e288148171db0c0e446e18dcd46effd (diff)
Make Actors event-agnostic
Removed event and event-context code from the Actor code. Also removed the preprocessing steps from the Actor code, giving the application complete control over any preprocessing. Also fixed a bug wherein the APPC actor was treating the AAI_RESOURCE_VNF property as a String instead of as a GenericVnf. Issue-ID: POLICY-2746-actor Change-Id: Ibc05fe39ffedc0bc461abf10e6a960861ac70119 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.sdnc/src/test')
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java34
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java27
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java33
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java53
4 files changed, 0 insertions, 147 deletions
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
index 5e71a6cd5..ba68534c4 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.List;
-import java.util.Map;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -33,10 +32,8 @@ import org.junit.Test;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
-import org.onap.policy.sdnc.SdncRequest;
import org.onap.policy.sdnc.SdncResponse;
public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
@@ -114,30 +111,6 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
@Test
public void testMakeRequest() throws Exception {
- oper.generateSubRequestId(1);
- SdncRequest request = oper.makeRequest(1);
- assertEquals(MY_SERVICE, request.getNsInstanceId());
- assertEquals(REQ_ID, request.getRequestId());
- assertEquals("/my-path/", request.getUrl());
- assertEquals(oper.getSubRequestId(), request.getHealRequest().getRequestHeaderInfo().getSvcRequestId());
-
- verifyRequest("bod.json", request, IGNORE_FIELDS);
-
- verifyMissing(BandwidthOnDemandOperation.SERVICE_ID_KEY, "service", BandwidthOnDemandOperation::new);
-
- // perform the operation
- makeContext();
- verifyRequest("bod.json", verifyOperation(oper), IGNORE_FIELDS);
- }
-
- @Test
- public void testMakeRequestViaProperties() throws Exception {
- // clear the enrichment data and remake the operation
- event.setAai(null);
- context = new ControlLoopEventContext(event);
- params = params.toBuilder().context(context).build();
- oper = new BandwidthOnDemandOperation(params, config);
-
oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH, MY_BANDWIDTH);
oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH_CHANGE_TIME, MY_CHANGE_TIME);
@@ -145,11 +118,4 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
verifyRequest("bod.json", verifyOperation(oper), IGNORE_FIELDS);
}
-
- @Override
- protected Map<String, String> makeEnrichment() {
- return Map.of(BandwidthOnDemandOperation.SERVICE_ID_KEY, MY_SERVICE, BandwidthOnDemandOperation.BANDWIDTH,
- MY_BANDWIDTH, BandwidthOnDemandOperation.BANDWIDTH_CHANGE_TIME, MY_CHANGE_TIME,
- BandwidthOnDemandOperation.VNF_ID, MY_VNF);
- }
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
index a118ab124..f4b6141f8 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
@@ -20,7 +20,6 @@
package org.onap.policy.controlloop.actor.sdnc;
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -29,7 +28,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
@@ -41,13 +39,10 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.sdnc.SdncRequest;
import org.onap.policy.sdnc.SdncResponse;
import org.onap.policy.sdnc.SdncResponseOutput;
import org.onap.policy.simulators.Util;
-import org.powermock.reflect.Whitebox;
/**
* Superclass for various operator tests.
@@ -137,26 +132,4 @@ public abstract class BasicSdncOperation extends BasicHttpOperation {
return coder.decode(reqText, SdncRequest.class);
}
-
- /**
- * Verifies that an exception is thrown if a field is missing from the enrichment
- * data.
- *
- * @param fieldName name of the field to be removed from the enrichment data
- * @param expectedText text expected in the exception message
- */
- protected void verifyMissing(String fieldName, String expectedText,
- OperationMaker<HttpConfig, SdncOperation> maker) {
-
- makeContext();
- enrichment.remove(fieldName);
-
- SdncOperation oper = maker.apply(params, config);
-
- assertThatIllegalArgumentException().isThrownBy(() -> Whitebox.invokeMethod(oper, "makeRequest", 1))
- .withMessageContaining("missing").withMessageContaining(expectedText);
- }
-
- @Override
- protected abstract Map<String, String> makeEnrichment();
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
index e41ef3fec..3f087844b 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.List;
-import java.util.Map;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -33,10 +32,8 @@ import org.junit.Test;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
-import org.onap.policy.sdnc.SdncRequest;
import org.onap.policy.sdnc.SdncResponse;
public class RerouteOperationTest extends BasicSdncOperation {
@@ -107,39 +104,9 @@ public class RerouteOperationTest extends BasicSdncOperation {
@Test
public void testMakeRequest() throws Exception {
- oper.generateSubRequestId(1);
- SdncRequest request = oper.makeRequest(1);
- assertEquals(MY_SERVICE, request.getNsInstanceId());
- assertEquals(REQ_ID, request.getRequestId());
- assertEquals("/my-path/", request.getUrl());
- assertEquals(oper.getSubRequestId(), request.getHealRequest().getRequestHeaderInfo().getSvcRequestId());
-
- verifyRequest("reroute.json", request, IGNORE_FIELDS);
-
- verifyMissing(RerouteOperation.SERVICE_ID_KEY, "service", RerouteOperation::new);
- verifyMissing(RerouteOperation.NETWORK_ID_KEY, "network", RerouteOperation::new);
-
- // perform the operation
- makeContext();
- verifyRequest("reroute.json", verifyOperation(oper), IGNORE_FIELDS);
- }
-
- @Test
- public void testMakeRequestViaProperties() throws Exception {
- // clear the enrichment data and remake the operation
- event.setAai(null);
- context = new ControlLoopEventContext(event);
- params = params.toBuilder().context(context).build();
- oper = new RerouteOperation(params, config);
-
oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
oper.setProperty(OperationProperties.ENRICHMENT_NETWORK_ID, MY_NETWORK);
verifyRequest("reroute.json", verifyOperation(oper), IGNORE_FIELDS);
}
-
- @Override
- protected Map<String, String> makeEnrichment() {
- return Map.of(RerouteOperation.SERVICE_ID_KEY, MY_SERVICE, RerouteOperation.NETWORK_ID_KEY, MY_NETWORK);
- }
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
index 4ba12c6ca..9055715b4 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
@@ -22,16 +22,11 @@ package org.onap.policy.controlloop.actor.sdnc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
-import java.util.Map;
-import java.util.TreeMap;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
import org.onap.policy.sdnc.SdncHealRequest;
import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
import org.onap.policy.sdnc.SdncRequest;
@@ -75,11 +70,6 @@ public class SdncOperationTest extends BasicSdncOperation {
}
@Test
- public void testStartPreprocessorAsync() {
- assertNotNull(oper.startPreprocessorAsync());
- }
-
- @Test
public void testStartOperationAsync_testStartRequestAsync() throws Exception {
verifyOperation(oper);
}
@@ -102,47 +92,4 @@ public class SdncOperationTest extends BasicSdncOperation {
response.setResponseOutput(null);
assertFalse(oper.isSuccess(null, response));
}
-
- @Test
- public void testGetOptProperty() {
- // in neither property nor enrichment
- assertNull(oper.getOptProperty("propA", "propA2"));
-
- // both - should choose the property
- remakeOper(Map.of("propB2", "valueB2"));
- oper.setProperty("propB", "valueB");
- assertEquals("valueB", oper.getOptProperty("propB", "propB2"));
-
- // both - should choose the property, even if it's null
- remakeOper(Map.of("propC2", "valueC2"));
- oper.setProperty("propC", null);
- assertNull(oper.getOptProperty("propC", "propC2"));
-
- // only in enrichment data
- remakeOper(Map.of("propD2", "valueD2"));
- assertEquals("valueD2", oper.getOptProperty("propD", "propD2"));
- }
-
- /**
- * Remakes the operation, with the specified A&AI enrichment data.
- *
- * @param aai A&AI enrichment data
- */
- private void remakeOper(Map<String, String> aai) {
- event.setAai(aai);
- context = new ControlLoopEventContext(event);
- params = params.toBuilder().context(context).build();
-
- oper = new SdncOperation(params, config, Collections.emptyList()) {
- @Override
- protected SdncRequest makeRequest(int attempt) {
- return request;
- }
- };
- }
-
- @Override
- protected Map<String, String> makeEnrichment() {
- return new TreeMap<>();
- }
}