Search in sources :

Example 1 with INotificationData

use of org.onap.sdc.api.notification.INotificationData in project so by onap.

the class ASDCElementInfoTest method createASDCElementInfoFromVfModuleTest.

@Test
public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
    String resourceInstanceName = "Resource 1";
    UUID generatedUUID = UUID.randomUUID();
    INotificationData notificationData = Mockito.mock(INotificationData.class);
    IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
    Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
    Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
    VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
    // Create module structure now
    String vfModuleModelName = "Module Model XYZ";
    UUID generatedUUIDForModule = UUID.randomUUID();
    IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.class);
    Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);
    Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());
    Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String>emptyList());
    VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);
    ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
    assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));
    assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));
    assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromVfModule.getType()));
    assertEquals(ASDCConfiguration.VF_MODULES_METADATA, elementInfoFromVfModule.getType());
    assertFalse(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
    elementInfoFromVfModule.addElementInfo("MyInfo2", "someValue");
    assertTrue(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
}
Also used : VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) INotificationData(org.onap.sdc.api.notification.INotificationData) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) UUID(java.util.UUID) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) Test(org.junit.Test)

Example 2 with INotificationData

use of org.onap.sdc.api.notification.INotificationData in project so by onap.

the class ASDCNotificationLoggingTest method dumpASDCNotificationTest.

@Test
public void dumpASDCNotificationTest() throws Exception {
    INotificationData asdcNotification = iNotificationDataObject();
    String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
    assertTrue(!result.equalsIgnoreCase("NULL"));
}
Also used : INotificationData(org.onap.sdc.api.notification.INotificationData) Test(org.junit.Test)

Example 3 with INotificationData

use of org.onap.sdc.api.notification.INotificationData in project so by onap.

the class ToscaResourceInstallerTest method createServiceTest.

@Test
public void createServiceTest() {
    ToscaResourceStructure toscaResourceStructure = mock(ToscaResourceStructure.class);
    ResourceStructure resourceStructure = mock(ResourceStructure.class);
    Metadata metadata = mock(Metadata.class);
    INotificationData notification = mock(INotificationData.class);
    doReturn("e2899e5c-ae35-434c-bada-0fabb7c1b44d").when(toscaResourceStructure).getServiceVersion();
    doReturn(metadata).when(toscaResourceStructure).getServiceMetadata();
    doReturn("production").when(notification).getWorkloadContext();
    doReturn(notification).when(resourceStructure).getNotification();
    String serviceType = "test-type";
    String serviceRole = "test-role";
    String category = "Network L4+";
    String description = "Customer Orderable service description";
    String name = "Customer Orderable Service";
    String uuid = "72db5868-4575-4804-b546-0b0d3c3b5ac6";
    String invariantUUID = "6f30bbe3-4590-4185-a7e0-4f9610926c6f";
    String namingPolicy = "naming Policy";
    String ecompGeneratedNaming = "true";
    String environmentContext = "General_Revenue-Bearing";
    doReturn(serviceType).when(metadata).getValue("serviceType");
    doReturn(serviceRole).when(metadata).getValue("serviceRole");
    doReturn(category).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
    doReturn(description).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
    doReturn(name).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
    doReturn(uuid).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
    doReturn(environmentContext).when(metadata).getValue(metadata.getValue("environmentContext"));
    doReturn(invariantUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
    doReturn(namingPolicy).when(metadata).getValue("namingPolicy");
    doReturn(ecompGeneratedNaming).when(metadata).getValue("ecompGeneratedNaming");
    ISdcCsarHelper iSdcCsarHelper = mock(ISdcCsarHelper.class);
    List<Input> serviceInputs = new ArrayList<Input>();
    LinkedHashMap<String, Object> value = new LinkedHashMap<String, Object>();
    value.put("controller_actor", "SO-REF-DATA");
    value.put("type", "string");
    Input input = new Input("controller_actor", value, null);
    serviceInputs.add(0, input);
    value = new LinkedHashMap<String, Object>();
    value.put("cds_model_version", "v1.4.0");
    value.put("type", "string");
    input = new Input("cds_model_version", value, null);
    serviceInputs.add(1, input);
    value = new LinkedHashMap<String, Object>();
    value.put("cds_model_name", "Blueprint140");
    value.put("type", "string");
    input = new Input("cds_model_name", value, null);
    serviceInputs.add(2, input);
    value = new LinkedHashMap<String, Object>();
    value.put("skip_post_instantiation_configuration", "false");
    value.put("type", "boolean");
    input = new Input("skip_post_instantiation_configuration", value, null);
    serviceInputs.add(3, input);
    doReturn(iSdcCsarHelper).when(toscaResourceStructure).getSdcCsarHelper();
    doReturn(serviceInputs).when(iSdcCsarHelper).getServiceInputs();
    Service service = toscaInstaller.createService(toscaResourceStructure, resourceStructure);
    assertNotNull(service);
    verify(toscaResourceStructure, times(2)).getServiceVersion();
    assertNotNull(service.getNamingPolicy());
    assertEquals(serviceType, service.getServiceType());
    assertEquals(serviceRole, service.getServiceRole());
    assertEquals(category, service.getCategory());
    assertEquals(description, service.getDescription());
    assertEquals(uuid, service.getModelUUID());
    assertEquals(invariantUUID, service.getModelInvariantUUID());
    assertEquals(namingPolicy, service.getNamingPolicy());
    assertTrue(service.getOnapGeneratedNaming());
}
Also used : INotificationData(org.onap.sdc.api.notification.INotificationData) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ArrayList(java.util.ArrayList) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) LinkedHashMap(java.util.LinkedHashMap) Input(org.onap.sdc.toscaparser.api.parameters.Input) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test)

Example 4 with INotificationData

use of org.onap.sdc.api.notification.INotificationData in project so by onap.

the class ASDCController method processNsstNotification.

private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
    Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
    try {
        String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
        boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement")) && iNotif.getResources().isEmpty();
        if (isNeedInital) {
            String artifactContent = null;
            List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
            Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream().filter(e -> e.getArtifactType().equalsIgnoreCase("WORKFLOW")).findFirst();
            if (artifactOpt.isPresent()) {
                IArtifactInfo artifactInfo = artifactOpt.get();
                logger.debug("Ready to parse this serviceArtifactUUID:  " + artifactInfo.getArtifactUUID());
                String filePath = Paths.get(getMsoConfigPath(), "ASDC", artifactInfo.getArtifactVersion(), artifactInfo.getArtifactName()).normalize().toString();
                ZipParser zipParserInstance = ZipParser.getInstance();
                artifactContent = zipParserInstance.parseJsonForZip(filePath);
                logger.debug("serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
                ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
                resourceStructure.setResourceType(ResourceType.OTHER);
                toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure, artifactContent);
            } else {
                logger.debug("serviceArtifact is null");
                toscaInstaller.installNsstService(toscaResourceStructure, null, null);
            }
        }
    } catch (IOException e) {
        logger.error("serviceArtifact parse failure for service uuid:  " + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
    } catch (Exception e) {
        logger.error("error NSST process resource failure ", e);
    }
}
Also used : ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) ONAPLogConstants(org.onap.logging.ref.slf4j.ONAPLogConstants) IFinalDistrStatusMessage(org.onap.sdc.api.consumer.IFinalDistrStatusMessage) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) INotificationData(org.onap.sdc.api.notification.INotificationData) ASDCDownloadException(org.onap.so.asdc.client.exceptions.ASDCDownloadException) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ResourceType(org.onap.so.asdc.installer.ResourceType) ASDCNotificationLogging(org.onap.so.asdc.util.ASDCNotificationLogging) MessageEnum(org.onap.so.logger.MessageEnum) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) WatchdogDistribution(org.onap.so.asdc.tenantIsolation.WatchdogDistribution) IDistributionClientDownloadResult(org.onap.sdc.api.results.IDistributionClientDownloadResult) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) ASDCParametersException(org.onap.so.asdc.client.exceptions.ASDCParametersException) DistributionStatus(org.onap.so.asdc.tenantIsolation.DistributionStatus) StandardCharsets(java.nio.charset.StandardCharsets) IDistributionClient(org.onap.sdc.api.IDistributionClient) List(java.util.List) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) DistributionActionResultEnum(org.onap.sdc.utils.DistributionActionResultEnum) Optional(java.util.Optional) LoggingAnchor(org.onap.so.logger.LoggingAnchor) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WatchdogDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository) ZipParser(org.onap.so.asdc.util.ZipParser) MapperFeature(com.fasterxml.jackson.databind.MapperFeature) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) ErrorCode(org.onap.logging.filter.base.ErrorCode) IDistributionStatusMessage(org.onap.sdc.api.consumer.IDistributionStatusMessage) IDistributionClientResult(org.onap.sdc.api.results.IDistributionClientResult) DistributionStatusEnum(org.onap.sdc.utils.DistributionStatusEnum) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileOutputStream(java.io.FileOutputStream) IVfResourceInstaller(org.onap.so.asdc.installer.IVfResourceInstaller) Include(com.fasterxml.jackson.annotation.JsonInclude.Include) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) File(java.io.File) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) ToscaResourceInstaller(org.onap.so.asdc.installer.heat.ToscaResourceInstaller) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) Component(org.springframework.stereotype.Component) Paths(java.nio.file.Paths) MDC(org.slf4j.MDC) SdcPropertyNames(org.onap.sdc.tosca.parser.impl.SdcPropertyNames) DeployActivitySpecs(org.onap.so.asdc.activity.DeployActivitySpecs) DistributionClientFactory(org.onap.sdc.impl.DistributionClientFactory) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) IOException(java.io.IOException) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) ASDCDownloadException(org.onap.so.asdc.client.exceptions.ASDCDownloadException) ASDCParametersException(org.onap.so.asdc.client.exceptions.ASDCParametersException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) ZipParser(org.onap.so.asdc.util.ZipParser) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance)

Example 5 with INotificationData

use of org.onap.sdc.api.notification.INotificationData in project so by onap.

the class NotificationLogging method registerForLog.

private static void registerForLog(INotificationData objectToLog) {
    INotificationData proxy = (INotificationData) Proxy.newProxyInstance(INotificationData.class.getClassLoader(), new Class[] { INotificationData.class }, NotificationLogging.getHandler());
    objectMethodsToLog.put(proxy, new ArrayList<>());
}
Also used : INotificationData(org.onap.sdc.api.notification.INotificationData)

Aggregations

INotificationData (org.onap.sdc.api.notification.INotificationData)8 Test (org.junit.Test)6 VfResourceStructure (org.onap.so.asdc.installer.VfResourceStructure)4 IResourceInstance (org.onap.sdc.api.notification.IResourceInstance)3 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)2 ResourceStructure (org.onap.so.asdc.installer.ResourceStructure)2 ToscaResourceStructure (org.onap.so.asdc.installer.ToscaResourceStructure)2 Include (com.fasterxml.jackson.annotation.JsonInclude.Include)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 MapperFeature (com.fasterxml.jackson.databind.MapperFeature)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Paths (java.nio.file.Paths)1