Search in sources :

Example 16 with VnfResource

use of org.onap.so.db.catalog.beans.VnfResource in project so by onap.

the class CatalogDbClientTest method testGetVnfResourceByModelUUIDNotFound.

@Test
public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
    VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
    assertNull(vnfResource);
}
Also used : VnfResource(org.onap.so.db.catalog.beans.VnfResource) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Example 17 with VnfResource

use of org.onap.so.db.catalog.beans.VnfResource in project so by onap.

the class CatalogDbClientTest method testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion.

@Test
public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
    VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
    assertNotNull(vnfResource);
    assertNotNull(vnfResource.getModelInvariantId());
    assertNotNull(vnfResource.getModelVersion());
    assertNotNull(vnfResource.getHeatTemplates());
    assertEquals("vSAMP10a", vnfResource.getModelName());
}
Also used : VnfResource(org.onap.so.db.catalog.beans.VnfResource) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Example 18 with VnfResource

use of org.onap.so.db.catalog.beans.VnfResource in project so by onap.

the class ToscaResourceInstaller method createVnfResource.

protected VnfResource createVnfResource(IEntityDetails entityDetails) {
    VnfResource vnfResource = new VnfResource();
    vnfResource.setModelInvariantUUID(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
    vnfResource.setModelName(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
    vnfResource.setModelUUID(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
    vnfResource.setModelVersion(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
    vnfResource.setDescription(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
    vnfResource.setOrchestrationMode(HEAT);
    vnfResource.setToscaNodeType(testNull(entityDetails.getToscaType()));
    vnfResource.setAicVersionMax(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
    vnfResource.setAicVersionMin(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
    vnfResource.setCategory(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
    vnfResource.setSubCategory(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
    return vnfResource;
}
Also used : VnfResource(org.onap.so.db.catalog.beans.VnfResource)

Example 19 with VnfResource

use of org.onap.so.db.catalog.beans.VnfResource in project so by onap.

the class ToscaResourceInstaller method processVfModules.

protected void processVfModules(IEntityDetails vfEntityDetails, ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, Service service, Metadata metadata) throws Exception {
    String vfCustomizationCategory = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
    logger.debug("VF Category is: {} ", vfCustomizationCategory);
    String vfCustomizationUUID = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
    logger.debug("VFCustomizationUUID= {}", vfCustomizationUUID);
    IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
    // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
    // comparing their VF Modules UUID's
    logger.debug("Checking if Notification VF ResourceCustomizationUUID: {} matches Tosca VF Customization UUID: {}", vfNotificationResource.getResourceCustomizationUUID(), vfCustomizationUUID);
    if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
        logger.debug("vfCustomizationUUID: {}  matches vfNotificationResource CustomizationUUID ", vfCustomizationUUID);
        VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service);
        if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
            Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>();
            Set<VnfcCustomization> existingVnfcSet = new HashSet<>();
            List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom = new ArrayList<>();
            for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
                logger.debug("vfModuleStructure: {}", vfModuleStructure);
                List<IEntityDetails> vfModuleEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.groups.VfModule"), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).customizationUUID(vfCustomizationUUID), false);
                IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
                logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
                Optional<IEntityDetails> matchingObject = vfModuleEntityList.stream().peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"))).filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())).findFirst();
                if (matchingObject.isPresent()) {
                    VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet, existingCvnfcConfigurationCustom);
                    vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
                } else
                    throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
            }
        }
        // Check for VNFC Instance Group info and add it if there is
        List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
        Set<VnfcCustomization> existingVnfcGroupSet = new HashSet<>();
        for (IEntityDetails groupEntity : vfcEntityList) {
            VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(groupEntity, vfEntityDetails, vnfResource, toscaResourceStruct, existingVnfcGroupSet);
            vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
        }
        List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList);
        if (!CollectionUtils.isEmpty(seqResult)) {
            String resultStr = seqResult.stream().collect(Collectors.joining(","));
            vnfResource.setVnfcInstanceGroupOrder(resultStr);
            logger.debug("vnfcGroupOrder result for service uuid {}: {}", service.getModelUUID(), resultStr);
        }
        // add this vnfResource with existing vnfResource for this service
        addVnfCustomization(service, vnfResource);
    } else {
        logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + "Tosca VF Customization UUID: " + vfCustomizationUUID);
    }
}
Also used : NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) Property(org.onap.sdc.toscaparser.api.Property) VfModule(org.onap.so.db.catalog.beans.VfModule) PnfResourceRepository(org.onap.so.db.catalog.data.repository.PnfResourceRepository) Autowired(org.springframework.beans.factory.annotation.Autowired) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) EntityQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder) Matcher(java.util.regex.Matcher) VnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) Map(java.util.Map) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) ExternalServiceToInternalServiceRepository(org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) VnfcInstanceGroupCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) VfModuleArtifact(org.onap.so.asdc.installer.VfModuleArtifact) SdcTypes(org.onap.sdc.tosca.parser.enums.SdcTypes) HeatFiles(org.onap.so.db.catalog.beans.HeatFiles) HeatEnvironmentRepository(org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository) Set(java.util.Set) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ASDCConfiguration(org.onap.so.asdc.client.ASDCConfiguration) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) CollectionUtils(org.springframework.util.CollectionUtils) ConfigurationResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CollectionResourceRepository(org.onap.so.db.catalog.data.repository.CollectionResourceRepository) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) VFModuleCustomizationRepository(org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository) TopologyTemplateQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery.TopologyTemplateQueryBuilder) InstanceGroupType(org.onap.so.db.catalog.beans.InstanceGroupType) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) HeatFilesRepository(org.onap.so.db.catalog.data.repository.HeatFilesRepository) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) ErrorCode(org.onap.logging.filter.base.ErrorCode) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment) PnfResource(org.onap.so.db.catalog.beans.PnfResource) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) CapabilityAssignment(org.onap.sdc.toscaparser.api.CapabilityAssignment) Input(org.onap.sdc.toscaparser.api.parameters.Input) MessageEnum(org.onap.so.logger.MessageEnum) SubType(org.onap.so.db.catalog.beans.SubType) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) WatchdogServiceModVerIdLookupRepository(org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) YamlEditor(org.onap.so.asdc.util.YamlEditor) TempNetworkHeatTemplateRepository(org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository) Collectors(java.util.stream.Collectors) List(java.util.List) ServiceInfo(org.onap.so.db.catalog.beans.ServiceInfo) Optional(java.util.Optional) LoggingAnchor(org.onap.so.logger.LoggingAnchor) Pattern(java.util.regex.Pattern) BigDecimalVersion(org.onap.so.asdc.installer.BigDecimalVersion) WatchdogDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository) TempNetworkHeatTemplateLookup(org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup) ServiceArtifact(org.onap.so.db.catalog.beans.ServiceArtifact) WatchdogServiceModVerIdLookup(org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup) HashMap(java.util.HashMap) CvnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository) ServiceProxyResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) ConfigurationResourceRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository) HashSet(java.util.HashSet) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) PnfCustomizationRepository(org.onap.so.db.catalog.data.repository.PnfCustomizationRepository) CollectionResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository) DistributionStatusEnum(org.onap.sdc.utils.DistributionStatusEnum) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) Logger(org.slf4j.Logger) EntityTemplateType(org.onap.sdc.tosca.parser.enums.EntityTemplateType) IStatusData(org.onap.sdc.api.notification.IStatusData) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HeatTemplateRepository(org.onap.so.db.catalog.data.repository.HeatTemplateRepository) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) Component(org.springframework.stereotype.Component) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) SdcPropertyNames(org.onap.sdc.tosca.parser.impl.SdcPropertyNames) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) GetInput(org.onap.sdc.toscaparser.api.functions.GetInput) Collections(java.util.Collections) WorkflowResource(org.onap.so.asdc.installer.bpmn.WorkflowResource) Transactional(org.springframework.transaction.annotation.Transactional) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) ArrayList(java.util.ArrayList) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) HashSet(java.util.HashSet)

Example 20 with VnfResource

use of org.onap.so.db.catalog.beans.VnfResource 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());
    }
}
Also used : ArtifactInfoImpl(org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) ResourceInfoImpl(org.onap.so.asdc.client.test.emulators.ResourceInfoImpl) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) EntityNotFoundException(javax.persistence.EntityNotFoundException) EntityNotFoundException(javax.persistence.EntityNotFoundException) ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) VnfResource(org.onap.so.db.catalog.beans.VnfResource) NotificationDataImpl(org.onap.so.asdc.client.test.emulators.NotificationDataImpl) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test)

Aggregations

VnfResource (org.onap.so.db.catalog.beans.VnfResource)21 Test (org.junit.Test)10 VfModule (org.onap.so.db.catalog.beans.VfModule)9 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)9 ArrayList (java.util.ArrayList)8 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)8 HashMap (java.util.HashMap)5 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)5 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)5 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)5 CvnfcCustomization (org.onap.so.db.catalog.beans.CvnfcCustomization)4 HeatTemplateParam (org.onap.so.db.catalog.beans.HeatTemplateParam)4 VnfcCustomization (org.onap.so.db.catalog.beans.VnfcCustomization)4 Transactional (org.springframework.transaction.annotation.Transactional)4 JsonParseException (com.fasterxml.jackson.core.JsonParseException)3 VnfException (org.onap.so.adapters.vnf.exceptions.VnfException)3 CloudSite (org.onap.so.db.catalog.beans.CloudSite)3 HeatFiles (org.onap.so.db.catalog.beans.HeatFiles)3 MavenLikeVersioning (org.onap.so.db.catalog.utils.MavenLikeVersioning)3 MsoException (org.onap.so.openstack.exceptions.MsoException)3