Search in sources :

Example 36 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.

the class MetadataServiceTest method testUpdateTaskDefNameNull.

@Test(expected = ConstraintViolationException.class)
public void testUpdateTaskDefNameNull() {
    try {
        TaskDef taskDef = new TaskDef();
        metadataService.updateTaskDef(taskDef);
    } catch (ConstraintViolationException ex) {
        assertEquals(2, ex.getConstraintViolations().size());
        Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations());
        assertTrue(messages.contains("TaskDef name cannot be null or empty"));
        assertTrue(messages.contains("ownerEmail cannot be empty"));
        throw ex;
    }
    fail("metadataService.updateTaskDef did not throw ConstraintViolationException !");
}
Also used : Set(java.util.Set) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 37 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.

the class MetadataServiceTest method testRegisterTaskDefNoResponseTimeout.

@Test(expected = ConstraintViolationException.class)
public void testRegisterTaskDefNoResponseTimeout() {
    try {
        TaskDef taskDef = new TaskDef();
        taskDef.setName("somename");
        taskDef.setOwnerEmail("sample@test.com");
        // wrong
        taskDef.setResponseTimeoutSeconds(0);
        metadataService.registerTaskDef(Collections.singletonList(taskDef));
    } catch (ConstraintViolationException ex) {
        assertEquals(1, ex.getConstraintViolations().size());
        Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations());
        assertTrue(messages.contains("TaskDef responseTimeoutSeconds: 0 should be minimum 1 second"));
        throw ex;
    }
    fail("metadataService.registerTaskDef did not throw ConstraintViolationException !");
}
Also used : Set(java.util.Set) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 38 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.

the class MetadataServiceTest method testUpdateTaskDefDaoException.

@Test(expected = ApplicationException.class)
public void testUpdateTaskDefDaoException() {
    TaskDef taskDef = new TaskDef();
    taskDef.setName("test");
    taskDef.setOwnerEmail("sample@test.com");
    when(metadataDAO.getTaskDef(any())).thenReturn(null);
    metadataService.updateTaskDef(taskDef);
}
Also used : TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) Test(org.junit.Test)

Example 39 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.

the class MetadataServiceTest method testUpdateTaskDefNotExisting.

@Test(expected = ApplicationException.class)
public void testUpdateTaskDefNotExisting() {
    TaskDef taskDef = new TaskDef();
    taskDef.setName("test");
    taskDef.setOwnerEmail("sample@test.com");
    when(metadataDAO.getTaskDef(any())).thenReturn(null);
    metadataService.updateTaskDef(taskDef);
}
Also used : TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) Test(org.junit.Test)

Example 40 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.

the class WorkflowDefConstraintTest method testWorkflowTaskName.

@Test
public void testWorkflowTaskName() {
    // name is null
    TaskDef taskDef = new TaskDef();
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();
    Set<ConstraintViolation<Object>> result = validator.validate(taskDef);
    assertEquals(2, result.size());
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ConstraintViolation(javax.validation.ConstraintViolation) Validator(javax.validation.Validator) Test(org.junit.Test)

Aggregations

TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)172 Test (org.junit.Test)128 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)121 Task (com.netflix.conductor.common.metadata.tasks.Task)77 Workflow (com.netflix.conductor.common.run.Workflow)76 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)73 HashMap (java.util.HashMap)56 ArrayList (java.util.ArrayList)32 ConstraintViolation (javax.validation.ConstraintViolation)31 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)30 UserTask (com.netflix.conductor.tests.utils.UserTask)28 LinkedList (java.util.LinkedList)28 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)27 List (java.util.List)22 Map (java.util.Map)19 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)18 Before (org.junit.Before)14 ExpectedException (org.junit.rules.ExpectedException)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)12 Collectors (java.util.stream.Collectors)11