use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method test_VFW_Distribution.
@Test
@Transactional
public void test_VFW_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())));
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File("src/test/resources/resource-examples/vFW/notification.json"), NotificationDataImpl.class);
headers.add("resource-location", "src/test/resources/resource-examples/vFW/");
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());
Service expectedService = new Service();
expectedService.setDescription("catalog service description");
expectedService.setModelInvariantUUID("3164f9ff-d7e7-4813-ab32-6be7e1cacb18");
expectedService.setModelName("vFW 2019-04-10 21:53:05");
expectedService.setModelUUID("e16e4ed9-3429-423a-bc3c-1389ae91491c");
expectedService.setModelVersion("1.0");
Service actualService = serviceRepo.findOneByModelUUID("e16e4ed9-3429-423a-bc3c-1389ae91491c");
if (actualService == null)
throw new Exception("No Allotted Resource Written to database");
assertEquals(expectedService.getModelName(), actualService.getModelName());
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCControllerITTest method treatNotification_ValidPnfResource_ExpectedOutput.
/**
* Test with service-pnfservice.csar.
*/
@Test
public void treatNotification_ValidPnfResource_ExpectedOutput() {
/**
* service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
*/
String serviceUuid = "77cf276e-905c-43f6-8d54-dda474be2f2e";
String serviceInvariantUuid = "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
initMockAaiServer(serviceUuid, serviceInvariantUuid);
NotificationDataImpl notificationData = new NotificationDataImpl();
notificationData.setServiceUUID(serviceUuid);
notificationData.setDistributionID(distributionId);
notificationData.setServiceInvariantUUID(serviceInvariantUuid);
notificationData.setServiceVersion("1.0");
ResourceInfoImpl resourceInfo = constructPnfResourceInfo();
List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
resourceInfoList.add(resourceInfo);
notificationData.setResources(resourceInfoList);
ArtifactInfoImpl artifactInfo = constructPnfServiceArtifact();
List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
artifactInfoList.add(artifactInfo);
notificationData.setServiceArtifacts(artifactInfoList);
try {
asdcController.treatNotification(notificationData);
logger.info("Checking the database for PNF ingestion");
/**
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid).orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-pnfservice.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
assertNull("tosca csar descrption", toscaCsar.getDescription());
assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
assertEquals("toscar csar URL", "/download/service-pnfservice.csar", toscaCsar.getUrl());
/**
* Check the service entity, it should be the same as global metadata information in
* service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid).orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
assertEquals("model UUID", serviceUuid, service.getModelUUID());
assertEquals("model name", "PNF Service Test CDS", service.getModelName());
assertEquals("model invariantUUID", serviceInvariantUuid, service.getModelInvariantUUID());
assertEquals("model version", "1.0", service.getModelVersion());
assertEquals("description", "123123", service.getDescription().trim());
assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
assertEquals("service type", "", service.getServiceType());
assertEquals("service role", "", service.getServiceRole());
assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext());
assertEquals("service category", "Network L1-3", service.getCategory());
assertNull("workload context", service.getWorkloadContext());
assertEquals("resource order", "PNF CDS Test", service.getResourceOrder());
assertEquals("CDS blueprint name", "Blueprint140", service.getBlueprintName());
assertEquals("CDS blueprint version", "v1.4.0", service.getBlueprintVersion());
assertEquals("controller actor", "SO-REF-DATA", service.getControllerActor());
/**
* Check PNF resource, it should be the same as metadata in the topology template in
* service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
*/
String pnfResourceKey = "aa5d0562-80e7-43e9-af74-3085e57ab09f";
PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey).orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
assertNull("orchestration mode", pnfResource.getOrchestrationMode());
assertEquals("Description", "123123", pnfResource.getDescription().trim());
assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID());
assertEquals("model invariant UUID", "17d9d183-cee5-4a46-b5c4-6d5203f7d2e8", pnfResource.getModelInvariantUUID());
assertEquals("model version", "1.0", pnfResource.getModelVersion());
assertEquals("model name", "PNF CDS Test", pnfResource.getModelName());
assertEquals("tosca node type", "org.openecomp.resource.pnf.PnfCdsTest", pnfResource.getToscaNodeType());
assertEquals("resource category", "Application L4+", pnfResource.getCategory());
assertEquals("resource sub category", "Firewall", pnfResource.getSubCategory());
/**
* Check PNF resource customization, it should be the same as metadata in the topology template in
* service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
*/
String pnfCustomizationKey = "9f01263a-eaf7-4d98-a37b-3785f751903e";
PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey).orElseThrow(() -> new EntityNotFoundException("PNF resource customization: " + pnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "PNF CDS Test 0", pnfCustomization.getModelInstanceName());
assertEquals("NF type", "", pnfCustomization.getNfType());
assertEquals("NF Role", "nf", pnfCustomization.getNfRole());
assertEquals("NF function", "nf", pnfCustomization.getNfFunction());
assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode());
assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID());
assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
assertNull("resource input", pnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", "Blueprint140", pnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", "v1.4.0", pnfCustomization.getBlueprintVersion());
assertTrue("skip post instantiation configuration", pnfCustomization.getSkipPostInstConf());
assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor());
/**
* Check the pnf resource customization with service mapping
*/
List<PnfResourceCustomization> pnfCustList = service.getPnfCustomizations();
assertEquals("PNF resource customization entity", 1, pnfCustList.size());
assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID());
/**
* Check the watchdog for component distribution status
*/
List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus());
assertEquals("SO", distributionStatus.getComponentName());
} catch (Exception e) {
logger.info(e.getMessage(), e);
fail(e.getMessage());
}
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ToscaResourceInstallerTest method prepareToscaResourceStructure.
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(resourceCustomizationUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
doReturn(uuid).when(metadata).getValue(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(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(metadata).when(nodeTemplate).getMetaData();
List<NodeTemplate> nodeList = new ArrayList<>();
nodeList.add(nodeTemplate);
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;
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCControllerITTest method treatNotification_ValidVnfResource_ExpectedOutput.
/**
* Testing with the service-Svc140-VF-csar.csar.
*/
@Test
public void treatNotification_ValidVnfResource_ExpectedOutput() {
/**
* service UUID/invariantUUID from global metadata in resource-Testvf140-template.yml.
*/
String serviceUuid = "28944a37-de3f-46ec-9c60-b57036fbd26d";
String serviceInvariantUuid = "9e900d3e-1e2e-4124-a5c2-4345734dc9de";
initMockAaiServer(serviceUuid, serviceInvariantUuid);
NotificationDataImpl notificationData = new NotificationDataImpl();
notificationData.setServiceUUID(serviceUuid);
notificationData.setDistributionID(distributionId);
notificationData.setServiceInvariantUUID(serviceInvariantUuid);
notificationData.setServiceVersion("1.0");
ResourceInfoImpl resourceInfo = constructVnfResourceInfo();
List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
resourceInfoList.add(resourceInfo);
notificationData.setResources(resourceInfoList);
ArtifactInfoImpl artifactInfo = constructVnfServiceArtifact();
List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
artifactInfoList.add(artifactInfo);
notificationData.setServiceArtifacts(artifactInfoList);
try {
asdcController.treatNotification(notificationData);
logger.info("Checking the database for VNF ingestion");
/**
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid).orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-vnfservice.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
assertNull("tosca csar descrption", toscaCsar.getDescription());
assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
assertEquals("toscar csar URL", "/download/service-vnfservice.csar", toscaCsar.getUrl());
/**
* Check the service entity, it should be the same as global metadata information in
* service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid).orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
assertEquals("model UUID", serviceUuid, service.getModelUUID());
assertEquals("model name", "SVC140", service.getModelName());
assertEquals("model invariantUUID", serviceInvariantUuid, service.getModelInvariantUUID());
assertEquals("model version", "1.0", service.getModelVersion());
assertEquals("description", "SVC140", service.getDescription().trim());
assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
assertEquals("service type", "ST", service.getServiceType());
assertEquals("service role", "Sr", service.getServiceRole());
assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext());
assertEquals("service category", "Network Service", service.getCategory());
assertNull("workload context", service.getWorkloadContext());
assertEquals("resource order", "TestVF140", service.getResourceOrder());
assertEquals("CDS blueprint name", "BP140", service.getBlueprintName());
assertEquals("CDS blueprint version", "v1.4.0", service.getBlueprintVersion());
assertEquals("controller actor", "SO-REF-DATA", service.getControllerActor());
/**
* Check VNF resource, it should be the same as metadata in the topology template in
* service-Testservice140-template.yml OR global metadata in the resource-Testservice140-template.yml
*/
String vnfResourceKey = "d20d3ea9-2f54-4071-8b5c-fd746dde245e";
VnfResource vnfResource = vnfResourceRepository.findById(vnfResourceKey).orElseThrow(() -> new EntityNotFoundException("VNF resource:" + vnfResourceKey + " not found"));
assertEquals("orchestration mode", "HEAT", vnfResource.getOrchestrationMode());
assertEquals("Description", "TestPNF140", vnfResource.getDescription().trim());
assertEquals("model UUID", vnfResourceKey, vnfResource.getModelUUID());
assertEquals("model invariant UUID", "7a4bffa2-fac5-4b8b-b348-0bdf313a1aeb", vnfResource.getModelInvariantUUID());
assertEquals("model version", "1.0", vnfResource.getModelVersion());
assertEquals("model name", "TestVF140", vnfResource.getModelName());
assertEquals("tosca node type", "org.openecomp.resource.vf.Testvf140", vnfResource.getToscaNodeType());
assertEquals("resource category", "Application L4+", vnfResource.getCategory());
assertEquals("resource sub category", "Database", vnfResource.getSubCategory());
/**
* Check VNF resource customization, it should be the same as metadata in the topology template in
* service-Testservice140-template.yml OR global metadata in the resource-Testservice140-template.yml
*/
String vnfCustomizationKey = "ca1c8455-8ce2-4a76-a037-3f4cf01cffa0";
VnfResourceCustomization vnfCustomization = Optional.ofNullable(vnfCustomizationRepository.findOneByModelCustomizationUUID(vnfCustomizationKey)).orElseThrow(() -> new EntityNotFoundException("VNF resource customization: " + vnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", vnfCustomizationKey, vnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "TestVF140 0", vnfCustomization.getModelInstanceName());
assertNull("NF type", vnfCustomization.getNfType());
assertNull("NF Role", vnfCustomization.getNfRole());
assertNull("NF function", vnfCustomization.getNfFunction());
assertNull("NF naming code", vnfCustomization.getNfNamingCode());
assertEquals("VNF resource model UUID", vnfResourceKey, vnfCustomization.getVnfResources().getModelUUID());
assertEquals("Multi stage design", "false", vnfCustomization.getMultiStageDesign());
assertNotNull("resource input", vnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", "BP140", vnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", "v1.4.0", vnfCustomization.getBlueprintVersion());
assertEquals("controller actor", "SO-REF-DATA", vnfCustomization.getControllerActor());
/**
* Check the vnf resource customization with service mapping
*/
List<VnfResourceCustomization> vnfCustList = service.getVnfCustomizations();
assertEquals("VNF resource customization entity", 1, vnfCustList.size());
assertEquals(vnfCustomizationKey, vnfCustList.get(0).getModelCustomizationUUID());
/**
* Check the watchdog for component distribution status
*/
List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus());
assertEquals("SO", distributionStatus.getComponentName());
} catch (Exception e) {
logger.info(e.getMessage(), e);
fail(e.getMessage());
}
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCControllerITTest method treatNotification_ValidPnfResource_With_Software_Version_ExpectedOutput.
/**
* Test with service-Ericservice-csar.csar to test software_vesrions field.
*/
@Test
public void treatNotification_ValidPnfResource_With_Software_Version_ExpectedOutput() {
/**
* service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
*/
// "77cf276e-905c-43f6-8d54-dda474be2f2e";
String serviceUuid = "8e7b2bd7-6901-4cc2-b3fb-3b6a1d5631e3";
// "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
String serviceInvariantUuid = "9a5f99c8-0492-4691-b29a-7360d9c3aae3";
initMockAaiServer(serviceUuid, serviceInvariantUuid);
NotificationDataImpl notificationData = new NotificationDataImpl();
notificationData.setServiceUUID(serviceUuid);
notificationData.setDistributionID(distributionId);
notificationData.setServiceInvariantUUID(serviceInvariantUuid);
notificationData.setServiceVersion("1.0");
ResourceInfoImpl resourceInfo = constructPnfResourceInfoWithSWV1();
List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
resourceInfoList.add(resourceInfo);
notificationData.setResources(resourceInfoList);
ArtifactInfoImpl artifactInfo = constructPnfServiceArtifactWithSWV();
List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
artifactInfoList.add(artifactInfo);
notificationData.setServiceArtifacts(artifactInfoList);
try {
asdcController.treatNotification(notificationData);
logger.info("Checking the database for PNF ingestion");
/**
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid).orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-Ericservice-csar.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
assertNull("tosca csar descrption", toscaCsar.getDescription());
assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
assertEquals("toscar csar URL", "/download/service-Ericservice-csar.csar", toscaCsar.getUrl());
/**
* Check the service entity, it should be the same as global metadata information in
* service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid).orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
/**
* Check PNF resource, it should be the same as metadata in the topology template in
* service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
*/
String pnfResourceKey = "7a90f80b-a6f6-4597-8c48-80bda26b4823";
/**
* Check PNF resource customization, it should be the same as metadata in the topology template in
* service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
*/
// "9f01263a-eaf7-4d98-a37b-3785f751903e";
String pnfCustomizationKey = "05660370-41ed-4720-a42b-d6def010c326";
PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey).orElseThrow(() -> new EntityNotFoundException("PNF resource customization: " + pnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "demo-PNF 0", pnfCustomization.getModelInstanceName());
assertEquals("NF type", "", pnfCustomization.getNfType());
assertEquals("NF Role", "", pnfCustomization.getNfRole());
assertEquals("NF function", "", pnfCustomization.getNfFunction());
assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode());
assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID());
assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
assertNull("resource input", pnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", "pm_control", pnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", "1.0.0", pnfCustomization.getBlueprintVersion());
assertEquals("default software version", "foo-123", pnfCustomization.getDefaultSoftwareVersion());
assertTrue("skip post instantiation configuration", pnfCustomization.getSkipPostInstConf());
assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor());
/**
* Check the pnf resource customization with service mapping
*/
List<PnfResourceCustomization> pnfCustList = service.getPnfCustomizations();
assertEquals("PNF resource customization entity", 1, pnfCustList.size());
assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID());
/**
* Check the watchdog for component distribution status
*/
List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus());
assertEquals("SO", distributionStatus.getComponentName());
} catch (Exception e) {
logger.info(e.getMessage(), e);
fail(e.getMessage());
}
}
Aggregations