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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations