use of org.onap.so.db.catalog.beans.Service 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.db.catalog.beans.Service in project so by onap.
the class ToscaResourceInputTest method processResourceSequenceTest.
@Test
public void processResourceSequenceTest() {
ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
ArrayList<Input> inputs = new ArrayList<>();
Service service = new Service();
HashMap<String, Object> hashMap = new HashMap();
hashMap.put("name", "node1");
Metadata metadata = new Metadata(hashMap);
when(entityDetails.getMetadata()).thenReturn(metadata);
when(sdcCsarHelper.getServiceInputs()).thenReturn(inputs);
when(toscaResourceInstaller.getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false)).thenReturn(Arrays.asList(entityDetails));
when(entityDetails.getRequirements()).thenReturn(null);
toscaResourceInstaller.processResourceSequence(toscaResourceStructure, service);
assertEquals(service.getResourceOrder(), "");
}
use of org.onap.so.db.catalog.beans.Service 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.db.catalog.beans.Service in project so by onap.
the class SkipCDSBuildingBlockListener method run.
/**
* Skip the CDS Building block according to the Skip Flag.
*
* @param flowsToExecute - List of ExecuteBuildingBlock object.
* @param execution - BuildingBlockExecution object
* @param currentBB - ExecuteBuildingBlock object
*/
@Override
public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) {
String resourceKey = currentBB.getBuildingBlock().getKey();
List<Resource> resources = execution.getVariable("resources");
Resource resource = resources.stream().filter(r -> resourceKey.equals(r.getResourceId())).findFirst().orElseThrow(() -> new IllegalArgumentException("Resource not found for key:" + resourceKey));
String scope = currentBB.getBuildingBlock().getBpmnScope();
if ("SERVICE".equalsIgnoreCase(scope)) {
Service service = catalogDbClient.getServiceByID(resource.getModelVersionId());
currentSequenceSkipCheck(execution, service.getSkipPostInstConf());
} else if ("VNF".equalsIgnoreCase(scope) && containsIgnoreCaseAction(currentBB, vnfActions)) {
VnfResourceCustomization vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
if (vrc != null) {
logger.debug("getSkipPostInstConf value: " + vrc.getSkipPostInstConf());
boolean skipConfigVNF = vrc.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipConfigVNF);
}
} else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule") && containsIgnoreCaseAction(currentBB, vFModuleAction)) {
VfModuleCustomization vfc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(resource.getModelCustomizationId());
if (null != vfc) {
logger.debug("getSkipPostInstConf value: " + vfc.getSkipPostInstConf().booleanValue());
boolean skipVfModule = vfc.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipVfModule);
}
} else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("PNF") && containsIgnoreCaseAction(currentBB, pnfActions)) {
PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
if (null != pnfResourceCustomization) {
logger.debug("getSkipPostInstConf value: " + pnfResourceCustomization.getSkipPostInstConf());
boolean skipConfigPNF = pnfResourceCustomization.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipConfigPNF);
}
}
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class ServiceInstancesTest method setServiceTypeTestDefault.
@Test
public void setServiceTypeTestDefault() throws JsonProcessingException {
String requestScope = ModelType.service.toString();
Boolean aLaCarteFlag = false;
ServiceInstancesRequest sir = new ServiceInstancesRequest();
RequestDetails requestDetails = new RequestDetails();
RequestInfo requestInfo = new RequestInfo();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
requestInfo.setSource("VID");
requestDetails.setModelInfo(modelInfo);
requestDetails.setRequestInfo(requestInfo);
sir.setRequestDetails(requestDetails);
Service defaultService = new Service();
defaultService.setServiceType("testServiceType");
wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
wireMockServer.stubFor(get(urlMatching(".*/service/search/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
assertEquals(serviceType, "testServiceType");
}
Aggregations