diff options
author | Byung-Woo Jun <byung-woo.jun@est.tech> | 2019-08-26 16:03:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-08-26 16:03:39 +0000 |
commit | 6e3d7ef904de93d7d6b8ae4f043fa200ce802453 (patch) | |
tree | af254a4e69c1d8d32fb913feea06df8b75f445ec | |
parent | a83fa219608559e1c9a82e4cfc5a345d6c3ec636 (diff) | |
parent | 713b2b8be4dd1dd57f5ef9b0927ceb9bd3b009c4 (diff) |
Merge "Fix parsing issue for ccvpn"
6 files changed, 335 insertions, 19 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 073412133c..90116ad4f5 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -742,8 +742,7 @@ public class ASDCController { logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID()); - if ("VF".equals(resourceType) && resource.getArtifacts() != null - && !resource.getArtifacts().isEmpty()) { + if ("VF".equals(resourceType)) { resourceStructure = new VfResourceStructure(iNotif, resource); } else if ("PNF".equals(resourceType)) { resourceStructure = new PnfResourceStructure(iNotif, resource); @@ -761,8 +760,8 @@ public class ASDCController { logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure.getResourceInstance().getResourceUUID()); - if ("VF".equals(resourceType) && resource.getArtifacts() != null - && !resource.getArtifacts().isEmpty()) { + + if ("VF".equals(resourceType)) { hasVFResource = true; for (IArtifactInfo artifact : resource.getArtifacts()) { IDistributionClientDownloadResult resultArtifact = diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 83827b425e..08aee1ab4e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -437,20 +437,17 @@ public class ToscaResourceInstaller { List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); - List<IEntityDetails> arEntityDetails = new ArrayList<IEntityDetails>(); - for (IEntityDetails vfEntityDetails : vfEntityList) { Metadata metadata = vfEntityDetails.getMetadata(); - String category = metadata.getValue("category"); + String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); - if ("Allotted Resource".equalsIgnoreCase(category)) { - arEntityDetails.add(vfEntityDetails); + if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) { + continue; } processVfModules(vfEntityDetails, vfNodeTemplatesList.get(0), toscaResourceStruct, vfResourceStructure, service, metadata); - } processResourceSequence(toscaResourceStruct, service); @@ -667,6 +664,8 @@ public class ToscaResourceInstaller { } else { NetworkResourceCustomization networkCustomization = createNetwork(vlEntity, toscaResourceStruct, null, null, null, service); + networkCustomization.setResourceInput( + getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID())); service.getNetworkCustomizations().add(networkCustomization); logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " + networkResourceModelName); @@ -677,11 +676,14 @@ public class ToscaResourceInstaller { } protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service, - List<NodeTemplate> allottedResourceList) { + List<NodeTemplate> allottedResourceList) throws ArtifactInstallerException { if (allottedResourceList != null) { for (NodeTemplate allottedNode : allottedResourceList) { - service.getAllottedCustomizations() - .add(createAllottedResource(allottedNode, toscaResourceStruct, service)); + AllottedResourceCustomization allottedResource = + createAllottedResource(allottedNode, toscaResourceStruct, service); + allottedResource.setResourceInput( + getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID())); + service.getAllottedCustomizations().add(allottedResource); } } } @@ -1370,7 +1372,14 @@ public class ToscaResourceInstaller { Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); - Service service = new Service(); + List<Service> services = + serviceRepo.findByModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + Service service; + if (!services.isEmpty() && services.size() > 0) { + service = services.get(0); + } else { + service = new Service(); + } if (serviceMetadata != null) { @@ -1482,7 +1491,14 @@ public class ToscaResourceInstaller { } protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) { - ToscaCsar toscaCsar = new ToscaCsar(); + Optional<ToscaCsar> toscaCsarOpt = + toscaCsarRepo.findById(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); + ToscaCsar toscaCsar; + if (toscaCsarOpt.isPresent()) { + toscaCsar = toscaCsarOpt.get(); + } else { + toscaCsar = new ToscaCsar(); + } if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) { toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum()); } else { @@ -2789,8 +2805,10 @@ public class ToscaResourceInstaller { if (!services.isEmpty()) { // service exist in db Service existingService = services.get(0); - List<VnfResourceCustomization> vnfCustomizations = existingService.getVnfCustomizations(); - vnfCustomizations.forEach(e -> service.getVnfCustomizations().add(e)); + List<VnfResourceCustomization> existingVnfCustomizations = existingService.getVnfCustomizations(); + if (existingService != null) { + service.getVnfCustomizations().addAll(existingVnfCustomizations); + } } service.getVnfCustomizations().add(vnfResourceCustomization); } diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java index 2c520a3bba..cfcf5ac599 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java @@ -144,6 +144,7 @@ public class ASDCRestInterfaceTest extends BaseTest { AllottedResourceCustomization arCustomization = new AllottedResourceCustomization(); arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba"); arCustomization.setModelInstanceName("rege1802pnf 0"); + arCustomization.setResourceInput("{}"); arCustomizationSet.add(arCustomization); arCustomization.setAllottedResource(expectedService); @@ -164,7 +165,7 @@ public class ASDCRestInterfaceTest extends BaseTest { @Test @Transactional - public void test_VFW_Distrobution() throws Exception { + public void test_VFW_Distribution() throws Exception { wireMockServer.stubFor(post(urlPathMatching("/aai/.*")) .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json"))); @@ -290,6 +291,30 @@ public class ASDCRestInterfaceTest extends BaseTest { assertEquals("Generic NeutronNet", networkResource.get().getModelName()); } + @Test + public void test_CCVPN_Distribution() throws Exception { + wireMockServer.stubFor(post(urlPathMatching("/aai/.*")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json"))); + + wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withStatus(org.springframework.http.HttpStatus.ACCEPTED.value()))); + + String resourceLocation = "src/test/resources/resource-examples/ccvpn/"; + ObjectMapper mapper = new ObjectMapper(); + NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demo-ccvpn-notification.json"), + NotificationDataImpl.class); + headers.add("resource-location", resourceLocation); + HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers); + ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), + HttpMethod.POST, entity, String.class); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + Optional<Service> service = serviceRepo.findById("5c4d4793-67fb-4155-b7d8-60ec011138c9"); + assertTrue(service.isPresent()); + assertEquals("SDWAN", service.get().getModelName()); + } + protected String createURLWithPort(String uri) { return "http://localhost:" + port + uri; } 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 7534ea645a..ffad137ad7 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 @@ -25,16 +25,19 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import org.hibernate.exception.LockAcquisitionException; import org.junit.Before; @@ -54,26 +57,38 @@ import org.onap.sdc.toscaparser.api.Group; import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.sdc.toscaparser.api.RequirementAssignment; import org.onap.sdc.toscaparser.api.RequirementAssignments; +import org.onap.sdc.toscaparser.api.SubstitutionMappings; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.elements.StatefulEntityType; +import org.onap.sdc.toscaparser.api.parameters.Input; import org.onap.sdc.utils.DistributionStatusEnum; import org.onap.so.asdc.BaseTest; +import org.onap.so.asdc.client.ResourceInstance; 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.IVfModuleData; import org.onap.so.asdc.installer.ResourceStructure; import org.onap.so.asdc.installer.ToscaResourceStructure; +import org.onap.so.asdc.installer.VfModuleStructure; +import org.onap.so.asdc.installer.VfResourceStructure; +import org.onap.so.asdc.installer.bpmn.WorkflowResource; import org.onap.so.db.catalog.beans.ConfigurationResource; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.ToscaCsar; +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.AllottedResourceRepository; import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository; +import org.onap.so.db.catalog.data.repository.InstanceGroupRepository; import org.onap.so.db.catalog.data.repository.ServiceRepository; import org.onap.so.db.catalog.data.repository.ToscaCsarRepository; +import org.onap.so.db.catalog.data.repository.VFModuleRepository; +import org.onap.so.db.catalog.data.repository.VnfResourceRepository; +import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository; import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -111,6 +126,8 @@ public class ToscaResourceInstallerTest extends BaseTest { @Mock private ToscaResourceStructure toscaResourceStructure; @Mock + private VfResourceStructure vfResourceStruct; + @Mock private ServiceProxyResourceCustomization spResourceCustomization; @Mock private ISdcCsarHelper csarHelper; @@ -258,6 +275,206 @@ public class ToscaResourceInstallerTest extends BaseTest { } @Test + public void installTheResourceWithGroupAndVFModulesTest() throws Exception { + ToscaResourceInstaller toscaInstaller = new ToscaResourceInstaller(); + ToscaResourceStructure toscaResourceStructObj = prepareToscaResourceStructure(true, toscaInstaller); + + toscaInstaller.installTheResource(toscaResourceStructObj, vfResourceStruct); + assertEquals(true, toscaResourceStructObj.isDeployedSuccessfully()); + } + + @Test + public void installTheResourceGroupWithoutVFModulesTest() throws Exception { + ToscaResourceInstaller toscaInstaller = new ToscaResourceInstaller(); + ToscaResourceStructure toscaResourceStructObj = prepareToscaResourceStructure(false, toscaInstaller); + + toscaInstaller.installTheResource(toscaResourceStructObj, vfResourceStruct); + assertEquals(true, toscaResourceStructObj.isDeployedSuccessfully()); + } + + private ToscaResourceStructure prepareToscaResourceStructure(boolean prepareVFModuleStructures, + ToscaResourceInstaller toscaInstaller) throws ArtifactInstallerException { + + Metadata metadata = mock(Metadata.class); + IResourceInstance resourceInstance = mock(ResourceInstance.class); + NodeTemplate nodeTemplate = mock(NodeTemplate.class); + ISdcCsarHelper csarHelper = mock(SdcCsarHelperImpl.class); + + IArtifactInfo inputCsar = mock(IArtifactInfo.class); + String artifactUuid = "0122c05e-e13a-4c63-b5d2-475ccf23aa74"; + String checkSum = "MGUzNjJjMzk3OTBkYzExYzQ0MDg2ZDc2M2E3ZjZiZmY="; + + doReturn(checkSum).when(inputCsar).getArtifactChecksum(); + doReturn(artifactUuid).when(inputCsar).getArtifactUUID(); + doReturn("1.0").when(inputCsar).getArtifactVersion(); + doReturn("TestCsarWithGroupAndVFModule").when(inputCsar).getArtifactName(); + doReturn("Test Csar data with Group and VF module inputs").when(inputCsar).getArtifactDescription(); + doReturn("http://localhost/dummy/url/test.csar").when(inputCsar).getArtifactURL(); + + ToscaResourceStructure toscaResourceStructObj = new ToscaResourceStructure(); + toscaResourceStructObj.setToscaArtifact(inputCsar); + + ToscaCsarRepository toscaCsarRepo = spy(ToscaCsarRepository.class); + + + ToscaCsar toscaCsar = mock(ToscaCsar.class); + Optional<ToscaCsar> returnValue = Optional.of(toscaCsar); + doReturn(artifactUuid).when(toscaCsar).getArtifactUUID(); + doReturn(checkSum).when(toscaCsar).getArtifactChecksum(); + doReturn(returnValue).when(toscaCsarRepo).findById(artifactUuid); + + ReflectionTestUtils.setField(toscaInstaller, "toscaCsarRepo", toscaCsarRepo); + + NotificationDataImpl notificationData = new NotificationDataImpl(); + notificationData.setDistributionID("testStatusSuccessfulTosca"); + notificationData.setServiceVersion("1234567"); + notificationData.setServiceUUID("serviceUUID1"); + notificationData.setWorkloadContext("workloadContext1"); + + + + String serviceType = "test-type1"; + String serviceRole = "test-role1"; + String category = "Network L3+"; + 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 Policy1"; + String ecompGeneratedNaming = "true"; + String environmentContext = "General_Revenue-Bearing1"; + String resourceCustomizationUUID = "0177ba22-5547-4e4e-bcf8-178f7f71de3a"; + + 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("1.0").when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VERSION); + 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"); + doReturn(resourceCustomizationUUID).when(metadata).getValue("vfModuleModelCustomizationUUID"); + + ServiceRepository serviceRepo = spy(ServiceRepository.class); + + VnfResourceRepository vnfRepo = spy(VnfResourceRepository.class); + doReturn(null).when(vnfRepo).findResourceByModelUUID(uuid); + + VFModuleRepository vfModuleRepo = spy(VFModuleRepository.class); + InstanceGroupRepository instanceGroupRepo = spy(InstanceGroupRepository.class); + + WorkflowResource workflowResource = spy(WorkflowResource.class); + + ReflectionTestUtils.setField(toscaInstaller, "serviceRepo", serviceRepo); + ReflectionTestUtils.setField(toscaInstaller, "vnfRepo", vnfRepo); + ReflectionTestUtils.setField(toscaInstaller, "vfModuleRepo", vfModuleRepo); + ReflectionTestUtils.setField(toscaInstaller, "instanceGroupRepo", instanceGroupRepo); + ReflectionTestUtils.setField(toscaInstaller, "workflowResource", workflowResource); + + // doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper(); + toscaResourceStructObj.setSdcCsarHelper(csarHelper); + doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, + SdcPropertyNames.PROPERTY_NAME_NFFUNCTION); + doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, + SdcPropertyNames.PROPERTY_NAME_NFROLE); + doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, + SdcPropertyNames.PROPERTY_NAME_NFTYPE); + doReturn(resourceCustomizationUUID).when(csarHelper).getMetadataPropertyValue(metadata, + SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + doReturn(uuid).when(csarHelper).getMetadataPropertyValue(metadata, + SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID); + + + // vnfc instance group list + List<Group> vnfcInstanceGroupList = new ArrayList<>(); + Group vnfcG1 = mock(Group.class); + Map<String, Object> metaProperties = new HashMap<>(); + metaProperties.put(SdcPropertyNames.PROPERTY_NAME_UUID, "vnfc_group1_uuid"); + metaProperties.put(SdcPropertyNames.PROPERTY_NAME_NAME, "vnfc_group1_uuid"); + metaProperties.put(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID, "vnfc_group1_invariantid"); + metaProperties.put(SdcPropertyNames.PROPERTY_NAME_VERSION, "1.0"); + Metadata vnfcmetadata = new Metadata(metaProperties); + + doReturn(vnfcmetadata).when(vnfcG1).getMetadata(); + ArrayList<NodeTemplate> memberList = new ArrayList(); + doReturn(memberList).when(vnfcG1).getMemberNodes(); + vnfcInstanceGroupList.add(vnfcG1); + SubstitutionMappings submappings = mock(SubstitutionMappings.class); + doReturn(new ArrayList<Input>()).when(submappings).getInputs(); + doReturn(submappings).when(nodeTemplate).getSubMappingToscaTemplate(); + + doReturn(vnfcInstanceGroupList).when(csarHelper).getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate, + "org.openecomp.groups.VfcInstanceGroup"); + + + doReturn(notificationData).when(vfResourceStruct).getNotification(); + doReturn(resourceInstance).when(vfResourceStruct).getResourceInstance(); + + if (prepareVFModuleStructures) { + + // VfModule list + List<Group> vfModuleGroups = new ArrayList<>(); + Group g1 = mock(Group.class); + doReturn(metadata).when(g1).getMetadata(); + vfModuleGroups.add(g1); + + doReturn(vfModuleGroups).when(csarHelper).getVfModulesByVf(resourceCustomizationUUID); + doReturn("1").when(csarHelper).getGroupPropertyLeafValue(g1, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT); + + doReturn(metadata).when(nodeTemplate).getMetaData(); + List<NodeTemplate> nodeList = new ArrayList<>(); + nodeList.add(nodeTemplate); + doReturn(nodeList).when(csarHelper).getServiceVfList(); + + IVfModuleData moduleMetadata = mock(IVfModuleData.class); + doReturn(name).when(moduleMetadata).getVfModuleModelName(); + doReturn(invariantUUID).when(moduleMetadata).getVfModuleModelInvariantUUID(); + doReturn(Collections.<String>emptyList()).when(moduleMetadata).getArtifacts(); + doReturn(resourceCustomizationUUID).when(moduleMetadata).getVfModuleModelCustomizationUUID(); + doReturn(uuid).when(moduleMetadata).getVfModuleModelUUID(); + doReturn("1.0").when(moduleMetadata).getVfModuleModelVersion(); + + VfModuleStructure moduleStructure = new VfModuleStructure(vfResourceStruct, moduleMetadata); + + List<VfModuleStructure> moduleStructures = new ArrayList<>(); + moduleStructures.add(moduleStructure); + doReturn(moduleStructures).when(vfResourceStruct).getVfModuleStructure(); + } + + toscaResourceStructObj.setServiceMetadata(metadata); + doReturn("resourceInstanceName1").when(resourceInstance).getResourceInstanceName(); + doReturn(resourceCustomizationUUID).when(resourceInstance).getResourceCustomizationUUID(); + doReturn("resourceName1").when(resourceInstance).getResourceName(); + + Service service = toscaInstaller.createService(toscaResourceStructObj, vfResourceStruct); + + assertNotNull(service); + service.setModelVersion("1.0"); + + doReturn(service).when(serviceRepo).save(service); + + WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository = + spy(WatchdogComponentDistributionStatusRepository.class); + ReflectionTestUtils.setField(toscaInstaller, "watchdogCDStatusRepository", watchdogCDStatusRepository); + doReturn(null).when(watchdogCDStatusRepository).save(any(WatchdogComponentDistributionStatus.class)); + + VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo = + spy(VnfcInstanceGroupCustomizationRepository.class); + ReflectionTestUtils.setField(toscaInstaller, "vnfcInstanceGroupCustomizationRepo", + vnfcInstanceGroupCustomizationRepo); + doReturn(null).when(vnfcInstanceGroupCustomizationRepo).save(any(VnfcInstanceGroupCustomization.class)); + return toscaResourceStructObj; + } + + + + @Test public void installTheResourceExceptionTest() throws Exception { expectedException.expect(ArtifactInstallerException.class); diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json new file mode 100644 index 0000000000..bc7d7d7979 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json @@ -0,0 +1,57 @@ +{ + "distributionID": "cbc7ab24-7d96-4cb5-949c-f23ada265513", + "serviceName": "SDWAN", + "serviceVersion": "2.0", + "serviceUUID": "5c4d4793-67fb-4155-b7d8-60ec011138c9", + "serviceDescription": "SDWAN Service", + "serviceInvariantUUID": "e830c260-ee21-4830-980c-c802cd9bbb1c", + "resources": [ + { + "resourceInstanceName": "siteVF 0", + "resourceName": "siteVF", + "resourceVersion": "1.0", + "resoucreType": "VF", + "resourceUUID": "2c10d85c-e492-4813-a2d6-d1fab757fe49", + "resourceInvariantUUID": "ed9b1fe5-1e94-4974-a48f-389571837fd6", + "resourceCustomizationUUID": "33de5105-edf3-48cb-bda0-37b2aa2f681f", + "category": "Configuration", + "subcategory": "Configuration", + "artifacts": [] + }, + { + "resourceInstanceName": "vpn 0", + "resourceName": "vpn", + "resourceVersion": "2.0", + "resoucreType": "VF", + "resourceUUID": "235861f1-ea93-4443-94fa-82f29903f54f", + "resourceInvariantUUID": "c4eff5e7-c4fe-4caf-989b-11efc8e42a73", + "resourceCustomizationUUID": "faa89d44-329b-4fcb-a5dc-6e6f84946537", + "category": "Configuration", + "subcategory": "Configuration", + "artifacts": [] + } + ], + "serviceArtifacts": [ + { + "artifactName": "service-Sdwan-template.yml", + "artifactType": "TOSCA_TEMPLATE", + "artifactURL": "/sdc/v1/catalog/services/Sdwan/2.0/artifacts/service-Sdwan-template.yml", + "artifactChecksum": "Zjg4MmJmNzI1MTliYzBiZjA2ZmJjN2EwNzZhZTcxYTQ=", + "artifactDescription": "TOSCA representation of the asset", + "artifactTimeout": 0, + "artifactUUID": "5e7beb91-61f9-4613-8cc5-1d288a624abb", + "artifactVersion": "2" + }, + { + "artifactName": "service-Sdwan-csar.csar", + "artifactType": "TOSCA_CSAR", + "artifactURL": "/service-Sdwan-csar.csar", + "artifactChecksum": "ODA1ZGViMzI0NzIxMmRmNTIzYzE0ZTg5NmExYWFjZTE=", + "artifactDescription": "TOSCA definition package of the asset", + "artifactTimeout": 0, + "artifactUUID": "771ec21a-1d14-4891-a56f-d4e47e2c8c91", + "artifactVersion": "2" + } + ], + "workloadContext": "Production" +}
\ No newline at end of file diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar Binary files differnew file mode 100644 index 0000000000..7a508429f8 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar |