diff options
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test')
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java (renamed from adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java) | 14 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java | 42 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java | 2 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java | 2 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/resources/schema.sql | 2 |
5 files changed, 43 insertions, 19 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java index d7739e56f6..bcf126d887 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java @@ -40,10 +40,10 @@ import org.springframework.core.env.Environment; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; -public class AuditStackServiceDataTest extends AuditStackServiceData { +public class AuditCreateStackServiceTest extends AuditCreateStackService { @InjectMocks - AuditStackServiceData auditStackService = new AuditStackServiceData(); + AuditCreateStackService auditStackService = new AuditCreateStackService(); @Mock HeatStackAudit heatStackAuditMock; @@ -73,14 +73,14 @@ public class AuditStackServiceDataTest extends AuditStackServiceData { @Test public void execute_external_task_audit_success_Test() { - doReturn(true).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(true).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).complete(mockExternalTask); } @Test public void execute_external_task_audit_first_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); doReturn(null).when(mockExternalTask).getRetries(); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, @@ -90,7 +90,7 @@ public class AuditStackServiceDataTest extends AuditStackServiceData { @Test public void execute_external_task_audit_intermediate_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); doReturn(6).when(mockExternalTask).getRetries(); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, @@ -101,11 +101,11 @@ public class AuditStackServiceDataTest extends AuditStackServiceData { @Test public void execute_external_task_audit_final_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); doReturn(1).when(mockExternalTask).getRetries(); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, - "AuditAAIInventoryFailure"); + "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory"); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java index 02557d8c20..9176b58de8 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java @@ -58,8 +58,6 @@ import com.woorea.openstack.heat.model.Resources; @RunWith(MockitoJUnitRunner.Silent.class) public class AuditVServerTest extends AuditVServer { - private ObjectMapper objectMapper = new ObjectMapper(); - @InjectMocks private AuditVServer auditNova = new AuditVServer(); @@ -225,9 +223,13 @@ public class AuditVServerTest extends AuditVServer { @Test public void audit_Vserver_Empty_HashSet() throws JsonParseException, JsonMappingException, IOException { - boolean exists = auditNova.auditVservers(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion); + assertEquals(true, doNotExist); } + @Test public void audit_Vserver_Found_Test() throws JsonParseException, JsonMappingException, IOException { @@ -246,8 +248,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(true, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -268,8 +273,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -288,16 +296,23 @@ public class AuditVServerTest extends AuditVServer { 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); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test - public void audit_Vserver_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { + public void audit_Vservers_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { doReturn(false).when(aaiResourcesMock).exists(vserverURI); doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(true, doNotExist); } @Test @@ -306,8 +321,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(vserverURI2); doReturn(Optional.of(test_port_1_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_1_uri); doReturn(Optional.of(test_port_2_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_2_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -325,8 +343,12 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java index 696784110b..5eea46d09f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java @@ -203,7 +203,7 @@ public class HeatStackAuditTest extends HeatStackAudit { Resources getResource = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class); doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName"); - boolean actual = heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName"); + boolean actual = heatStackAudit.auditHeatStackCreate(cloudRegion, "cloudOwner", tenantId, "heatStackName"); assertEquals(true, actual); } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 75cea9eafc..376076a0a0 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -65,7 +65,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{ @Test public void createVfModule() throws Exception { - //expectedException.expect(VnfException.class); + Map<String, Object> stackInputs = new HashMap<>(); stackInputs.put("oof_directives", "{}"); stackInputs.put("sdnc_directives", "{}"); diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index e9f2a09860..ac08f8b645 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -384,6 +384,8 @@ create table `vnf_resource_customization` ( `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, `resource_input` varchar(20000) default null, + `cds_blueprint_name` varchar(200), + `cds_blueprint_version` varchar(200), primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade |