summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-08-04 16:27:18 -0400
committerJim Hahn <jrh3@att.com>2020-08-06 19:19:46 -0400
commitdeed677c3dc8751209d50e7d35132c929fe6800d (patch)
tree01f3149d4a03206e134d889d50834ae8d141a0ce /models-interactions/model-actors/actor.so/src
parent364ef26929f06637bca03dd7bfb5e8ac69b611f8 (diff)
Modify Actors to use properties when provided
Modified the Actors to use properties when the application provides them instead of going to the event context for the data. This sometimes entailed moving code out of the Operation subclass constructor that used or validated the context data. Combined some property names and renamed others. Changed VF Count from AtomicInteger to Integer. Issue-ID: POLICY-2746 Change-Id: Ib8730538309bb77d2f4f6161e9a20a49362d8972 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.so/src')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java96
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java33
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java17
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java146
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java55
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java45
6 files changed, 301 insertions, 91 deletions
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index f269ea078..8f0dda3d2 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -29,10 +29,12 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
+import java.util.function.Function;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.ModelVer;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiConstants;
@@ -43,6 +45,7 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
@@ -170,10 +173,19 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
}
protected int getVfCount() {
+ if (containsProperty(OperationProperties.DATA_VF_COUNT)) {
+ return getProperty(OperationProperties.DATA_VF_COUNT);
+ }
+
return params.getContext().getProperty(vfCountKey);
}
protected void setVfCount(int vfCount) {
+ if (containsProperty(OperationProperties.DATA_VF_COUNT)) {
+ setProperty(OperationProperties.DATA_VF_COUNT, vfCount);
+ return;
+ }
+
params.getContext().setProperty(vfCountKey, vfCount);
}
@@ -370,45 +382,77 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
return headers;
}
- /*
- * These methods extract data from the Custom Query and throw an
- * IllegalArgumentException if the desired data item is not found.
+ /**
+ * Gets an item from a property. If the property is not found, then it invokes the
+ * given function to retrieve it from the custom query data. If that fails as well,
+ * then an exception is thrown.
+ *
+ * @param propName property name
+ * @param getter method to extract the value from the custom query data
+ * @param errmsg error message to include in any exception
+ * @return the retrieved item
*/
+ protected <T> T getItem(String propName, Function<AaiCqResponse, T> getter, String errmsg) {
+ if (containsProperty(propName)) {
+ return getProperty(propName);
+ }
- protected GenericVnf getVnfItem(AaiCqResponse aaiCqResponse, SoModelInfo soModelInfo) {
- GenericVnf vnf = aaiCqResponse.getGenericVnfByVfModuleModelInvariantId(soModelInfo.getModelInvariantId());
- if (vnf == null) {
- throw new IllegalArgumentException("missing generic VNF");
+ final AaiCqResponse aaiCqResponse = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY);
+ T item = getter.apply(aaiCqResponse);
+ if (item == null) {
+ throw new IllegalArgumentException(errmsg);
}
- return vnf;
+ return item;
}
- protected ServiceInstance getServiceInstance(AaiCqResponse aaiCqResponse) {
- ServiceInstance vnfService = aaiCqResponse.getServiceInstance();
- if (vnfService == null) {
- throw new IllegalArgumentException("missing VNF Service Item");
- }
+ /*
+ * These methods extract data from the Custom Query and throw an
+ * IllegalArgumentException if the desired data item is not found.
+ */
- return vnfService;
+ protected GenericVnf getVnfItem(SoModelInfo soModelInfo) {
+ // @formatter:off
+ return getItem(OperationProperties.AAI_VNF,
+ cq -> cq.getGenericVnfByVfModuleModelInvariantId(soModelInfo.getModelInvariantId()),
+ "missing generic VNF");
+ // @formatter:on
}
- protected Tenant getDefaultTenant(AaiCqResponse aaiCqResponse) {
- Tenant tenant = aaiCqResponse.getDefaultTenant();
- if (tenant == null) {
- throw new IllegalArgumentException("missing Tenant Item");
- }
+ protected ServiceInstance getServiceInstance() {
+ return getItem(OperationProperties.AAI_SERVICE, AaiCqResponse::getServiceInstance, "missing VNF Service Item");
+ }
- return tenant;
+ protected Tenant getDefaultTenant() {
+ // @formatter:off
+ return getItem(OperationProperties.AAI_DEFAULT_TENANT,
+ AaiCqResponse::getDefaultTenant,
+ "missing Default Tenant Item");
+ // @formatter:on
}
- protected CloudRegion getDefaultCloudRegion(AaiCqResponse aaiCqResponse) {
- CloudRegion cloudRegion = aaiCqResponse.getDefaultCloudRegion();
- if (cloudRegion == null) {
- throw new IllegalArgumentException("missing Cloud Region");
- }
+ protected CloudRegion getDefaultCloudRegion() {
+ // @formatter:off
+ return getItem(OperationProperties.AAI_DEFAULT_CLOUD_REGION,
+ AaiCqResponse::getDefaultCloudRegion,
+ "missing Default Cloud Region");
+ // @formatter:on
+ }
+
+ protected ModelVer getVnfModel(GenericVnf vnfItem) {
+ // @formatter:off
+ return getItem(OperationProperties.AAI_VNF_MODEL,
+ cq -> cq.getModelVerByVersionId(vnfItem.getModelVersionId()),
+ "missing generic VNF Model");
+ // @formatter:on
+ }
- return cloudRegion;
+ protected ModelVer getServiceModel(ServiceInstance vnfServiceItem) {
+ // @formatter:off
+ return getItem(OperationProperties.AAI_SERVICE_MODEL,
+ cq -> cq.getModelVerByVersionId(vnfServiceItem.getModelVersionId()),
+ "missing Service Model");
+ // @formatter:on
}
// these may be overridden by junit tests
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
index 4bae1e84d..7e95bda03 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
@@ -29,6 +29,7 @@ import javax.ws.rs.core.Response;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.ModelVer;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiConstants;
@@ -61,10 +62,12 @@ public class VfModuleCreate extends SoOperation {
// @formatter:off
private static final List<String> PROPERTY_NAMES = List.of(
- OperationProperties.AAI_MODEL_SERVICE,
- OperationProperties.AAI_MODEL_VNF,
- OperationProperties.AAI_MODEL_CLOUD_REGION,
- OperationProperties.AAI_MODEL_TENANT,
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.AAI_SERVICE_MODEL,
+ OperationProperties.AAI_VNF,
+ OperationProperties.AAI_VNF_MODEL,
+ OperationProperties.AAI_DEFAULT_CLOUD_REGION,
+ OperationProperties.AAI_DEFAULT_TENANT,
OperationProperties.DATA_VF_COUNT);
// @formatter:off
@@ -156,12 +159,13 @@ public class VfModuleCreate extends SoOperation {
* @return a pair containing the request URL and the new request
*/
protected Pair<String, SoRequest> makeRequest() {
- final AaiCqResponse aaiCqResponse = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY);
final SoModelInfo soModelInfo = prepareSoModelInfo();
- final GenericVnf vnfItem = getVnfItem(aaiCqResponse, soModelInfo);
- final ServiceInstance vnfServiceItem = getServiceInstance(aaiCqResponse);
- final Tenant tenantItem = getDefaultTenant(aaiCqResponse);
- final CloudRegion cloudRegionItem = getDefaultCloudRegion(aaiCqResponse);
+ final GenericVnf vnfItem = getVnfItem(soModelInfo);
+ final ServiceInstance vnfServiceItem = getServiceInstance();
+ final Tenant tenantItem = getDefaultTenant();
+ final CloudRegion cloudRegionItem = getDefaultCloudRegion();
+ final ModelVer vnfModel = getVnfModel(vnfItem);
+ final ModelVer vnfServiceModel = getServiceModel(vnfServiceItem);
SoRequest request = new SoRequest();
request.setOperationType(SoOperationType.SCALE_OUT);
@@ -198,10 +202,8 @@ public class VfModuleCreate extends SoOperation {
.setModelInvariantId(vnfServiceItem.getModelInvariantId());
relatedInstanceListElement1.getRelatedInstance().getModelInfo()
.setModelVersionId(vnfServiceItem.getModelVersionId());
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(
- aaiCqResponse.getModelVerByVersionId(vnfServiceItem.getModelVersionId()).getModelName());
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion(
- aaiCqResponse.getModelVerByVersionId(vnfServiceItem.getModelVersionId()).getModelVersion());
+ relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(vnfModel.getModelName());
+ relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion(vnfModel.getModelVersion());
// VNF Item
relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfItem.getVnfId());
@@ -211,10 +213,9 @@ public class VfModuleCreate extends SoOperation {
.setModelInvariantId(vnfItem.getModelInvariantId());
relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId(vnfItem.getModelVersionId());
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(vnfServiceModel.getModelName());
relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelName(aaiCqResponse.getModelVerByVersionId(vnfItem.getModelVersionId()).getModelName());
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion(
- aaiCqResponse.getModelVerByVersionId(vnfItem.getModelVersionId()).getModelVersion());
+ .setModelVersion(vnfServiceModel.getModelVersion());
relatedInstanceListElement2.getRelatedInstance().getModelInfo()
.setModelCustomizationId(vnfItem.getModelCustomizationId());
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
index 7db76d2d1..0ff833c59 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
@@ -70,10 +70,10 @@ public class VfModuleDelete extends SoOperation {
// @formatter:off
private static final List<String> PROPERTY_NAMES = List.of(
- OperationProperties.AAI_MODEL_SERVICE,
- OperationProperties.AAI_MODEL_VNF,
- OperationProperties.AAI_MODEL_CLOUD_REGION,
- OperationProperties.AAI_MODEL_TENANT,
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.AAI_VNF,
+ OperationProperties.AAI_DEFAULT_CLOUD_REGION,
+ OperationProperties.AAI_DEFAULT_TENANT,
OperationProperties.DATA_VF_COUNT);
// @formatter:on
@@ -239,12 +239,11 @@ public class VfModuleDelete extends SoOperation {
* @return a pair containing the request URL and the new request
*/
protected Pair<String, SoRequest> makeRequest() {
- final AaiCqResponse aaiCqResponse = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY);
final SoModelInfo soModelInfo = prepareSoModelInfo();
- final GenericVnf vnfItem = getVnfItem(aaiCqResponse, soModelInfo);
- final ServiceInstance vnfServiceItem = getServiceInstance(aaiCqResponse);
- final Tenant tenantItem = getDefaultTenant(aaiCqResponse);
- final CloudRegion cloudRegionItem = getDefaultCloudRegion(aaiCqResponse);
+ final GenericVnf vnfItem = getVnfItem(soModelInfo);
+ final ServiceInstance vnfServiceItem = getServiceInstance();
+ final Tenant tenantItem = getDefaultTenant();
+ final CloudRegion cloudRegionItem = getDefaultCloudRegion();
SoRequest request = new SoRequest();
request.setOperationType(SoOperationType.DELETE_VF_MODULE);
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 7314c59fa..e364246e4 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
@@ -36,12 +36,14 @@ import java.time.Month;
import java.util.Collections;
import java.util.List;
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;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.ModelVer;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiCqResponse;
@@ -49,6 +51,7 @@ import org.onap.policy.common.utils.coder.Coder;
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.so.SoModelInfo;
import org.onap.policy.so.SoRequest;
@@ -63,6 +66,8 @@ public class SoOperationTest extends BasicSoOperation {
private static final List<String> PROP_NAMES = Collections.emptyList();
+ private static final String VERSION_ID = "1.2.3";
+
private SoOperation oper;
/**
@@ -140,6 +145,24 @@ public class SoOperationTest extends BasicSoOperation {
}
/**
+ * Tests the VF Count methods when properties are being used.
+ * @throws Exception if an error occurs
+ */
+ @Test
+ public void testGetVfCount_testSetVfCount_ViaProperties() throws Exception {
+ oper.setProperty(OperationProperties.DATA_VF_COUNT, VF_COUNT);
+
+ // verify that the count was stored
+ assertEquals(VF_COUNT.intValue(), oper.getVfCount());
+
+ oper.setVfCount(VF_COUNT + 1);
+
+ int count = oper.getProperty(OperationProperties.DATA_VF_COUNT);
+ assertEquals(VF_COUNT + 1, count);
+ assertEquals(VF_COUNT + 1, oper.getVfCount());
+ }
+
+ /**
* Tests obtainVfCount() when it actually has to query.
*/
@Test
@@ -286,55 +309,114 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testGetVnfItem() {
- // missing data
+ public void testGetItem() {
AaiCqResponse cq = mock(AaiCqResponse.class);
- assertThatIllegalArgumentException().isThrownBy(() -> oper.getVnfItem(cq, oper.prepareSoModelInfo()))
- .withMessage("missing generic VNF");
+ params.getContext().setProperty(AaiCqResponse.CONTEXT_KEY, cq);
- // valid data
- GenericVnf vnf = new GenericVnf();
- when(cq.getGenericVnfByVfModuleModelInvariantId(MODEL_INVAR_ID)).thenReturn(vnf);
- assertSame(vnf, oper.getVnfItem(cq, oper.prepareSoModelInfo()));
+ // in neither property nor custom query
+ assertThatIllegalArgumentException().isThrownBy(() -> oper.getItem("propA", cq2 -> null, "not found"))
+ .withMessage("not found");
+
+ // only in custom query
+ assertEquals("valueB", oper.getItem("propB", cq2 -> "valueB", "failureB"));
+
+ // both - should choose the property
+ oper.setProperty("propC", "valueC");
+ assertEquals("valueC", oper.getItem("propC", cq2 -> "valueC2", "failureC"));
+
+ // both - should choose the property, even if it's null
+ oper.setProperty("propD", null);
+ assertNull(oper.getItem("propD", cq2 -> "valueD2", "failureD"));
}
@Test
- public void testGetServiceInstance() {
- // missing data
- AaiCqResponse cq = mock(AaiCqResponse.class);
- assertThatIllegalArgumentException().isThrownBy(() -> oper.getServiceInstance(cq))
- .withMessage("missing VNF Service Item");
+ public void testGetVnfItem() {
+ // @formatter:off
+ verifyItems(OperationProperties.AAI_VNF, GenericVnf::new,
+ (cq, instance) -> when(cq.getGenericVnfByVfModuleModelInvariantId(MODEL_INVAR_ID)).thenReturn(instance),
+ () -> oper.getVnfItem(oper.prepareSoModelInfo()),
+ "missing generic VNF");
+ // @formatter:on
+ }
- // valid data
- ServiceInstance instance = new ServiceInstance();
- when(cq.getServiceInstance()).thenReturn(instance);
- assertSame(instance, oper.getServiceInstance(cq));
+ @Test
+ public void testGetServiceInstance() {
+ // @formatter:off
+ verifyItems(OperationProperties.AAI_SERVICE, ServiceInstance::new,
+ (cq, instance) -> when(cq.getServiceInstance()).thenReturn(instance),
+ () -> oper.getServiceInstance(),
+ "missing VNF Service Item");
+ // @formatter:on
}
@Test
public void testGetDefaultTenant() {
- // missing data
- AaiCqResponse cq = mock(AaiCqResponse.class);
- assertThatIllegalArgumentException().isThrownBy(() -> oper.getDefaultTenant(cq))
- .withMessage("missing Tenant Item");
+ // @formatter:off
+ verifyItems(OperationProperties.AAI_DEFAULT_TENANT, Tenant::new,
+ (cq, tenant) -> when(cq.getDefaultTenant()).thenReturn(tenant),
+ () -> oper.getDefaultTenant(),
+ "missing Default Tenant Item");
+ // @formatter:on
+ }
- // valid data
- Tenant tenant = new Tenant();
- when(cq.getDefaultTenant()).thenReturn(tenant);
- assertSame(tenant, oper.getDefaultTenant(cq));
+ @Test
+ public void testGetVnfModel() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setModelVersionId(VERSION_ID);
+
+ // @formatter:off
+ verifyItems(OperationProperties.AAI_VNF_MODEL, ModelVer::new,
+ (cq, model) -> when(cq.getModelVerByVersionId(VERSION_ID)).thenReturn(model),
+ () -> oper.getVnfModel(vnf),
+ "missing generic VNF Model");
+ // @formatter:on
+ }
+
+ @Test
+ public void testGetServiceModel() {
+ ServiceInstance service = new ServiceInstance();
+ service.setModelVersionId(VERSION_ID);
+
+ // @formatter:off
+ verifyItems(OperationProperties.AAI_SERVICE_MODEL, ModelVer::new,
+ (cq, model) -> when(cq.getModelVerByVersionId(VERSION_ID)).thenReturn(model),
+ () -> oper.getServiceModel(service),
+ "missing Service Model");
+ // @formatter:on
}
@Test
public void testGetDefaultCloudRegion() {
- // missing data
+ // @formatter:off
+ verifyItems(OperationProperties.AAI_DEFAULT_CLOUD_REGION, CloudRegion::new,
+ (cq, region) -> when(cq.getDefaultCloudRegion()).thenReturn(region),
+ () -> oper.getDefaultCloudRegion(),
+ "missing Default Cloud Region");
+ // @formatter:on
+ }
+
+ private <T> void verifyItems(String propName, Supplier<T> maker, BiConsumer<AaiCqResponse, T> setter,
+ Supplier<T> getter, String errmsg) {
+
AaiCqResponse cq = mock(AaiCqResponse.class);
- assertThatIllegalArgumentException().isThrownBy(() -> oper.getDefaultCloudRegion(cq))
- .withMessage("missing Cloud Region");
+ params.getContext().setProperty(AaiCqResponse.CONTEXT_KEY, cq);
- // valid data
- CloudRegion region = new CloudRegion();
- when(cq.getDefaultCloudRegion()).thenReturn(region);
- assertSame(region, oper.getDefaultCloudRegion(cq));
+ // in neither property nor custom query
+ assertThatIllegalArgumentException().isThrownBy(getter::get).withMessage(errmsg);
+
+ // only in custom query
+ final T item1 = maker.get();
+ setter.accept(cq, item1);
+ assertSame(item1, getter.get());
+
+ // both - should choose the property
+ final T item2 = maker.get();
+ oper.setProperty(propName, item2);
+ assertSame(item2, getter.get());
+
+ // both - should choose the property, even if it's null
+ oper.setProperty(propName, null);
+ assertNull(getter.get());
}
@Test
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 012f8deff..9d80343e6 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
@@ -108,6 +108,51 @@ public class VfModuleCreateTest extends BasicSoOperation {
assertTrue(outcome.getResponse() instanceof SoResponse);
}
+ /**
+ * Tests "success" case with simulator, using properties instead of custom query data.
+ */
+ @Test
+ public void testSuccessViaProperties() throws Exception {
+ HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT)
+ .path("serviceInstantiation/v7/serviceInstances").pollPath("orchestrationRequests/v5/")
+ .maxPolls(2).build();
+ config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+
+ params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).preprocessed(true).build();
+ params.getContext().removeProperty(AaiCqResponse.CONTEXT_KEY);
+
+ oper = new VfModuleCreate(params, config);
+
+ // set the properties
+ ServiceInstance instance = new ServiceInstance();
+ instance.setServiceInstanceId(SVC_INSTANCE_ID);
+ oper.setProperty(OperationProperties.AAI_SERVICE, instance);
+
+ ModelVer modelVers = new ModelVer();
+ modelVers.setModelName(MODEL_NAME2);
+ modelVers.setModelVersion(MODEL_VERS2);
+
+ oper.setProperty(OperationProperties.AAI_SERVICE_MODEL, modelVers);
+ oper.setProperty(OperationProperties.AAI_VNF_MODEL, modelVers);
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId(VNF_ID);
+ oper.setProperty(OperationProperties.AAI_VNF, vnf);
+
+ oper.setProperty(OperationProperties.AAI_DEFAULT_CLOUD_REGION, new CloudRegion());
+ oper.setProperty(OperationProperties.AAI_DEFAULT_TENANT, new Tenant());
+
+ oper.setProperty(OperationProperties.DATA_VF_COUNT, VF_COUNT);
+
+ // run the operation
+ outcome = oper.start().get();
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertTrue(outcome.getResponse() instanceof SoResponse);
+
+ int count = oper.getProperty(OperationProperties.DATA_VF_COUNT);
+ assertEquals(VF_COUNT + 1, count);
+ }
+
@Test
public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
@@ -124,10 +169,12 @@ public class VfModuleCreateTest extends BasicSoOperation {
// @formatter:off
assertThat(oper.getPropertyNames()).isEqualTo(
List.of(
- OperationProperties.AAI_MODEL_SERVICE,
- OperationProperties.AAI_MODEL_VNF,
- OperationProperties.AAI_MODEL_CLOUD_REGION,
- OperationProperties.AAI_MODEL_TENANT,
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.AAI_SERVICE_MODEL,
+ OperationProperties.AAI_VNF,
+ OperationProperties.AAI_VNF_MODEL,
+ OperationProperties.AAI_DEFAULT_CLOUD_REGION,
+ OperationProperties.AAI_DEFAULT_TENANT,
OperationProperties.DATA_VF_COUNT));
// @formatter:on
}
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 cc2aafa74..9335f0141 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
@@ -137,6 +137,43 @@ public class VfModuleDeleteTest extends BasicSoOperation {
assertTrue(outcome.getResponse() instanceof SoResponse);
}
+ /**
+ * Tests "success" case with simulator, using properties instead of custom query data.
+ */
+ @Test
+ public void testSuccessViaProperties() throws Exception {
+ HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT).path("serviceInstances/v7")
+ .pollPath("orchestrationRequests/v5/").maxPolls(2).build();
+ config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+
+ params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).preprocessed(true).build();
+ params.getContext().removeProperty(AaiCqResponse.CONTEXT_KEY);
+
+ oper = new VfModuleDelete(params, config);
+
+ // set the properties
+ ServiceInstance instance = new ServiceInstance();
+ instance.setServiceInstanceId(SVC_INSTANCE_ID);
+ oper.setProperty(OperationProperties.AAI_SERVICE, instance);
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId(VNF_ID);
+ oper.setProperty(OperationProperties.AAI_VNF, vnf);
+
+ oper.setProperty(OperationProperties.AAI_DEFAULT_CLOUD_REGION, new CloudRegion());
+ oper.setProperty(OperationProperties.AAI_DEFAULT_TENANT, new Tenant());
+
+ oper.setProperty(OperationProperties.DATA_VF_COUNT, VF_COUNT);
+
+ // run the operation
+ outcome = oper.start().get();
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertTrue(outcome.getResponse() instanceof SoResponse);
+
+ int count = oper.getProperty(OperationProperties.DATA_VF_COUNT);
+ assertEquals(VF_COUNT - 1, count);
+ }
+
@Test
public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
@@ -153,10 +190,10 @@ public class VfModuleDeleteTest extends BasicSoOperation {
// @formatter:off
assertThat(oper.getPropertyNames()).isEqualTo(
List.of(
- OperationProperties.AAI_MODEL_SERVICE,
- OperationProperties.AAI_MODEL_VNF,
- OperationProperties.AAI_MODEL_CLOUD_REGION,
- OperationProperties.AAI_MODEL_TENANT,
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.AAI_VNF,
+ OperationProperties.AAI_DEFAULT_CLOUD_REGION,
+ OperationProperties.AAI_DEFAULT_TENANT,
OperationProperties.DATA_VF_COUNT));
// @formatter:on
}