Search in sources :

Example 6 with Workflow

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

the class WorkflowResourceTest method installWorkflowResource_Test.

@Transactional
@Test
public void installWorkflowResource_Test() throws Exception {
    Workflow workflow = new Workflow();
    workflow.setArtifactChecksum("12345");
    workflow.setArtifactName("myTestWorkflow1");
    workflow.setArtifactUUID("a5c59864-8407-4175-8060-de8ff95eab41");
    workflow.setBody("my body");
    workflow.setDescription("testing workflow");
    workflow.setName("myTestWorkflow1");
    workflow.setResourceTarget("vnf");
    workflow.setSource("sdc");
    workflow.setTimeoutMinutes(5000);
    workflow.setOperationName("myTestWorkflow");
    workflow.setVersion(1.0);
    VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow();
    vnfResourceWorkflow.setVnfResourceModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
    vnfResourceWorkflow.setWorkflow(workflow);
    List<VnfResourceWorkflow> vnfResourceWorkflows = new ArrayList<VnfResourceWorkflow>();
    vnfResourceWorkflows.add(vnfResourceWorkflow);
    workflow.setVnfResourceWorkflow(vnfResourceWorkflows);
    WorkflowActivitySpecSequence wfss1 = new WorkflowActivitySpecSequence();
    wfss1.setActivitySpecId(1);
    wfss1.setWorkflow(workflow);
    wfss1.setSeqNo(1);
    List<WorkflowActivitySpecSequence> wfss = new ArrayList<WorkflowActivitySpecSequence>();
    wfss.add(wfss1);
    workflow.setWorkflowActivitySpecSequence(wfss);
    workflowRepo.save(workflow);
    assertNotNull(workflow);
}
Also used : VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) ArrayList(java.util.ArrayList) Workflow(org.onap.so.db.catalog.beans.Workflow) VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) WorkflowActivitySpecSequence(org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 7 with Workflow

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

the class ASDCRestInterfaceTest method testWorkflowDistribution.

@Test
@Transactional
public void testWorkflowDistribution() 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())));
    wireMockServer.stubFor(post(urlPathEqualTo("/sobpmnengine/deployment/create")).willReturn(aResponse().withStatus(200)));
    ObjectMapper mapper = new ObjectMapper();
    NotificationDataImpl request = mapper.readValue(new File("src/test/resources/resource-examples/WorkflowBpmn/workflow-distribution.json"), NotificationDataImpl.class);
    headers.add("resource-location", "src/test/resources/resource-examples/WorkflowBpmn/");
    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());
    Workflow actualResponse = workflowRepo.findByArtifactUUID("a90f8eaa-7c20-422f-8c81-aacbca6fb9e7");
    if (actualResponse == null)
        throw new Exception("No Workflow Written to database");
    String expectedBody = new String(Files.readAllBytes(Paths.get("src/test/resources/resource-examples/WorkflowBpmn/TestWF2-1_0.bpmn")));
    assertEquals(actualResponse.getArtifactChecksum(), "ZjUzNjg1NDMyMTc4MWJmZjFlNDcyOGQ0Zjc1YWQwYzQ\u003d");
    assertEquals(actualResponse.getArtifactName(), "TestWF2-1_0.bpmn");
    assertEquals(actualResponse.getDescription(), "Workflow Artifact Description");
    assertEquals(actualResponse.getBody(), expectedBody);
    Workflow shouldNotBeFound = workflowRepo.findByArtifactUUID("f27066a1-c3a7-4672-b02e-1251b74b7b71");
    assertNull(shouldNotBeFound);
}
Also used : NotificationDataImpl(org.onap.so.asdc.client.test.emulators.NotificationDataImpl) HttpEntity(org.springframework.http.HttpEntity) Workflow(org.onap.so.db.catalog.beans.Workflow) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 8 with Workflow

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

the class CatalogDbClientTest method getWorkflowByModelUUID_invalidUuid_nullOutput.

@Test
public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
    Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
    assertNull(workflow);
}
Also used : Workflow(org.onap.so.db.catalog.beans.Workflow) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Example 9 with Workflow

use of org.onap.so.db.catalog.beans.Workflow 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 10 with Workflow

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

the class ServiceLevelPreparationTest method validateWorkflowSetFromDb.

@Test
public void validateWorkflowSetFromDb() throws Exception {
    Workflow vnfWorkflow = new Workflow();
    vnfWorkflow.setName("VNFHealthCheck");
    vnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION);
    vnfWorkflow.setResourceTarget("vnf");
    workflowList.add(vnfWorkflow);
    // Mock db response with multiple worklfows mapped with same operation name
    when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList);
    serviceLevelPrepare.execute(execution);
    // Expect right workflow gets assigned from db based on the controller scope.
    assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE))).isEqualTo(PNF_HEALTH_CHECK_WORKFLOW);
}
Also used : Workflow(org.onap.so.db.catalog.beans.Workflow) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

Workflow (org.onap.so.db.catalog.beans.Workflow)14 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)4 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)3 Transactional (javax.transaction.Transactional)2 BaseTest (org.onap.so.asdc.BaseTest)2 VnfResourceWorkflow (org.onap.so.db.catalog.beans.VnfResourceWorkflow)2 WorkflowActivitySpecSequence (org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 Before (org.junit.Before)1 IArtifactInfo (org.onap.sdc.api.notification.IArtifactInfo)1 NotificationDataImpl (org.onap.so.asdc.client.test.emulators.NotificationDataImpl)1 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)1 BaseTest (org.onap.so.db.catalog.BaseTest)1 HttpEntity (org.springframework.http.HttpEntity)1 Client (uk.co.blackpepper.bowman.Client)1