Search in sources :

Example 11 with IArtifactInfo

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

the class WorkflowResource method installWorkflowResource.

protected void installWorkflowResource(WorkflowArtifact artifact, String vfResourceModelUuid) throws Exception {
    IArtifactInfo artifactInfo = artifact.getArtifactInfo();
    Workflow workflow = new Workflow();
    workflow.setArtifactChecksum(artifactInfo.getArtifactChecksum());
    workflow.setArtifactName(artifactInfo.getArtifactName());
    workflow.setArtifactUUID(artifactInfo.getArtifactUUID());
    workflow.setBody(artifact.getResult());
    workflow.setDescription(artifactInfo.getArtifactDescription());
    workflow.setName(getWorkflowNameFromArtifactName(artifactInfo.getArtifactName()));
    workflow.setResourceTarget(TARGET_RESOURCE_VNF);
    workflow.setSource(SOURCE_SDC);
    workflow.setTimeoutMinutes(artifactInfo.getArtifactTimeout());
    workflow.setOperationName(getWorkflowNameFromArtifactName(artifactInfo.getArtifactName()));
    workflow.setVersion(getWorkflowVersionFromArtifactName(artifactInfo.getArtifactName()));
    VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow();
    vnfResourceWorkflow.setVnfResourceModelUUID(vfResourceModelUuid);
    vnfResourceWorkflow.setWorkflow(workflow);
    List<VnfResourceWorkflow> vnfResourceWorkflows = new ArrayList<>();
    vnfResourceWorkflows.add(vnfResourceWorkflow);
    workflow.setVnfResourceWorkflow(vnfResourceWorkflows);
    List<String> activityNames = getActivityNameList(artifact.getResult());
    List<WorkflowActivitySpecSequence> wfss = getWorkflowActivitySpecSequence(activityNames, workflow);
    workflow.setWorkflowActivitySpecSequence(wfss);
    workflowRepo.save(workflow);
}
Also used : VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) ArrayList(java.util.ArrayList) VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) Workflow(org.onap.so.db.catalog.beans.Workflow) WorkflowActivitySpecSequence(org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence)

Example 12 with IArtifactInfo

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

the class ASDCElementInfoTest method createASDCElementInfoFromArtifact.

@Test
public void createASDCElementInfoFromArtifact() {
    for (String eVal : ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST) {
        String generatedArtifactName = eVal + " 1";
        UUID generatedUUIDForArtifact = UUID.randomUUID();
        IArtifactInfo artifactInfo = Mockito.mock(IArtifactInfo.class);
        Mockito.when(artifactInfo.getArtifactType()).thenReturn(eVal);
        Mockito.when(artifactInfo.getArtifactName()).thenReturn(generatedArtifactName);
        Mockito.when(artifactInfo.getArtifactUUID()).thenReturn(generatedUUIDForArtifact.toString());
        ASDCElementInfo elementInfoFromArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(artifactInfo);
        assertTrue(elementInfoFromArtifact.toString().contains(generatedArtifactName));
        assertTrue(elementInfoFromArtifact.toString().contains(generatedUUIDForArtifact.toString()));
        assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromArtifact.getType()));
        assertEquals(eVal, elementInfoFromArtifact.getType());
        assertFalse(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
        elementInfoFromArtifact.addElementInfo("MyInfo3", "someValue");
        assertTrue(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
    }
}
Also used : ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

IArtifactInfo (org.onap.sdc.api.notification.IArtifactInfo)12 ArtifactInstallerException (org.onap.so.asdc.client.exceptions.ArtifactInstallerException)5 IResourceInstance (org.onap.sdc.api.notification.IResourceInstance)4 ToscaResourceStructure (org.onap.so.asdc.installer.ToscaResourceStructure)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 ArrayList (java.util.ArrayList)3 IDistributionClientDownloadResult (org.onap.sdc.api.results.IDistributionClientDownloadResult)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Optional (java.util.Optional)2 Test (org.junit.Test)2 ErrorCode (org.onap.logging.filter.base.ErrorCode)2 ISdcCsarHelper (org.onap.sdc.tosca.parser.api.ISdcCsarHelper)2 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)2 DistributionStatusEnum (org.onap.sdc.utils.DistributionStatusEnum)2 ASDCControllerException (org.onap.so.asdc.client.exceptions.ASDCControllerException)2