aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java17
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPolicies.json10
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete0.json10
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete1.json10
5 files changed, 62 insertions, 7 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
index 5cb775180e..4984b2fbb5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
@@ -30,6 +30,8 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
@@ -39,6 +41,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Captor;
import org.mockito.InjectMocks;
+import org.onap.aai.domain.yang.NetworkPolicies;
import org.onap.aai.domain.yang.NetworkPolicy;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -50,11 +53,13 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.exception.BBObjectNotFoundException;
public class AAIDeleteTasksTest extends BaseTaskTest {
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
@InjectMocks
private AAIDeleteTasks aaiDeleteTasks = new AAIDeleteTasks();
@@ -191,11 +196,14 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
@Test
public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
- NetworkPolicy networkPolicy0 = new NetworkPolicy();
- networkPolicy0.setNetworkPolicyId("testNetworkPolicyId0");
- NetworkPolicy networkPolicy1 = new NetworkPolicy();
- networkPolicy1.setNetworkPolicyId("testNetworkPolicyId1");
- doReturn(Optional.of(networkPolicy0),Optional.of(networkPolicy1)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ final String content0 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json")));
+ AAIResultWrapper aaiResultWrapper0 = new AAIResultWrapper(content0);
+ NetworkPolicies networkPolicies0 = aaiResultWrapper0.asBean(NetworkPolicies.class).get();
+ final String content1 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete1.json")));
+ AAIResultWrapper aaiResultWrapper1 = new AAIResultWrapper(content1);
+ NetworkPolicies networkPolicies1 = aaiResultWrapper1.asBean(NetworkPolicies.class).get();
+
+ doReturn(Optional.of(networkPolicies0),Optional.of(networkPolicies1)).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class));
aaiDeleteTasks.deleteNetworkPolicies(execution);
verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture());
@@ -206,8 +214,8 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
@Test
public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception {
execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
- Optional<NetworkPolicy> networkPolicy = Optional.empty();
- doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ Optional<NetworkPolicies> networkPolicies = Optional.empty();
+ doReturn(networkPolicies).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
aaiDeleteTasks.deleteNetworkPolicies(execution);
verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
index 2e2cc5d974..8632a6afdd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
@@ -56,6 +56,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
@@ -191,6 +192,22 @@ public class AAINetworkResourcesTest extends TestDataSetup{
}
@Test
+ public void getNetworkPoliciesTest() throws Exception {
+ final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicies.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<org.onap.aai.domain.yang.NetworkPolicies> oNetPolicies = Optional.empty();
+ AAIResourceUri netPoliciesUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oNetPolicies = aaiNetworkResources.getNetworkPolicies(netPoliciesUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+ if (oNetPolicies.isPresent()) {
+ org.onap.aai.domain.yang.NetworkPolicies networkPolicies = oNetPolicies.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicies.class).get(), sameBeanAs(networkPolicies));
+ }
+ }
+
+ @Test
public void getRouteTableTest() throws Exception {
final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkTableRefs.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPolicies.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPolicies.json
new file mode 100644
index 0000000000..3bd60a777e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPolicies.json
@@ -0,0 +1,10 @@
+{"network-policy":
+ [
+ {
+ "network-policy-id":"1ac71fb8-ad43-4e16-9459-c3f372b8236d",
+ "network-policy-fqdn":"default-domain:enpx-26177-T-E2E-rdm6a:enpx-26177-T-E2E-rdm6a_TIPXH-DBEV-VIF-TDAT0_net_1",
+ "heat-stack-id":"InfraMSO-vSAMP12_14_1.0-VF-Base-1902-est01-GR_API-021119-1/9a3be28f-115d-4693-9b17-9291b98b46de",
+ "resource-version":"1550068250015"
+ }
+ ]
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete0.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete0.json
new file mode 100644
index 0000000000..f60c6d97ad
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete0.json
@@ -0,0 +1,10 @@
+{"network-policy":
+ [
+ {
+ "network-policy-id":"testNetworkPolicyId0",
+ "network-policy-fqdn":"ABC123",
+ "heat-stack-id":"InfraMSO-vSAMP12_14_1.0-VF-Base-1902-est01-GR_API-021119-1/9a3be28f-115d-4693-9b17-9291b98b46de",
+ "resource-version":"1550068250015"
+ }
+ ]
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete1.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete1.json
new file mode 100644
index 0000000000..6aaea8eec8
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/queryAaiNetworkPoliciesForDelete1.json
@@ -0,0 +1,10 @@
+{"network-policy":
+ [
+ {
+ "network-policy-id":"testNetworkPolicyId1",
+ "network-policy-fqdn":"DEF456",
+ "heat-stack-id":"InfraMSO-vSAMP12_14_1.0-VF-Base-1902-est01-GR_API-021119-1/9a3be28f-115d-4693-9b17-9291b98b46de",
+ "resource-version":"1550068250015"
+ }
+ ]
+} \ No newline at end of file