aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test')
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java51
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java113
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java191
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java444
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/HeatStackAuditTest.java298
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java8
6 files changed, 4 insertions, 1101 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java
deleted file mode 100644
index c70e60e9d3..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.onap.so.adapters.tasks.audit;
-
-import org.junit.Test;
-import org.onap.so.objects.audit.AAIObjectAudit;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class AbstractAuditServiceTest extends AbstractAuditService {
-
- private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existenceState) {
- AAIObjectAudit auditObject = new AAIObjectAudit();
- AAIObjectAuditList auditList = new AAIObjectAuditList();
-
- auditObject.setDoesObjectExist(existenceState);
- auditList.getAuditList().add(auditObject);
-
- return auditList;
- }
-
- @Test
- public void didCreateAuditFail_shouldReturnFalse_whenGivenNull() {
- assertFalse(didCreateAuditFail(null));
- }
-
- @Test
- public void didCreateAuditFail_shouldReturnTrue_whenGivenNotExistingObject() {
- assertTrue(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(false)));
- }
-
- @Test
- public void didCreateAuditFail_shouldReturnFalse_whenGivenExistingObject() {
- assertFalse(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(true)));
- }
-
- @Test
- public void didDeleteAuditFail_shouldReturnFalse_whenGivenNull() {
- assertFalse(didDeleteAuditFail(null));
- }
-
- @Test
- public void didDeleteAuditFail_shouldReturnTrue_whenGivenExistingObject() {
- assertTrue(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(true)));
- }
-
- @Test
- public void didDeleteAuditFail_shouldReturnFalse_whenGivenNotExistingObject() {
- assertFalse(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(false)));
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java
deleted file mode 100644
index 76e5bbc47f..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.onap.so.adapters.tasks.audit;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.aai.domain.yang.Vserver;
-import org.onap.so.audit.beans.AuditInventory;
-import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
-import org.onap.so.db.request.beans.RequestProcessingData;
-import org.onap.so.db.request.client.RequestsDbClient;
-import org.onap.so.objects.audit.AAIObjectAudit;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import com.fasterxml.jackson.core.JsonProcessingException;
-
-
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class AuditDataServiceTest {
-
- @InjectMocks
- AuditDataService auditDataService = new AuditDataService();
-
- @Mock
- protected RequestsDbClient requestsDbClient;
-
- AuditInventory auditInventory = new AuditInventory();
-
- @Before
- public void before() throws JsonProcessingException {
- auditInventory.setCloudOwner("testCloudOwner");
- auditInventory.setCloudRegion("testLcpCloudRegionId");
- auditInventory.setHeatStackName("testVfModuleName1");
- auditInventory.setVfModuleId("testVnfModuleId");
- auditInventory.setTenantId("testTenantId");
- auditInventory.setGenericVnfId("testVnfId1");
- }
-
- @Test
- public void testWriteStackDataToRequestDb() throws Exception {
- Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient)
- .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any());
- Mockito.doNothing().when(requestsDbClient).saveRequestProcessingData(Mockito.any());
-
- AAIObjectAuditList auditList = new AAIObjectAuditList();
- auditList.setHeatStackName("testHeatStackName");
- AAIObjectAudit audit = new AAIObjectAudit();
- Vserver vserver = new Vserver();
- vserver.setVserverId("testVserverId");
- audit.setAaiObject(vserver);
- auditList.getAuditList().add(audit);
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- String auditListString = objectMapper.getMapper().writeValueAsString(auditList);
-
- RequestProcessingData requestProcessingData = new RequestProcessingData();
- requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId());
- requestProcessingData.setGroupingId(auditInventory.getVfModuleId());
- requestProcessingData.setName(auditInventory.getHeatStackName());
- requestProcessingData.setTag("AuditStackData");
- requestProcessingData.setValue(auditListString);
-
- auditDataService.writeStackDataToRequestDb(auditInventory, auditList);
- Mockito.verify(requestsDbClient, Mockito.times(1)).saveRequestProcessingData(requestProcessingData);
- }
-
- @Test
- public void testGetStackDataToRequestDb() throws Exception {
- AAIObjectAuditList auditList = new AAIObjectAuditList();
- auditList.setHeatStackName("testHeatStackName");
- AAIObjectAudit audit = new AAIObjectAudit();
- Vserver vserver = new Vserver();
- vserver.setVserverId("testVserverId");
- audit.setAaiObject(vserver);
- auditList.getAuditList().add(audit);
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- String auditListString = objectMapper.getMapper().writeValueAsString(audit);
-
- List<RequestProcessingData> list = new ArrayList();
- RequestProcessingData requestProcessingData = new RequestProcessingData();
- requestProcessingData.setId(234321432);
- requestProcessingData.setGroupingId("testVfModuleId");
- requestProcessingData.setName("heatStackName");
- requestProcessingData.setTag("AuditStackData");
- requestProcessingData.setValue(auditListString);
- list.add(requestProcessingData);
-
- Mockito.doReturn(list).when(requestsDbClient).getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(),
- Mockito.any(), Mockito.any());
- auditDataService.getStackDataFromRequestDb(auditInventory);
- Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag(
- "testVnfModuleId", "testVfModuleName1", "AuditStackData");
- }
-
- @Test
- public void testGetStackDataToRequestDbWhenRequestProcessingDataListIsEmpty() throws Exception {
-
- Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient)
- .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any());
- Optional<AAIObjectAuditList> result = auditDataService.getStackDataFromRequestDb(auditInventory);
- Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag(
- "testVnfModuleId", "testVfModuleName1", "AuditStackData");
- assertThat(result).isEmpty();
-
- }
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java
deleted file mode 100644
index 78dbcd94c2..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017-2019 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.so.adapters.tasks.audit;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Optional;
-import org.camunda.bpm.client.task.ExternalTask;
-import org.camunda.bpm.client.task.ExternalTaskService;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.onap.so.adapters.tasks.audit.AuditCreateStackService;
-import org.onap.so.adapters.tasks.audit.AuditDataService;
-import org.onap.so.adapters.tasks.audit.AuditQueryStackService;
-import org.onap.so.adapters.tasks.audit.HeatStackAudit;
-import org.onap.so.audit.beans.AuditInventory;
-import org.onap.so.logging.tasks.AuditMDCSetup;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.springframework.core.env.Environment;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class AuditStackServiceDataTest extends AuditCreateStackService {
-
- @InjectMocks
- private AuditCreateStackService auditStackService = new AuditCreateStackService();
-
- @InjectMocks
- private AuditQueryStackService auditQueryStackService = new AuditQueryStackService();
-
- @Mock
- private HeatStackAudit heatStackAuditMock;
-
- @Mock
- private Environment mockEnv;
-
- @Mock
- private ExternalTask mockExternalTask;
-
- @Mock
- private ExternalTaskService mockExternalTaskService;
-
- @Mock
- private AuditDataService auditDataService;
-
- @Mock
- private AuditMDCSetup mdcSetup;
-
- private ObjectMapper objectMapper = new ObjectMapper();
-
- private AuditInventory auditInventory = new AuditInventory();
-
- Optional<AAIObjectAuditList> auditListOptSuccess;
-
- Optional<AAIObjectAuditList> auditListOptFailure;
-
- @Before
- public void setup() throws JsonParseException, JsonMappingException, IOException {
- auditInventory.setCloudOwner("cloudOwner");
- auditInventory.setCloudRegion("cloudRegion");
- auditInventory.setTenantId("tenantId");
- auditInventory.setHeatStackName("stackName");
- MockitoAnnotations.initMocks(this);
-
- AAIObjectAuditList auditListSuccess = objectMapper
- .readValue(new File("src/test/resources/ExpectedVServerFound.json"), AAIObjectAuditList.class);
- auditListOptSuccess = Optional.of(auditListSuccess);
-
- AAIObjectAuditList auditListFailure = objectMapper.readValue(
- new File("src/test/resources/Vserver2_Found_VServer1_Not_Found.json"), AAIObjectAuditList.class);
- auditListOptFailure = Optional.of(auditListFailure);
- String[] retrySequence = new String[8];
- retrySequence[0] = "1";
- retrySequence[1] = "1";
- retrySequence[2] = "2";
- retrySequence[3] = "3";
- retrySequence[4] = "5";
- retrySequence[5] = "8";
- retrySequence[6] = "13";
- retrySequence[7] = "20";
- doReturn(auditInventory).when(mockExternalTask).getVariable("auditInventory");
- doReturn("6000").when(mockEnv).getProperty("mso.workflow.topics.retryMultiplier", "6000");
- doReturn(retrySequence).when(mockEnv).getProperty("mso.workflow.topics.retrySequence", String[].class);
- doReturn("aasdfasdf").when(mockExternalTask).getId();
- }
-
- @Test
- public void execute_external_task_audit_success_Test() {
- doReturn(auditListOptSuccess).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId",
- "stackName");
- auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
- ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
- ArgumentCaptor<ExternalTask> taskCaptor = ArgumentCaptor.forClass(ExternalTask.class);
- Mockito.verify(mockExternalTaskService).complete(taskCaptor.capture(), captor.capture());
- Map actualMap = captor.getValue();
- assertEquals(true, actualMap.get("auditIsSuccessful"));
- assertNotNull(actualMap.get("auditInventoryResult"));
- }
-
- @Test
- public void executeExternalTaskQueryAuditTest() throws JsonProcessingException {
- doReturn(auditListOptSuccess).when(heatStackAuditMock).queryHeatStack("cloudOwner", "cloudRegion", "tenantId",
- "stackName");
- Mockito.doNothing().when(auditDataService).writeStackDataToRequestDb(Mockito.any(AuditInventory.class),
- Mockito.any(AAIObjectAuditList.class));
- auditQueryStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
- ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
- ArgumentCaptor<ExternalTask> taskCaptor = ArgumentCaptor.forClass(ExternalTask.class);
- Mockito.verify(mockExternalTaskService).complete(taskCaptor.capture(), captor.capture());
- Mockito.verify(auditDataService).writeStackDataToRequestDb(Mockito.any(AuditInventory.class),
- Mockito.any(AAIObjectAuditList.class));
- }
-
- @Test
- public void execute_external_task_audit_first_failure_Test() {
- doReturn(auditListOptFailure).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId",
- "stackName");
- doReturn(null).when(mockExternalTask).getRetries();
- auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
- Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask,
- "Unable to find all VServers and L-Interaces in A&AI",
- "Unable to find all VServers and L-Interaces in A&AI", 8, 10000L);
- }
-
- @Test
- public void execute_external_task_audit_intermediate_failure_Test() {
- doReturn(auditListOptFailure).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId",
- "stackName");
- doReturn(6).when(mockExternalTask).getRetries();
- auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
- Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask,
- "Unable to find all VServers and L-Interaces in A&AI",
- "Unable to find all VServers and L-Interaces in A&AI", 5, 12000L);
-
- }
-
- @Test
- public void execute_external_task_audit_final_failure_Test() {
- doReturn(auditListOptFailure).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId",
- "stackName");
- doReturn(1).when(mockExternalTask).getRetries();
- auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
- ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
- ArgumentCaptor<ExternalTask> taskCaptor = ArgumentCaptor.forClass(ExternalTask.class);
- Mockito.verify(mockExternalTaskService).complete(taskCaptor.capture(), captor.capture());
- Map actualMap = captor.getValue();
- assertEquals(false, actualMap.get("auditIsSuccessful"));
- assertNotNull(actualMap.get("auditInventoryResult"));
- }
-
- @Test
- public void determineAuditResult_Test() throws Exception {
- boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess.get());
- assertEquals(false, actual);
- }
-
- @Test
- public void determineAuditResult_Failure_Test() throws Exception {
- boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure.get());
- assertEquals(true, actual);
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java
deleted file mode 100644
index 2e496c50cd..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017-2019 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 perservice2sions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.adapters.tasks.audit;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.aai.domain.yang.LInterface;
-import org.onap.aai.domain.yang.LInterfaces;
-import org.onap.aai.domain.yang.VfModule;
-import org.onap.aai.domain.yang.VfModules;
-import org.onap.aai.domain.yang.Vserver;
-import org.onap.aaiclient.client.aai.AAIObjectType;
-import org.onap.aaiclient.client.aai.AAIResourcesClient;
-import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
-import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
-import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
-import org.onap.so.objects.audit.AAIObjectAudit;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.skyscreamer.jsonassert.JSONAssert;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class AuditVServerTest extends AuditVServer {
-
- private ObjectMapper objectMapper = new ObjectMapper();
-
- @InjectMocks
- private AuditVServer auditNova = new AuditVServer();
-
- @Mock
- private AAIResourcesClient aaiResourcesMock;
-
- private String cloudOwner = "cloudOwner";
- private String cloudRegion = "cloudRegion";
- private String tenantId = "tenantId";
-
- private AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db"));
-
- private AAIResourceUri vserverURI2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz"));
-
- private AAIResourceUri ssc_1_trusted_port_0_uri = AAIUriFactory.createResourceUri(
- AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId)
- .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_trusted_port_0"));
-
- private AAIResourceUri ssc_1_service1_port_0_uri = AAIUriFactory.createResourceUri(
- AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId)
- .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_service1_port_0"));
-
- private AAIResourceUri ssc_1_mgmt_port_1_uri = AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion)
- .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_mgmt_port_1"));
-
- private AAIResourceUri ssc_1_mgmt_port_0_uri = AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion)
- .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_mgmt_port_0"));
-
- private AAIResourceUri ssc_1_service2_port_0_uri = AAIUriFactory.createResourceUri(
- AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId)
- .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_service2_port_0"));
-
- private AAIResourceUri ssc_1_int_ha_port_0_uri = AAIUriFactory.createResourceUri(
- AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId)
- .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_int_ha_port_0"));
-
- private AAIResourceUri test_port_1_uri = AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion)
- .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz").lInterface("test_port_1"));
-
- private AAIResourceUri test_port_2_uri = AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion)
- .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz").lInterface("test_port_2"));
-
- private AAIResourceUri service2_sub_1_uri =
- AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, cloudRegion, tenantId,
- "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service2_port_0", "service2_sub_interface_1");
-
- private AAIResourceUri service1_sub_0_uri =
- AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, cloudRegion, tenantId,
- "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service1_port_0", "service1_sub_interface_1");
-
- private AAIResourceUri service1_sub_1_uri =
- AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, cloudRegion, tenantId,
- "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service1_port_0", "service1_sub_interface_2");
-
-
-
- private Set<Vserver> vserversToAudit = new HashSet<>();
-
- LInterface test_port_1 = new LInterface();
- LInterface test_port_2 = new LInterface();
- LInterface ssc_1_int_ha_port_0 = new LInterface();
- LInterface service2_sub_interface_1 = new LInterface();
- LInterface ssc_1_service2_port_0 = new LInterface();
- LInterface ssc_1_mgmt_port_0 = new LInterface();
- LInterface ssc_1_mgmt_port_1 = new LInterface();
- LInterface service1_sub_interface_2 = new LInterface();
- LInterface service1_sub_interface_1 = new LInterface();
- LInterface ssc_1_service1_port_0 = new LInterface();
- LInterface ssc_1_trusted_port_0 = new LInterface();
-
-
-
- @Before
- public void setup() {
- objectMapper.setSerializationInclusion(Include.NON_NULL);
- auditNova.setAaiClient(aaiResourcesMock);
-
- Vserver vServer1 = new Vserver();
- vServer1.setVserverId("3a4c2ca5-27b3-4ecc-98c5-06804867c4db");
- LInterfaces vServer1Linterfaces = new LInterfaces();
- vServer1.setLInterfaces(vServer1Linterfaces);
-
- ssc_1_trusted_port_0.setInterfaceId("dec8bdc7-5718-41dc-bfbb-561ff6eeb81c");
- ssc_1_trusted_port_0.setInterfaceName("ssc_1_trusted_port_0");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_trusted_port_0);
-
-
- ssc_1_service1_port_0.setInterfaceId("1c56a24b-5f03-435a-850d-31cd4252de56");
- ssc_1_service1_port_0.setInterfaceName("ssc_1_service1_port_0");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_service1_port_0);
- ssc_1_service1_port_0.setLInterfaces(new LInterfaces());
-
-
- service1_sub_interface_1.setInterfaceId("0d9cd813-2ae1-46c0-9ebb-48081f6cffbb");
- service1_sub_interface_1.setInterfaceName("service1_sub_interface_1");
- ssc_1_service1_port_0.getLInterfaces().getLInterface().add(service1_sub_interface_1);
-
-
- service1_sub_interface_2.setInterfaceId("b7019dd0-2ee9-4447-bdef-ac25676b205a");
- service1_sub_interface_2.setInterfaceName("service1_sub_interface_2");
- ssc_1_service1_port_0.getLInterfaces().getLInterface().add(service1_sub_interface_2);
-
-
- ssc_1_mgmt_port_1.setInterfaceId("12afcd28-929f-4d80-8a5a-0833bfd5e20b");
- ssc_1_mgmt_port_1.setInterfaceName("ssc_1_mgmt_port_1");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_1);
-
- ssc_1_mgmt_port_0.setInterfaceId("80baec42-ffae-425f-ad8c-3f7b2c24bfff");
- ssc_1_mgmt_port_0.setInterfaceName("ssc_1_mgmt_port_0");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_0);
-
-
- ssc_1_service2_port_0.setLInterfaces(new LInterfaces());
- ssc_1_service2_port_0.setInterfaceId("13eddf95-4cf3-45f2-823a-2d890a6549b4");
- ssc_1_service2_port_0.setInterfaceName("ssc_1_service2_port_0");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_service2_port_0);
-
-
- service2_sub_interface_1.setInterfaceId("f711be16-2654-4a09-b89d-0511fda20e81");
- service2_sub_interface_1.setInterfaceName("service2_sub_interface_1");
- ssc_1_service2_port_0.getLInterfaces().getLInterface().add(service2_sub_interface_1);
-
-
- ssc_1_int_ha_port_0.setInterfaceId("9cab2903-70f7-44fd-b681-491d6ae2adb8");
- ssc_1_int_ha_port_0.setInterfaceName("ssc_1_int_ha_port_0");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_int_ha_port_0);
-
- Vserver vServer2 = new Vserver();
- vServer2.setVserverId("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz");
- LInterfaces vServer2Linterfaces = new LInterfaces();
- vServer2.setLInterfaces(vServer2Linterfaces);
-
- test_port_1.setInterfaceId("9cab2903-70f7-44fd-b681-491d6ae2adz1");
- test_port_1.setInterfaceName("test_port_1");
-
-
- test_port_2.setInterfaceId("9cab2903-70f7-44fd-b681-491d6ae2adz2");
- test_port_2.setInterfaceName("test_port_2");
-
- vServer2.getLInterfaces().getLInterface().add(test_port_1);
- vServer2.getLInterfaces().getLInterface().add(test_port_2);
-
- vserversToAudit.add(vServer1);
- vserversToAudit.add(vServer2);
- }
-
- @Test
- public void audit_Vserver_Empty_HashSet() throws JsonParseException, JsonMappingException, IOException {
- Optional<AAIObjectAuditList> actual =
- auditNova.auditVservers(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion);
- assertEquals(Optional.empty(), actual);
- }
-
- @Test
- public void audit_Vserver_Found_Test() throws JsonParseException, JsonMappingException, IOException {
- doReturn(true).when(aaiResourcesMock).exists(vserverURI);
- doReturn(true).when(aaiResourcesMock).exists(vserverURI2);
- doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_trusted_port_0_uri);
- doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service1_port_0_uri);
- doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri);
- doReturn(Optional.of(ssc_1_mgmt_port_0)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri);
- doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service2_port_0_uri);
- doReturn(Optional.of(service2_sub_interface_1)).when(aaiResourcesMock).get(LInterface.class,
- service1_sub_1_uri);
- doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_int_ha_port_0_uri);
- doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri);
- doReturn(Optional.of(test_port_2)).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri);
-
- doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
-
- Optional<AAIObjectAuditList> actual =
- auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
- String actualString = objectMapper.writeValueAsString(actual.get());
- String expected = getJson("ExpectedVServerFound.json");
- JSONAssert.assertEquals(expected, actualString, false);
- }
-
- @Test
- public void audit_Vserver_Found_Test_Network_Not_Found()
- throws JsonParseException, JsonMappingException, IOException {
- doReturn(true).when(aaiResourcesMock).exists(vserverURI);
- doReturn(true).when(aaiResourcesMock).exists(vserverURI2);
- doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_trusted_port_0_uri);
- doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service1_port_0_uri);
- doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri);
- doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri);
- doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service2_port_0_uri);
- doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_int_ha_port_0_uri);
- doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri);
- doReturn(Optional.of(test_port_2)).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri);
-
- doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
-
- Optional<AAIObjectAuditList> actual =
- auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
- String actualString = objectMapper.writeValueAsString(actual.get());
- String expected = getJson("VServer_Found_network_Not_Found.json");
- JSONAssert.assertEquals(expected, actualString, false);
- }
-
- @Test
- public void audit_Vserver_Found_Test_Network_Not_Found_Second_Server()
- throws JsonParseException, JsonMappingException, IOException {
- doReturn(true).when(aaiResourcesMock).exists(vserverURI);
- doReturn(true).when(aaiResourcesMock).exists(vserverURI2);
- doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_trusted_port_0_uri);
- doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service1_port_0_uri);
- doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri);
- doReturn(Optional.of(ssc_1_mgmt_port_0)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri);
- doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service2_port_0_uri);
- doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_int_ha_port_0_uri);
- doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri);
- doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri);
- doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
- Optional<AAIObjectAuditList> actual =
- auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
- String actualString = objectMapper.writeValueAsString(actual.get());
- String expected = getJson("VServer_Found_Network_Sec_Server_Not_Found.json");
- JSONAssert.assertEquals(expected, actualString, false);
- }
-
- @Test
- public void audit_Vserver_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException {
- doReturn(false).when(aaiResourcesMock).exists(vserverURI);
- doReturn(false).when(aaiResourcesMock).exists(vserverURI2);
- Optional<AAIObjectAuditList> actual =
- auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
- String actualString = objectMapper.writeValueAsString(actual.get());
- String expected = getJson("Vservers_Not_Found.json");
- JSONAssert.assertEquals(expected, actualString, false);
- }
-
- @Test
- public void audit_Vserver_first_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException {
- doReturn(false).when(aaiResourcesMock).exists(vserverURI);
- doReturn(true).when(aaiResourcesMock).exists(vserverURI2);
- doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri);
- doReturn(Optional.of(test_port_2)).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri);
- Optional<AAIObjectAuditList> actual =
- auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
- String actualString = objectMapper.writeValueAsString(actual.get());
- String expected = getJson("Vserver2_Found_VServer1_Not_Found.json");
- JSONAssert.assertEquals(expected, actualString, false);
- }
-
-
- @Test
- public void doesSubInterfaceExistinAAI_Test() {
- AAIResourceUri subInterfaceURI = AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner,
- cloudRegion, tenantId, "vserverId", "l-interface", "sub-interface");
-
- assertEquals(
- "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/cloudRegion/tenants/tenant/tenantId/vservers/vserver/vserverId/l-interfaces/l-interface/l-interface/l-interfaces/l-interface/sub-interface",
- subInterfaceURI.build().toString());
- }
-
- @Test
- public void audit_Vserver_Second_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException {
- doReturn(true).when(aaiResourcesMock).exists(vserverURI);
- doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_trusted_port_0_uri);
- doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service1_port_0_uri);
- doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri);
- doReturn(Optional.of(ssc_1_mgmt_port_0)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri);
- doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_service2_port_0_uri);
- doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class,
- ssc_1_int_ha_port_0_uri);
- doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri);
- doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri);
- doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
- doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
-
- doReturn(false).when(aaiResourcesMock).exists(vserverURI2);
- Optional<AAIObjectAuditList> actual =
- auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
- String actualString = objectMapper.writeValueAsString(actual.get());
- String expected = getJson("VServer_Found_Sec_Server_Not_Found2.json");
-
- JSONAssert.assertEquals(expected, actualString, false);
- }
-
- @Test
- public void testAuditVserversWithList() {
-
- AAIObjectAuditList auditList = new AAIObjectAuditList();
- AAIObjectAudit obj1 = new AAIObjectAudit();
- Vserver vserver = new Vserver();
- vserver.setVserverId("testVserverId");
- obj1.setAaiObject(vserver);
- obj1.setResourceURI(
- AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId"))
- .build());
- auditList.getAuditList().add(obj1);
-
- doReturn(false).when(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder
- .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId")));
-
- auditNova.auditVservers(auditList);
-
- Mockito.verify(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder
- .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId")));
-
- Assert.assertEquals(false, auditList.getAuditList().get(0).isDoesObjectExist());
- }
-
- @Test
- public void testAuditVserversThroughRelationships() {
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("id");
-
- AAIResultWrapper wrapper = new AAIResultWrapper(vfModule);
-
- doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class,
- AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("genericVnfId").vfModules())
- .queryParam("vf-module-name", "vfModuleName"));
-
- Optional<AAIObjectAuditList> auditList =
- auditNova.auditVserversThroughRelationships("genericVnfId", "vfModuleName");
-
- Assert.assertTrue(auditList.get().getAuditList().isEmpty());
- }
-
- @Test
- public void testAuditVserversThroughRelationships_exists() throws IOException {
-
- String vfModule = getJson("vfModule.json");
-
- AAIResultWrapper wrapper = new AAIResultWrapper(vfModule);
- AAIResultWrapper vserverWrapper = new AAIResultWrapper(new Vserver());
-
- doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class,
- AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("genericVnfId").vfModules())
- .queryParam("vf-module-name", "vfModuleName"));
-
- doReturn(vserverWrapper).when(aaiResourcesMock)
- .get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .cloudRegion("cloud-owner", "cloud-region-id").tenant("tenant-id").vserver("VUSCHGA1")));
-
- Optional<AAIObjectAuditList> auditList =
- auditNova.auditVserversThroughRelationships("genericVnfId", "vfModuleName");
-
- Assert.assertFalse(auditList.get().getAuditList().isEmpty());
- }
-
-
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename)));
- }
-
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/HeatStackAuditTest.java
deleted file mode 100644
index d1d0d96042..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/HeatStackAuditTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017-2019 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.so.adapters.tasks.audit;
-
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.aai.domain.yang.LInterface;
-import org.onap.aai.domain.yang.LInterfaces;
-import org.onap.aai.domain.yang.Vserver;
-import org.onap.so.adapters.tasks.audit.AuditVServer;
-import org.onap.so.adapters.tasks.audit.HeatStackAudit;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.onap.so.openstack.utils.MsoHeatUtils;
-import org.onap.so.openstack.utils.MsoNeutronUtils;
-import org.skyscreamer.jsonassert.JSONAssert;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.woorea.openstack.heat.model.Resource;
-import com.woorea.openstack.heat.model.Resources;
-import com.woorea.openstack.heat.model.Stack;
-import com.woorea.openstack.quantum.model.Port;
-
-
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class HeatStackAuditTest extends HeatStackAudit {
-
- @InjectMocks
- private HeatStackAudit heatStackAudit = new HeatStackAudit();
-
- @Mock
- private MsoHeatUtils msoHeatUtilsMock;
-
- @Mock
- private MsoNeutronUtils neutronUtilsMock;
-
- @Mock
- private AuditVServer auditVserver;
-
- private static final String cloudRegion = "cloudRegion";
- private static final String tenantId = "tenantId";
-
- private Resources resources = new Resources();
-
- private ObjectMapper objectMapper =
- new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
- .setSerializationInclusion(Include.NON_NULL);
-
- private ObjectMapper stackObjectMapper = new ObjectMapper()
- .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true).setSerializationInclusion(Include.NON_NULL);
-
- private List<Optional<Port>> portList = new ArrayList<>();
-
- @Before
- public void setup() throws Exception {
- resources = objectMapper.readValue(new File("src/test/resources/GetResources.json"), Resources.class);
- Port neutronPort1 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort1.json"), Port.class);
- doReturn(Optional.of(neutronPort1)).when(neutronUtilsMock)
- .getNeutronPort("7ee06d9d-3d18-411c-9d3e-aec930f70413", cloudRegion, tenantId);
- Port neutronPort2 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort2.json"), Port.class);
- doReturn(Optional.of(neutronPort2)).when(neutronUtilsMock)
- .getNeutronPort("27391d94-33af-474a-927d-d409249e8fd3", cloudRegion, tenantId);
- Port neutronPort3 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort3.json"), Port.class);
- doReturn(Optional.of(neutronPort3)).when(neutronUtilsMock)
- .getNeutronPort("fdeedf37-c01e-4ab0-bdd6-8d5fc4913943", cloudRegion, tenantId);
- Port neutronPort4 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort4.json"), Port.class);
- doReturn(Optional.of(neutronPort4)).when(neutronUtilsMock)
- .getNeutronPort("8d93f63e-e972-48c7-ad98-b2122da47315", cloudRegion, tenantId);
- Port neutronPort5 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort5.json"), Port.class);
- doReturn(Optional.of(neutronPort5)).when(neutronUtilsMock)
- .getNeutronPort("0594a2f2-7ea4-42eb-abc2-48ea49677fca", cloudRegion, tenantId);
- Port neutronPort6 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort6.json"), Port.class);
- doReturn(Optional.of(neutronPort6)).when(neutronUtilsMock)
- .getNeutronPort("00bb8407-650e-48b5-b919-33b88d6f8fe3", cloudRegion, tenantId);
-
-
- portList.add(Optional.empty());
- portList.add(Optional.of(neutronPort1));
- portList.add(Optional.of(neutronPort2));
- portList.add(Optional.of(neutronPort3));
- portList.add(Optional.of(neutronPort4));
- portList.add(Optional.of(neutronPort5));
- portList.add(Optional.of(neutronPort6));
- }
-
- @Test
- public void extract_proper_path_Test() {
- Optional<String> actualResult = extractStackPathFromHref(
- "https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
- assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81", actualResult.get());
- }
-
- @Test
- public void extract_proper_resources_path_Test() {
- Optional<String> actualResult = extractResourcePathFromHref(
- "https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
- assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81/resources", actualResult.get());
- }
-
- @Test
- public void extract_invalid_uri_Test() {
- Optional<String> actualResult = extractStackPathFromHref(
- "orchestrn.com:8004/v18b44d60a6f94bdcb2738f9e//stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
- assertEquals(false, actualResult.isPresent());
- }
-
- @Test
- public void createVserverSet_Test() throws Exception {
- List<Resource> novaResources = resources.getList().stream().filter(p -> "OS::Nova::Server".equals(p.getType()))
- .collect(Collectors.toList());
-
- List<Resource> resourceGroups = resources.getList().stream()
- .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType())).collect(Collectors.toList());
-
- Resources service1QueryResponse = objectMapper
- .readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class);
- doReturn(service1QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources",
- cloudRegion, tenantId, Resources.class);
-
- Resources service2QueryResponse = objectMapper
- .readValue(new File("src/test/resources/Service2ResourceGroupResponse.json"), Resources.class);
- doReturn(service2QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c/resources",
- cloudRegion, tenantId, Resources.class);
-
-
- Stack service2StackQuerySubInt =
- stackObjectMapper.readValue(new File("src/test/resources/Service2SubInterface0.json"), Stack.class);
- doReturn(service2StackQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81",
- cloudRegion, tenantId, Stack.class);
- Resources service2ResourceQuerySubInt = objectMapper
- .readValue(new File("src/test/resources/Service2SubInterface1Resources.json"), Resources.class);
- doReturn(service2ResourceQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources",
- cloudRegion, tenantId, Resources.class);
-
- Stack service1StackQuerySubInt1 =
- stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface0.json"), Stack.class);
- doReturn(service1StackQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb",
- cloudRegion, tenantId, Stack.class);
- Resources service1ResourceQuerySubInt1 = objectMapper
- .readValue(new File("src/test/resources/Service1SubInterface0Resources.json"), Resources.class);
- doReturn(service1ResourceQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb/resources",
- cloudRegion, tenantId, Resources.class);
-
-
- Stack service1StackQuerySubInt2 =
- stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface1.json"), Stack.class);
- doReturn(service1StackQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a",
- cloudRegion, tenantId, Stack.class);
- Resources service1ResourceQuerySubInt2 = objectMapper
- .readValue(new File("src/test/resources/Service1SubInterface1Resources.json"), Resources.class);
- doReturn(service1ResourceQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a/resources",
- cloudRegion, tenantId, Resources.class);
-
- Stack service1StackQuerySubInt3 =
- stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface2.json"), Stack.class);
- doReturn(service1StackQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c",
- cloudRegion, tenantId, Stack.class);
- Resources service1ResourceQuerySubInt3 = objectMapper
- .readValue(new File("src/test/resources/Service1SubInterface2Resources.json"), Resources.class);
- doReturn(service1ResourceQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest(
- "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c/resources",
- cloudRegion, tenantId, Resources.class);
-
- Set<Vserver> vServersToAudit = heatStackAudit.createVserverSet(resources, novaResources, portList);
- Set<Vserver> vserversWithSubInterfaces =
- heatStackAudit.processSubInterfaces(cloudRegion, tenantId, resourceGroups, vServersToAudit);
-
- String actualValue = objectMapper.writeValueAsString(vserversWithSubInterfaces);
- String expectedValue = getJson("ExpectedVserversToAudit.json");
- JSONAssert.assertEquals(expectedValue, actualValue, false);
- }
-
- @Test
- public void auditHeatStackNoServers_Test() throws Exception {
- Resources getResource = objectMapper
- .readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class);
- doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName", 3);
-
- Optional<AAIObjectAuditList> actual =
- heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName");
- assertEquals(true, actual.get().getAuditList().isEmpty());
- }
-
- @Test
- public void auditHeatStackNestedServers_Test() throws Exception {
- Resources getResource =
- objectMapper.readValue(new File("src/test/resources/GetNestedResources.json"), Resources.class);
- List<Resource> novaResources = getResource.getList().stream()
- .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
- List<Resource> resourceGroups = getResource.getList().stream()
- .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType())).collect(Collectors.toList());
-
- doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName", 3);
- Set<Vserver> vServersToAudit = heatStackAudit.createVserverSet(resources, novaResources, portList);
- Set<Vserver> vserversWithSubInterfaces =
- heatStackAudit.processSubInterfaces(cloudRegion, tenantId, resourceGroups, vServersToAudit);
- String actualValue = objectMapper.writeValueAsString(vserversWithSubInterfaces);
- String expectedValue = getJson("NestedExpectedValue.json");
- JSONAssert.assertEquals(expectedValue, actualValue, false);
- }
-
-
- @Test
- public void findInterfaceInformation_Test() {
- List<Resource> novaResources = resources.getList().stream().filter(p -> "OS::Nova::Server".equals(p.getType()))
- .collect(Collectors.toList());
- Set<Vserver> expectedVservers = new HashSet<>();
- Vserver vServer1 = new Vserver();
- vServer1.setVserverId("92272b67-d23f-42ca-87fa-7b06a9ec81f3");
- LInterfaces vServer1Linterfaces = new LInterfaces();
- vServer1.setLInterfaces(vServer1Linterfaces);
-
- LInterface ssc_1_trusted_port_0 = new LInterface();
- ssc_1_trusted_port_0.setInterfaceId("7ee06d9d-3d18-411c-9d3e-aec930f70413");
- ssc_1_trusted_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_trusted_port_0);
-
- LInterface ssc_1_svc2_port_0 = new LInterface();
- ssc_1_svc2_port_0.setInterfaceId("27391d94-33af-474a-927d-d409249e8fd3");
- ssc_1_svc2_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_svc2_port_0);
-
- LInterface ssc_1_mgmt_port_1 = new LInterface();
- ssc_1_mgmt_port_1.setInterfaceId("fdeedf37-c01e-4ab0-bdd6-8d5fc4913943");
- ssc_1_mgmt_port_1.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_1);
-
- LInterface ssc_1_mgmt_port_0 = new LInterface();
- ssc_1_mgmt_port_0.setInterfaceId("8d93f63e-e972-48c7-ad98-b2122da47315");
- ssc_1_mgmt_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_0);
-
- LInterface ssc_1_svc1_port_0 = new LInterface();
- ssc_1_svc1_port_0.setInterfaceId("0594a2f2-7ea4-42eb-abc2-48ea49677fca");
- ssc_1_svc1_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_svc1_port_0);
-
- LInterface ssc_1_int_ha_port_0 = new LInterface();
- ssc_1_int_ha_port_0.setInterfaceId("00bb8407-650e-48b5-b919-33b88d6f8fe3");
- ssc_1_int_ha_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port");
- vServer1.getLInterfaces().getLInterface().add(ssc_1_int_ha_port_0);
-
- expectedVservers.add(vServer1);
-
- Set<Vserver> actualVservers = heatStackAudit.createVserverSet(resources, novaResources, portList);
-
- assertThat(actualVservers, sameBeanAs(expectedVservers));
- }
-
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename)));
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
index ebc7c3a81e..309a143e32 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
@@ -215,7 +215,7 @@ public class HeatBridgeImplTest {
// Assert
ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class);
- verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class));
+ verify(transaction, times(2)).create(captor.capture(), any());
List<AAIResourceUri> uris = captor.getAllValues();
assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
@@ -259,7 +259,7 @@ public class HeatBridgeImplTest {
// Assert
ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class);
- verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class));
+ verify(transaction, times(2)).create(captor.capture(), any());
List<AAIResourceUri> uris = captor.getAllValues();
assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
@@ -539,7 +539,7 @@ public class HeatBridgeImplTest {
when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf));
// Act
- heatbridge.updateLInterfaceVlan(port, lIf, "hostname");
+ heatbridge.createVlanAndSriovVF(port, lIf, "hostname");
// Assert
verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
@@ -625,7 +625,7 @@ public class HeatBridgeImplTest {
PInterface pIf = mock(PInterface.class);
when(pIf.getInterfaceName()).thenReturn("test-port-id");
- doNothing().when(heatbridge).updateSriovPfToPserver(any(), any());
+ doNothing().when(heatbridge).updateSriovPfToSriovVF(any(), any());
// Act
heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner");