Search in sources :

Example 11 with Input

use of com.netflix.conductor.contribs.http.HttpTask.Input in project conductor by Netflix.

the class TestHttpTask method testOAuth.

@Test
public void testOAuth() {
    Task task = new Task();
    Input input = new Input();
    input.setUri("http://localhost:7009/oauth");
    input.setMethod("POST");
    input.setOauthConsumerKey("someKey");
    input.setOauthConsumerSecret("someSecret");
    task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
    httpTask.start(workflow, task, workflowExecutor);
    Map<String, Object> response = (Map<String, Object>) task.getOutputData().get("response");
    Map<String, String> body = (Map<String, String>) response.get("body");
    assertEquals("someKey", body.get("oauth_consumer_key"));
    assertTrue("Should have OAuth nonce", body.containsKey("oauth_nonce"));
    assertTrue("Should have OAuth signature", body.containsKey("oauth_signature"));
    assertTrue("Should have OAuth signature method", body.containsKey("oauth_signature_method"));
    assertTrue("Should have OAuth oauth_timestamp", body.containsKey("oauth_timestamp"));
    assertTrue("Should have OAuth oauth_version", body.containsKey("oauth_version"));
    assertEquals("Task output: " + task.getOutputData(), Status.COMPLETED, task.getStatus());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 12 with Input

use of com.netflix.conductor.contribs.http.HttpTask.Input in project conductor by Netflix.

the class TestHttpTask method testPostNoContent.

@Test
public void testPostNoContent() {
    Task task = new Task();
    Input input = new Input();
    input.setUri("http://localhost:7009/post2");
    Map<String, Object> body = new HashMap<>();
    body.put("input_key1", "value1");
    body.put("input_key2", 45.3d);
    input.setBody(body);
    input.setMethod("POST");
    task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
    httpTask.start(workflow, task, workflowExecutor);
    assertEquals(task.getReasonForIncompletion(), Task.Status.COMPLETED, task.getStatus());
    Map<String, Object> hr = (Map<String, Object>) task.getOutputData().get("response");
    Object response = hr.get("body");
    assertEquals(Task.Status.COMPLETED, task.getStatus());
    assertNull("response is: " + response, response);
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Task (com.netflix.conductor.common.metadata.tasks.Task)12 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)12 Input (com.netflix.conductor.contribs.http.HttpTask.Input)12 Test (org.junit.Test)12 HashMap (java.util.HashMap)8 Map (java.util.Map)7 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)1 Workflow (com.netflix.conductor.common.run.Workflow)1 Configuration (com.netflix.conductor.core.config.Configuration)1 DeciderService (com.netflix.conductor.core.execution.DeciderService)1 ParametersUtils (com.netflix.conductor.core.execution.ParametersUtils)1 TaskMapper (com.netflix.conductor.core.execution.mapper.TaskMapper)1 ExternalPayloadStorageUtils (com.netflix.conductor.core.utils.ExternalPayloadStorageUtils)1 MetadataDAO (com.netflix.conductor.dao.MetadataDAO)1 Instant (java.time.Instant)1