diff options
Diffstat (limited to 'asdc-controller/src/test')
3 files changed, 85 insertions, 6 deletions
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java index 844adeede2..846eaf47e2 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java @@ -33,10 +33,7 @@ import org.onap.sdc.toscaparser.api.parameters.Input; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.installer.ToscaResourceStructure; import org.onap.so.db.catalog.beans.Service; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedHashMap; +import java.util.*; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Mockito.when; @@ -61,6 +58,27 @@ public class ToscaResourceInputTest { Input input; @Test + public void getListResourceInput() { + ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); + LinkedHashMap<String, Property> hashMap = new LinkedHashMap<>(); + hashMap.put("key1", property); + Map<String, Object> map = new HashMap<>(); + map.put("customizationUUID", "69df3303-d2b3-47a1-9d04-41604d3a95fd"); + Metadata metadata = new Metadata(map); + when(nodeTemplate.getProperties()).thenReturn(hashMap); + when(property.getValue()).thenReturn(getInput); + when(getInput.getInputName()).thenReturn("nameKey"); + when(input.getName()).thenReturn("nameKey"); + when(input.getDefault()).thenReturn("defaultValue"); + when(getInput.toString()).thenReturn("getinput:[sites,INDEX,role]"); + when(nodeTemplate.getMetaData()).thenReturn(metadata); + List<Input> inputs = new ArrayList<>(); + inputs.add(input); + String resourceInput = toscaResourceInstaller.getVnfcResourceInput(nodeTemplate, inputs); + assertEquals("{\\\"key1\\\":\\\"[sites,INDEX,role]|defaultValue\\\"}", resourceInput); + } + + @Test public void processResourceSequenceTest() { ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java index dd107f7775..bd8e877369 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java @@ -34,6 +34,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.hibernate.exception.LockAcquisitionException; import org.junit.Before; import org.junit.Rule; @@ -42,6 +43,7 @@ import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl; @@ -56,6 +58,7 @@ import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl; import org.onap.so.asdc.client.test.emulators.JsonStatusData; import org.onap.so.asdc.client.test.emulators.NotificationDataImpl; +import org.onap.so.asdc.installer.ResourceStructure; import org.onap.so.asdc.installer.ToscaResourceStructure; import org.onap.so.db.catalog.beans.ConfigurationResource; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; @@ -340,7 +343,59 @@ public class ToscaResourceInstallerTest extends BaseTest { return actualWatchdogComponentDistributionStatus; } - + @Test + public void createServiceTest() { + ToscaResourceStructure toscaResourceStructure = mock(ToscaResourceStructure.class); + ResourceStructure resourceStructure = mock(ResourceStructure.class); + Metadata metadata = mock(Metadata.class); + INotificationData notification = mock(INotificationData.class); + + doReturn("e2899e5c-ae35-434c-bada-0fabb7c1b44d").when(toscaResourceStructure).getServiceVersion(); + doReturn(metadata).when(toscaResourceStructure).getServiceMetadata(); + doReturn("production").when(notification).getWorkloadContext(); + doReturn(notification).when(resourceStructure).getNotification(); + + String serviceType = "test-type"; + String serviceRole = "test-role"; + String category = "Network L4+"; + String description = "Customer Orderable service description"; + String name = "Customer Orderable Service"; + String uuid = "72db5868-4575-4804-b546-0b0d3c3b5ac6"; + String invariantUUID = "6f30bbe3-4590-4185-a7e0-4f9610926c6f"; + String namingPolicy = "naming Policy"; + String ecompGeneratedNaming = "true"; + String environmentContext = "General_Revenue-Bearing"; + + doReturn(serviceType).when(metadata).getValue("serviceType"); + doReturn(serviceRole).when(metadata).getValue("serviceRole"); + + doReturn(category).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); + doReturn(description).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION); + + doReturn(name).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME); + + doReturn(uuid).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID); + + doReturn(environmentContext).when(metadata).getValue(metadata.getValue("environmentContext")); + doReturn(invariantUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID); + doReturn(namingPolicy).when(metadata).getValue("namingPolicy"); + doReturn(ecompGeneratedNaming).when(metadata).getValue("ecompGeneratedNaming"); + + Service service = toscaInstaller.createService(toscaResourceStructure, resourceStructure); + + assertNotNull(service); + + verify(toscaResourceStructure, times(2)).getServiceVersion(); + assertNotNull(service.getNamingPolicy()); + assertEquals(serviceType, service.getServiceType()); + assertEquals(serviceRole, service.getServiceRole()); + assertEquals(category, service.getCategory()); + assertEquals(description, service.getDescription()); + assertEquals(uuid, service.getModelUUID()); + assertEquals(invariantUUID, service.getModelInvariantUUID()); + assertEquals(namingPolicy, service.getNamingPolicy()); + assertTrue(service.getOnapGeneratedNaming()); + } private void prepareConfigurationResource() { doReturn(metadata).when(nodeTemplate).getMetaData(); @@ -396,7 +451,7 @@ public class ToscaResourceInstallerTest extends BaseTest { assertNotNull(configurationResourceCustomization); assertNotNull(configurationResourceCustomization.getConfigurationResource()); assertEquals(MockConstants.MODEL_CUSTOMIZATIONUUID, - configurationResourceCustomization.getServiceProxyResourceCustomizationUUID()); + configurationResourceCustomization.getServiceProxyResourceCustomization().getModelCustomizationUUID()); } @Test diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index 8cc5ee9d49..5e4af83e0e 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -806,6 +806,9 @@ CREATE TABLE `service` ( `WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL, `SERVICE_CATEGORY` varchar(200) DEFAULT NULL, `RESOURCE_ORDER` varchar(200) default NULL, + `OVERALL_DISTRIBUTION_STATUS` varchar(45), + `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL, + `NAMING_POLICY` varchar(200) DEFAULT NULL, PRIMARY KEY (`MODEL_UUID`), KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`), CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE @@ -1109,6 +1112,7 @@ CREATE TABLE `vnf_resource_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL, `SERVICE_MODEL_UUID` varchar(200) NOT NULL, + `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`), KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`), @@ -1135,6 +1139,8 @@ CREATE TABLE `vnfc_customization` ( `MODEL_NAME` varchar(200) NOT NULL, `TOSCA_NODE_TYPE` varchar(200) NOT NULL, `DESCRIPTION` varchar(1200) DEFAULT NULL, + `RESOURCE_INPUT` varchar(20000) DEFAULT NULL, + `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL, `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; |