Search in sources :

Example 76 with WorkflowDef

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 !");
}
Also used : Set(java.util.Set) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 77 with WorkflowDef

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 !");
}
Also used : Set(java.util.Set) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ArrayList(java.util.ArrayList) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 78 with WorkflowDef

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);
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) Test(org.junit.Test)

Example 79 with WorkflowDef

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());
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) Workflow(com.netflix.conductor.common.run.Workflow) ExecutionDAOTest(com.netflix.conductor.dao.ExecutionDAOTest) Test(org.junit.Test)

Example 80 with WorkflowDef

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());
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) Test(org.junit.Test)

Aggregations

WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)247 Test (org.junit.Test)185 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)173 Workflow (com.netflix.conductor.common.run.Workflow)128 HashMap (java.util.HashMap)123 Task (com.netflix.conductor.common.metadata.tasks.Task)100 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)71 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)49 ArrayList (java.util.ArrayList)43 LinkedList (java.util.LinkedList)37 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)35 List (java.util.List)33 UserTask (com.netflix.conductor.tests.utils.UserTask)28 Map (java.util.Map)25 SubWorkflowParams (com.netflix.conductor.common.metadata.workflow.SubWorkflowParams)20 ConstraintViolation (javax.validation.ConstraintViolation)14 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)13 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)13 ValidatorFactory (javax.validation.ValidatorFactory)13 DynamicForkJoinTaskList (com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTaskList)12