summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.cds/src/test
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2021-12-16 16:15:33 -0600
committerjhh <jorge.hernandez-herrero@att.com>2022-01-07 17:48:21 -0600
commit5da73554e8fdc16864338f9b796418777cacb660 (patch)
tree50cb34200bc796ab372500099837dbd71f7e2a0f /models-interactions/model-actors/actor.cds/src/test
parentc122a8dd920b2d00699b239f8de3483479471efd (diff)
extend vnf properties model for cds actors
CDS operations for VNFs default to vFirewall-like behavior for AAI queries where vserver and target resources are required. The properties refactoring allows for enriched vnf-id behavior (similar to vCPE) and provides some leg work for other extensions. Fix dmaap simulator sporadic test errors in junits Issue-ID: POLICY-3865 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Iad35e4f2a9e10b1a49818c91b9fec7520e844b8c
Diffstat (limited to 'models-interactions/model-actors/actor.cds/src/test')
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java95
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java90
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java85
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java58
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java76
5 files changed, 381 insertions, 23 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 0809291ad..cae048b17 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ package org.onap.policy.controlloop.actor.cds;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -42,7 +43,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
-import org.onap.policy.cds.client.CdsProcessorGrpcClient;
import org.onap.policy.cds.properties.CdsServerProperties;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -50,6 +50,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.common.utils.time.PseudoExecutor;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
+import org.onap.policy.controlloop.actor.cds.properties.GrpcOperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
@@ -78,7 +79,6 @@ public class GrpcOperationTest {
private static CdsSimulator sim;
@Mock
- private CdsProcessorGrpcClient cdsClient;
private CdsServerProperties cdsProps;
private PseudoExecutor executor;
private Map<String, String> targetEntityIds;
@@ -100,7 +100,7 @@ public class GrpcOperationTest {
* Sets up the fields.
*/
@Before
- public void setUp() throws Exception {
+ public void setUp() {
// Setup the CDS properties
cdsProps = new CdsServerProperties();
cdsProps.setHost("10.10.10.10");
@@ -150,19 +150,33 @@ public class GrpcOperationTest {
@Test
public void testGetPropertyNames() {
+ /*
+ * check VNF case with target entities
+ */
+ params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
+ operation = new GrpcOperation(params, config);
+
+ // @formatter:off
+ assertThat(operation.getPropertyNames()).isEqualTo(
+ List.of(
+ OperationProperties.AAI_RESOURCE_VNF,
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.EVENT_ADDITIONAL_PARAMS,
+ OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES));
+ // @formatter:on
/*
- * check VNF case
+ * check VNF case with no target entities
*/
+ params = params.toBuilder().targetEntityIds(null).build();
operation = new GrpcOperation(params, config);
// @formatter:off
assertThat(operation.getPropertyNames()).isEqualTo(
- List.of(
- OperationProperties.AAI_RESOURCE_VNF,
- OperationProperties.AAI_SERVICE,
- OperationProperties.EVENT_ADDITIONAL_PARAMS,
- OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES));
+ List.of(
+ OperationProperties.AAI_TARGET_ENTITY,
+ OperationProperties.EVENT_ADDITIONAL_PARAMS,
+ OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES));
// @formatter:on
/*
@@ -182,47 +196,82 @@ public class GrpcOperationTest {
@Test
public void testGetServiceInstanceId() {
+ params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
- assertEquals(MY_SVC_ID, operation.getServiceInstanceId());
+ assertEquals(MY_SVC_ID,
+ operation.getOpProperties()
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_SERVICE_INSTANCE_ID_KEY));
}
@Test
public void testGetVnfId() {
+ params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
- assertEquals(MY_VNF, operation.getVnfId());
+ assertEquals(MY_VNF,
+ operation.getOpProperties()
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+
+ params = params.toBuilder().targetEntityIds(null).build();
+ operation = new GrpcOperation(params, config);
+ assertThatIllegalStateException().isThrownBy(()
+ -> operation.getOpProperties()
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+
+ operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_VNF);
+ assertEquals(MY_VNF,
+ operation.getOpProperties()
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+ operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, null);
}
@Test
- public void testStartOperationAsync() throws Exception {
- verifyOperation(TargetType.VNF, this::loadVnfData);
+ public void testStartOperationAsync() {
+ ControlLoopOperationParams clop =
+ ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
+ .operation(GrpcOperation.NAME)
+ .requestId(REQUEST_ID)
+ .actorService(new ActorService())
+ .targetType(TargetType.VNF)
+ .build();
+
+ verifyOperation(clop, () -> operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_VNF));
+ verifyOperation(clop.toBuilder().targetEntityIds(targetEntityIds).build(), this::loadVnfData);
}
/**
* Tests startOperationAsync() when the target type is PNF.
*/
@Test
- public void testStartOperationAsyncPnf() throws Exception {
- verifyOperation(TargetType.PNF, this::loadPnfData);
+ public void testStartOperationAsyncPnf() {
+ ControlLoopOperationParams clop =
+ ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
+ .operation(GrpcOperation.NAME)
+ .requestId(REQUEST_ID)
+ .actorService(new ActorService())
+ .targetType(TargetType.PNF)
+ .build();
+
+ verifyOperation(clop, this::loadPnfData);
}
@Test
- public void testStartOperationAsyncError() throws Exception {
+ public void testStartOperationAsyncError() {
operation = new GrpcOperation(params, config);
assertThatIllegalArgumentException()
.isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
}
- private void verifyOperation(TargetType targetType, Runnable loader) {
-
+ private void verifyOperation(ControlLoopOperationParams clop, Runnable loader) {
Map<String, Object> payloadMap = Map.of(CdsActorConstants.KEY_CBA_NAME, CDS_BLUEPRINT_NAME,
CdsActorConstants.KEY_CBA_VERSION, CDS_BLUEPRINT_VERSION, "data",
"{\"mapInfo\":{\"key\":\"val\"},\"arrayInfo\":[\"one\",\"two\"],\"paramInfo\":\"val\"}");
-
- ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
- .operation(GrpcOperation.NAME).requestId(REQUEST_ID).actorService(new ActorService())
- .targetType(targetType).payload(payloadMap).build();
+ params = clop.toBuilder().payload(payloadMap).build();
GrpcConfig config = new GrpcConfig(executor, cdsProps);
operation = new GrpcOperation(params, config);
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java
new file mode 100644
index 000000000..44ebc12c5
--- /dev/null
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.cds.properties;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Collections;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.policy.cds.properties.CdsServerProperties;
+import org.onap.policy.common.utils.time.PseudoExecutor;
+import org.onap.policy.controlloop.actor.cds.GrpcConfig;
+import org.onap.policy.controlloop.actor.cds.GrpcOperation;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+
+public class GrcpOperationResourceVnfPropertiesTest {
+
+ @Test
+ public void getPropertyNames() {
+ assertEquals(GrcpOperationResourceVnfProperties.VNF_PROPERTY_NAMES,
+ new GrcpOperationResourceVnfProperties().getPropertyNames());
+ }
+
+ @Test
+ public void convertToAaiProperties() {
+ ControlLoopOperationParams params =
+ ControlLoopOperationParams.builder()
+ .targetType(TargetType.VNF)
+ .build();
+
+ GrpcOperation operation =
+ new GrpcOperation(params, new GrpcConfig(new PseudoExecutor(), new CdsServerProperties()));
+
+ GrcpOperationResourceVnfProperties properties = new GrcpOperationResourceVnfProperties();
+ assertThatIllegalStateException()
+ .isThrownBy(() -> properties.convertToAaiProperties(operation));
+
+ GenericVnf genvnf = new GenericVnf();
+ genvnf.setVnfId("v");
+ operation.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("s");
+ operation.setProperty(OperationProperties.AAI_SERVICE, serviceInstance);
+
+ assertEquals("s",
+ properties.convertToAaiProperties(operation)
+ .get(GrcpOperationResourceVnfProperties.AAI_SERVICE_INSTANCE_ID_KEY));
+
+ assertEquals("v",
+ properties.convertToAaiProperties(operation)
+ .get(GrcpOperationResourceVnfProperties.AAI_VNF_ID_KEY));
+
+ operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES, Collections.emptyMap());
+
+ assertNull(properties.convertToAaiProperties(operation)
+ .get(GrcpOperationResourceVnfProperties.AAI_SERVICE_INSTANCE_ID_KEY));
+
+ assertNull(properties.convertToAaiProperties(operation)
+ .get(GrcpOperationResourceVnfProperties.AAI_VNF_ID_KEY));
+
+ operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES,
+ Map.of("aa", "AA"));
+ assertEquals("AA",
+ properties.convertToAaiProperties(operation)
+ .get("aa"));
+ }
+} \ No newline at end of file
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java
new file mode 100644
index 000000000..828ededa9
--- /dev/null
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.cds.properties;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Collections;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.cds.properties.CdsServerProperties;
+import org.onap.policy.common.utils.coder.Coder;
+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.common.utils.time.PseudoExecutor;
+import org.onap.policy.controlloop.actor.cds.GrpcConfig;
+import org.onap.policy.controlloop.actor.cds.GrpcOperation;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+
+public class GrpcOperationPnfPropertiesTest {
+ private static final Coder coder = new StandardCoder();
+
+ @Test
+ public void getPropertyNames() {
+ assertEquals(GrpcOperationPnfProperties.PNF_PROPERTY_NAMES,
+ new GrpcOperationPnfProperties().getPropertyNames());
+ }
+
+ @Test
+ public void convertToAaiProperties() throws CoderException {
+ ControlLoopOperationParams params =
+ ControlLoopOperationParams.builder()
+ .targetType(TargetType.PNF)
+ .build();
+
+ GrpcOperation operation =
+ new GrpcOperation(params, new GrpcConfig(new PseudoExecutor(), new CdsServerProperties()));
+
+ GrpcOperationPnfProperties properties = new GrpcOperationPnfProperties();
+ assertThatIllegalStateException()
+ .isThrownBy(() -> properties.convertToAaiProperties(operation));
+
+ String pnf = "{'dataA': 'valueA', 'dataB': 'valueB'}".replace('\'', '"');
+ StandardCoderObject sco = coder.decode(pnf, StandardCoderObject.class);
+ operation.setProperty(OperationProperties.AAI_PNF, sco);
+
+ assertEquals("valueA",
+ properties.convertToAaiProperties(operation)
+ .get(GrpcOperationPnfProperties.AAI_PNF_PREFIX + "dataA"));
+
+ assertEquals("valueB",
+ properties.convertToAaiProperties(operation)
+ .get(GrpcOperationPnfProperties.AAI_PNF_PREFIX + "dataB"));
+
+ operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES, Collections.emptyMap());
+ assertNull(properties.convertToAaiProperties(operation)
+ .get(GrpcOperationPnfProperties.AAI_PNF_PREFIX + "dataA"));
+
+ operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES,
+ Map.of("dataC", "valueC"));
+ assertEquals("valueC",
+ properties.convertToAaiProperties(operation)
+ .get("dataC"));
+ }
+} \ No newline at end of file
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java
new file mode 100644
index 000000000..514df4e2f
--- /dev/null
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.cds.properties;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+
+public class GrpcOperationPropertiesTest {
+
+ @Test
+ public void build() {
+ ControlLoopOperationParams params = ControlLoopOperationParams.builder().targetType(TargetType.VNF).build();
+ assertEquals(GrpcOperationTargetVnfProperties.VNF_PROPERTY_NAMES,
+ GrpcOperationProperties.build(params).getPropertyNames());
+
+ Map<String, String> targetEntityIds = new HashMap<>();
+ targetEntityIds.put(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, "R");
+
+ params = ControlLoopOperationParams.builder()
+ .targetType(TargetType.VNF)
+ .targetEntityIds(targetEntityIds)
+ .build();
+ assertEquals(GrcpOperationResourceVnfProperties.VNF_PROPERTY_NAMES,
+ GrpcOperationProperties.build(params).getPropertyNames());
+
+ params = ControlLoopOperationParams.builder().targetType(TargetType.PNF).build();
+ assertEquals(GrpcOperationPnfProperties.PNF_PROPERTY_NAMES,
+ GrpcOperationProperties.build(params).getPropertyNames());
+
+ params = ControlLoopOperationParams.builder()
+ .targetType(TargetType.VFC)
+ .targetEntityIds(targetEntityIds)
+ .build();
+ assertEquals(GrcpOperationResourceVnfProperties.VNF_PROPERTY_NAMES,
+ GrpcOperationProperties.build(params).getPropertyNames());
+ }
+} \ No newline at end of file
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java
new file mode 100644
index 000000000..798a96bed
--- /dev/null
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.cds.properties;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Collections;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.cds.properties.CdsServerProperties;
+import org.onap.policy.common.utils.time.PseudoExecutor;
+import org.onap.policy.controlloop.actor.cds.GrpcConfig;
+import org.onap.policy.controlloop.actor.cds.GrpcOperation;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+
+public class GrpcOperationTargetVnfPropertiesTest {
+
+ @Test
+ public void getPropertyNames() {
+ assertEquals(GrpcOperationTargetVnfProperties.VNF_PROPERTY_NAMES,
+ new GrpcOperationTargetVnfProperties().getPropertyNames());
+ }
+
+ @Test
+ public void convertToAaiProperties() {
+ ControlLoopOperationParams params =
+ ControlLoopOperationParams.builder()
+ .targetType(TargetType.VNF)
+ .build();
+
+ GrpcOperation operation =
+ new GrpcOperation(params, new GrpcConfig(new PseudoExecutor(), new CdsServerProperties()));
+
+ GrpcOperationTargetVnfProperties properties = new GrpcOperationTargetVnfProperties();
+ assertThatIllegalStateException()
+ .isThrownBy(() -> properties.convertToAaiProperties(operation));
+
+ operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, "v");
+ assertEquals("v",
+ properties.convertToAaiProperties(operation)
+ .get(GrpcOperationTargetVnfProperties.AAI_VNF_ID_KEY));
+
+ assertNull(properties.convertToAaiProperties(operation)
+ .get(GrcpOperationResourceVnfProperties.AAI_SERVICE_INSTANCE_ID_KEY));
+
+ operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES, Collections.emptyMap());
+ assertNull(properties.convertToAaiProperties(operation)
+ .get(GrpcOperationTargetVnfProperties.AAI_VNF_ID_KEY));
+
+ operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES,
+ Map.of("aa", "AA"));
+ assertEquals("AA",
+ properties.convertToAaiProperties(operation)
+ .get("aa"));
+ }
+} \ No newline at end of file