use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class MetadataResourceTest method testGetAllWorkflowDef.
@Test
public void testGetAllWorkflowDef() {
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName("test");
workflowDef.setVersion(1);
workflowDef.setDescription("test");
List<WorkflowDef> listOfWorkflowDef = new ArrayList<>();
listOfWorkflowDef.add(workflowDef);
when(mockMetadataService.getWorkflowDefs()).thenReturn(listOfWorkflowDef);
assertEquals(listOfWorkflowDef, metadataResource.getAll());
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class MetadataResourceTest method testCreateWorkflow.
@Test
public void testCreateWorkflow() {
WorkflowDef workflowDef = new WorkflowDef();
metadataResource.create(workflowDef);
verify(mockMetadataService, times(1)).registerWorkflowDef(any(WorkflowDef.class));
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class MetadataResourceTest method testGetWorkflowDef.
@Test
public void testGetWorkflowDef() {
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName("test");
workflowDef.setVersion(1);
workflowDef.setDescription("test");
when(mockMetadataService.getWorkflowDef(anyString(), any())).thenReturn(workflowDef);
assertEquals(workflowDef, metadataResource.get("test", 1));
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class CassandraDAOTest method testWorkflowDefCRUD.
@Test
public void testWorkflowDefCRUD() throws Exception {
String name = "workflow_def_1";
int version = 1;
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName(name);
workflowDef.setVersion(version);
workflowDef.setOwnerEmail("test@junit.com");
// create workflow definition explicitly in test
// since, embedded Cassandra server does not support LWT required for this API.
addWorkflowDefinition(workflowDef);
// fetch the workflow definition
Optional<WorkflowDef> defOptional = metadataDAO.getWorkflowDef(name, version);
assertTrue(defOptional.isPresent());
assertEquals(workflowDef, defOptional.get());
// register a higher version
int higherVersion = 2;
workflowDef.setVersion(higherVersion);
workflowDef.setDescription("higher version");
// register the higher version definition
addWorkflowDefinition(workflowDef);
// fetch the higher version
defOptional = metadataDAO.getWorkflowDef(name, higherVersion);
assertTrue(defOptional.isPresent());
assertEquals(workflowDef, defOptional.get());
// fetch latest version
defOptional = metadataDAO.getLatestWorkflowDef(name);
assertTrue(defOptional.isPresent());
assertEquals(workflowDef, defOptional.get());
// modify the definition
workflowDef.setOwnerEmail("junit@test.com");
metadataDAO.updateWorkflowDef(workflowDef);
// fetch the workflow definition
defOptional = metadataDAO.getWorkflowDef(name, higherVersion);
assertTrue(defOptional.isPresent());
assertEquals(workflowDef, defOptional.get());
// delete workflow def
metadataDAO.removeWorkflowDef(name, higherVersion);
defOptional = metadataDAO.getWorkflowDef(name, higherVersion);
assertFalse(defOptional.isPresent());
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class CassandraMetadataDAO method getWorkflowDef.
@Override
public Optional<WorkflowDef> getWorkflowDef(String name, int version) {
try {
recordCassandraDaoRequests("getWorkflowDef");
ResultSet resultSet = session.execute(selectWorkflowDefStatement.bind(name, version));
WorkflowDef workflowDef = Optional.ofNullable(resultSet.one()).map(row -> readValue(row.getString(WORKFLOW_DEFINITION_KEY), WorkflowDef.class)).orElse(null);
return Optional.ofNullable(workflowDef);
} catch (Exception e) {
Monitors.error(CLASS_NAME, "getTaskDef");
String errorMsg = String.format("Error fetching workflow def: %s/%d", name, version);
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
}
Aggregations