use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class MetadataServiceTest method testRegisterWorkflowDefInvalidName.
@Test(expected = ConstraintViolationException.class)
public void testRegisterWorkflowDefInvalidName() {
try {
WorkflowDef workflowDef = new WorkflowDef();
// not allowed
workflowDef.setName("invalid:name");
workflowDef.setOwnerEmail("inavlid-email");
metadataService.registerWorkflowDef(workflowDef);
} catch (ConstraintViolationException ex) {
assertEquals(3, ex.getConstraintViolations().size());
Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations());
assertTrue(messages.contains("WorkflowTask list cannot be empty"));
assertTrue(messages.contains("Workflow name cannot contain the following set of characters: ':'"));
assertTrue(messages.contains("ownerEmail should be valid email address"));
throw ex;
}
fail("metadataService.registerWorkflowDef did not throw ConstraintViolationException !");
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class MetadataServiceTest method testUpdateWorkflowDefWithEmptyWorkflowDefName.
@Test(expected = ConstraintViolationException.class)
public void testUpdateWorkflowDefWithEmptyWorkflowDefName() {
try {
List<WorkflowDef> workflowDefList = new ArrayList<>();
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName(null);
workflowDef.setOwnerEmail(null);
workflowDefList.add(workflowDef);
metadataService.updateWorkflowDef(workflowDefList);
} catch (ConstraintViolationException ex) {
assertEquals(3, ex.getConstraintViolations().size());
Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations());
assertTrue(messages.contains("WorkflowDef name cannot be null or empty"));
assertTrue(messages.contains("WorkflowTask list cannot be empty"));
assertTrue(messages.contains("ownerEmail cannot be empty"));
throw ex;
}
fail("metadataService.updateWorkflowDef did not throw ConstraintViolationException !");
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class PostgresMetadataDAOTest method testDuplicateWorkflowDef.
@Test
public void testDuplicateWorkflowDef() throws Exception {
expectedException.expect(ApplicationException.class);
expectedException.expectMessage("Workflow with testDuplicate.1 already exists!");
expectedException.expect(hasProperty("code", is(CONFLICT)));
WorkflowDef def = new WorkflowDef();
def.setName("testDuplicate");
def.setVersion(1);
dao.createWorkflowDef(def);
dao.createWorkflowDef(def);
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class MySQLExecutionDAOTest method testPendingByCorrelationId.
@Test
public void testPendingByCorrelationId() {
WorkflowDef def = new WorkflowDef();
def.setName("pending_count_correlation_jtest");
Workflow workflow = createTestWorkflow();
workflow.setWorkflowDefinition(def);
generateWorkflows(workflow, 10);
List<Workflow> bycorrelationId = getExecutionDAO().getWorkflowsByCorrelationId("pending_count_correlation_jtest", "corr001", true);
assertNotNull(bycorrelationId);
assertEquals(10, bycorrelationId.size());
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class MySQLMetadataDAOTest method testWorkflowDefOperations.
@Test
public void testWorkflowDefOperations() throws Exception {
WorkflowDef def = new WorkflowDef();
def.setName("test");
def.setVersion(1);
def.setDescription("description");
def.setCreatedBy("unit_test");
def.setCreateTime(1L);
def.setOwnerApp("ownerApp");
def.setUpdatedBy("unit_test2");
def.setUpdateTime(2L);
dao.createWorkflowDef(def);
List<WorkflowDef> all = dao.getAllWorkflowDefs();
assertNotNull(all);
assertEquals(1, all.size());
assertEquals("test", all.get(0).getName());
assertEquals(1, all.get(0).getVersion());
WorkflowDef found = dao.getWorkflowDef("test", 1).get();
assertTrue(EqualsBuilder.reflectionEquals(def, found));
def.setVersion(3);
dao.createWorkflowDef(def);
all = dao.getAllWorkflowDefs();
assertNotNull(all);
assertEquals(2, all.size());
assertEquals("test", all.get(0).getName());
assertEquals(1, all.get(0).getVersion());
found = dao.getLatestWorkflowDef(def.getName()).get();
assertEquals(def.getName(), found.getName());
assertEquals(def.getVersion(), found.getVersion());
assertEquals(3, found.getVersion());
all = dao.getAllLatest();
assertNotNull(all);
assertEquals(1, all.size());
assertEquals("test", all.get(0).getName());
assertEquals(3, all.get(0).getVersion());
all = dao.getAllVersions(def.getName());
assertNotNull(all);
assertEquals(2, all.size());
assertEquals("test", all.get(0).getName());
assertEquals("test", all.get(1).getName());
assertEquals(1, all.get(0).getVersion());
assertEquals(3, all.get(1).getVersion());
def.setDescription("updated");
dao.updateWorkflowDef(def);
found = dao.getWorkflowDef(def.getName(), def.getVersion()).get();
assertEquals(def.getDescription(), found.getDescription());
List<String> allnames = dao.findAll();
assertNotNull(allnames);
assertEquals(1, allnames.size());
assertEquals(def.getName(), allnames.get(0));
def.setVersion(2);
dao.createWorkflowDef(def);
found = dao.getLatestWorkflowDef(def.getName()).get();
assertEquals(def.getName(), found.getName());
assertEquals(3, found.getVersion());
dao.removeWorkflowDef("test", 3);
Optional<WorkflowDef> deleted = dao.getWorkflowDef("test", 3);
assertFalse(deleted.isPresent());
found = dao.getLatestWorkflowDef(def.getName()).get();
assertEquals(def.getName(), found.getName());
assertEquals(2, found.getVersion());
dao.removeWorkflowDef("test", 1);
deleted = dao.getWorkflowDef("test", 1);
assertFalse(deleted.isPresent());
found = dao.getLatestWorkflowDef(def.getName()).get();
assertEquals(def.getName(), found.getName());
assertEquals(2, found.getVersion());
}
Aggregations