Search in sources :

Example 6 with ConductorClientException

use of com.netflix.conductor.client.exceptions.ConductorClientException in project conductor by Netflix.

the class AbstractHttpEndToEndTest method testCreateInvalidWorkflowDef.

@Test(expected = ConductorClientException.class)
public void testCreateInvalidWorkflowDef() {
    try {
        WorkflowDef workflowDef = new WorkflowDef();
        List<WorkflowDef> workflowDefList = new ArrayList<>();
        workflowDefList.add(workflowDef);
        metadataClient.registerWorkflowDef(workflowDef);
    } catch (ConductorClientException e) {
        assertEquals(3, e.getValidationErrors().size());
        assertEquals(400, e.getStatus());
        assertEquals("Validation failed, check below errors for detail.", e.getMessage());
        assertFalse(e.isRetryable());
        List<ValidationError> errors = e.getValidationErrors();
        List<String> errorMessages = errors.stream().map(ValidationError::getMessage).collect(Collectors.toList());
        assertTrue(errorMessages.contains("WorkflowDef name cannot be null or empty"));
        assertTrue(errorMessages.contains("WorkflowTask list cannot be empty"));
        assertTrue(errorMessages.contains("ownerEmail cannot be empty"));
        throw e;
    }
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ValidationError(com.netflix.conductor.common.validation.ValidationError) ConductorClientException(com.netflix.conductor.client.exceptions.ConductorClientException) Test(org.junit.Test)

Example 7 with ConductorClientException

use of com.netflix.conductor.client.exceptions.ConductorClientException in project conductor by Netflix.

the class AbstractHttpEndToEndTest method testUpdateWorkflowDef.

@Test(expected = ConductorClientException.class)
public void testUpdateWorkflowDef() {
    try {
        WorkflowDef workflowDef = new WorkflowDef();
        List<WorkflowDef> workflowDefList = new ArrayList<>();
        workflowDefList.add(workflowDef);
        metadataClient.updateWorkflowDefs(workflowDefList);
    } catch (ConductorClientException e) {
        assertEquals(400, e.getStatus());
        assertEquals("Validation failed, check below errors for detail.", e.getMessage());
        assertFalse(e.isRetryable());
        List<ValidationError> errors = e.getValidationErrors();
        List<String> errorMessages = errors.stream().map(ValidationError::getMessage).collect(Collectors.toList());
        assertEquals(3, errors.size());
        assertTrue(errorMessages.contains("WorkflowTask list cannot be empty"));
        assertTrue(errorMessages.contains("WorkflowDef name cannot be null or empty"));
        assertTrue(errorMessages.contains("ownerEmail cannot be empty"));
        throw e;
    }
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ValidationError(com.netflix.conductor.common.validation.ValidationError) ConductorClientException(com.netflix.conductor.client.exceptions.ConductorClientException) Test(org.junit.Test)

Example 8 with ConductorClientException

use of com.netflix.conductor.client.exceptions.ConductorClientException in project conductor by Netflix.

the class AbstractHttpEndToEndTest method testMetadataWorkflowDefinition.

@Test(expected = ConductorClientException.class)
public void testMetadataWorkflowDefinition() {
    String workflowDefName = "testWorkflowDefMetadata";
    WorkflowDef def = new WorkflowDef();
    def.setName(workflowDefName);
    def.setVersion(1);
    WorkflowTask t0 = new WorkflowTask();
    t0.setName("t0");
    t0.setWorkflowTaskType(TaskType.SIMPLE);
    t0.setTaskReferenceName("t0");
    WorkflowTask t1 = new WorkflowTask();
    t1.setName("t1");
    t1.setWorkflowTaskType(TaskType.SIMPLE);
    t1.setTaskReferenceName("t1");
    def.getTasks().add(t0);
    def.getTasks().add(t1);
    metadataClient.registerWorkflowDef(def);
    metadataClient.unregisterWorkflowDef(workflowDefName, 1);
    try {
        metadataClient.getWorkflowDef(workflowDefName, 1);
    } catch (ConductorClientException e) {
        int statusCode = e.getStatus();
        String errorMessage = e.getMessage();
        boolean retryable = e.isRetryable();
        assertEquals(404, statusCode);
        assertEquals("No such workflow found by name: testWorkflowDefMetadata, version: 1", errorMessage);
        assertFalse(retryable);
        throw e;
    }
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ConductorClientException(com.netflix.conductor.client.exceptions.ConductorClientException) Test(org.junit.Test)

Example 9 with ConductorClientException

use of com.netflix.conductor.client.exceptions.ConductorClientException in project conductor by Netflix.

the class AbstractHttpEndToEndTest method testUpdateWorkflow.

@Test(expected = ConductorClientException.class)
public void testUpdateWorkflow() {
    TaskDef taskDef = new TaskDef();
    taskDef.setName("taskUpdate");
    ArrayList<TaskDef> tasks = new ArrayList<>();
    tasks.add(taskDef);
    metadataClient.registerTaskDefs(tasks);
    WorkflowDef def = new WorkflowDef();
    def.setName("testWorkflowDel");
    def.setVersion(1);
    WorkflowTask workflowTask = new WorkflowTask();
    workflowTask.setName("taskUpdate");
    workflowTask.setTaskReferenceName("taskUpdate");
    List<WorkflowTask> workflowTaskList = new ArrayList<>();
    workflowTaskList.add(workflowTask);
    def.setTasks(workflowTaskList);
    List<WorkflowDef> workflowList = new ArrayList<>();
    workflowList.add(def);
    metadataClient.registerWorkflowDef(def);
    def.setVersion(2);
    metadataClient.updateWorkflowDefs(workflowList);
    WorkflowDef def1 = metadataClient.getWorkflowDef(def.getName(), 2);
    assertNotNull(def1);
    try {
        metadataClient.getTaskDef("test");
    } catch (ConductorClientException e) {
        int statuCode = e.getStatus();
        assertEquals(404, statuCode);
        assertEquals("No such taskType found by name: test", e.getMessage());
        assertFalse(e.isRetryable());
        throw e;
    }
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ConductorClientException(com.netflix.conductor.client.exceptions.ConductorClientException) Test(org.junit.Test)

Example 10 with ConductorClientException

use of com.netflix.conductor.client.exceptions.ConductorClientException in project conductor by Netflix.

the class AbstractHttpEndToEndTest method testInvalidResource.

@Test(expected = ConductorClientException.class)
public void testInvalidResource() {
    MetadataClient metadataClient = new MetadataClient();
    metadataClient.setRootURI(String.format("%sinvalid", apiRoot));
    WorkflowDef def = new WorkflowDef();
    def.setName("testWorkflowDel");
    def.setVersion(1);
    try {
        metadataClient.registerWorkflowDef(def);
    } catch (ConductorClientException e) {
        int statusCode = e.getStatus();
        boolean retryable = e.isRetryable();
        assertEquals(404, statusCode);
        assertFalse(retryable);
        throw e;
    }
}
Also used : MetadataClient(com.netflix.conductor.client.http.MetadataClient) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ConductorClientException(com.netflix.conductor.client.exceptions.ConductorClientException) Test(org.junit.Test)

Aggregations

ConductorClientException (com.netflix.conductor.client.exceptions.ConductorClientException)14 Test (org.junit.Test)8 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)5 ValidationError (com.netflix.conductor.common.validation.ValidationError)4 List (java.util.List)4 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 HttpURLConnection (java.net.HttpURLConnection)2 MalformedURLException (java.net.MalformedURLException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 MetadataClient (com.netflix.conductor.client.http.MetadataClient)1 TaskClient (com.netflix.conductor.client.http.TaskClient)1 Worker (com.netflix.conductor.client.worker.Worker)1 Task (com.netflix.conductor.common.metadata.tasks.Task)1 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)1 TaskResult (com.netflix.conductor.common.metadata.tasks.TaskResult)1