Search in sources :

Example 6 with ExecutionService

use of com.netflix.conductor.service.ExecutionService in project conductor by Netflix.

the class TestSimpleEventProcessor method testExecuteNonRetriableApplicationException.

@Test
public void testExecuteNonRetriableApplicationException() {
    AtomicInteger executeInvoked = new AtomicInteger(0);
    doAnswer((Answer<Map<String, Object>>) invocation -> {
        executeInvoked.incrementAndGet();
        throw new ApplicationException(ApplicationException.Code.INVALID_INPUT, "some non-retriable error");
    }).when(actionProcessor).execute(any(), any(), any(), any());
    SimpleEventProcessor eventProcessor = new SimpleEventProcessor(executionService, metadataService, actionProcessor, eventQueues, jsonUtils, new TestConfiguration(), objectMapper);
    EventExecution eventExecution = new EventExecution("id", "messageId");
    eventExecution.setStatus(EventExecution.Status.IN_PROGRESS);
    eventExecution.setEvent("event");
    eventExecution.setName("handler");
    Action action = new Action();
    action.setAction(Type.start_workflow);
    eventExecution.setAction(Type.start_workflow);
    eventProcessor.execute(eventExecution, action, "payload");
    assertEquals(1, executeInvoked.get());
    assertEquals(EventExecution.Status.FAILED, eventExecution.getStatus());
    assertNotNull(eventExecution.getOutput().get("exception"));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MetadataService(com.netflix.conductor.service.MetadataService) TestConfiguration(com.netflix.conductor.core.execution.TestConfiguration) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Action(com.netflix.conductor.common.metadata.events.EventHandler.Action) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArgumentMatchers.anyMap(org.mockito.ArgumentMatchers.anyMap) HashMap(java.util.HashMap) Task(com.netflix.conductor.common.metadata.tasks.Task) StartWorkflow(com.netflix.conductor.common.metadata.events.EventHandler.StartWorkflow) Observable(rx.Observable) ParametersUtils(com.netflix.conductor.core.execution.ParametersUtils) JsonUtils(com.netflix.conductor.core.utils.JsonUtils) LinkedHashMap(java.util.LinkedHashMap) Answer(org.mockito.stubbing.Answer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Workflow(com.netflix.conductor.common.run.Workflow) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) WorkflowExecutor(com.netflix.conductor.core.execution.WorkflowExecutor) EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) Before(org.junit.Before) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) Message(com.netflix.conductor.core.events.queue.Message) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) Assert.assertNotNull(org.junit.Assert.assertNotNull) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Assert.assertTrue(org.junit.Assert.assertTrue) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) EventHandler(com.netflix.conductor.common.metadata.events.EventHandler) UUID(java.util.UUID) Type(com.netflix.conductor.common.metadata.events.EventHandler.Action.Type) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Mockito.never(org.mockito.Mockito.never) Assert.assertNull(org.junit.Assert.assertNull) Mockito.atMost(org.mockito.Mockito.atMost) TaskDetails(com.netflix.conductor.common.metadata.events.EventHandler.TaskDetails) ExecutionService(com.netflix.conductor.service.ExecutionService) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) ObservableQueue(com.netflix.conductor.core.events.queue.ObservableQueue) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) Action(com.netflix.conductor.common.metadata.events.EventHandler.Action) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) TestConfiguration(com.netflix.conductor.core.execution.TestConfiguration) ArgumentMatchers.anyMap(org.mockito.ArgumentMatchers.anyMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Message (com.netflix.conductor.core.events.queue.Message)6 ObservableQueue (com.netflix.conductor.core.events.queue.ObservableQueue)6 ParametersUtils (com.netflix.conductor.core.execution.ParametersUtils)6 WorkflowExecutor (com.netflix.conductor.core.execution.WorkflowExecutor)6 JsonUtils (com.netflix.conductor.core.utils.JsonUtils)6 ExecutionService (com.netflix.conductor.service.ExecutionService)6 MetadataService (com.netflix.conductor.service.MetadataService)6 HashMap (java.util.HashMap)6 LinkedHashMap (java.util.LinkedHashMap)6 Before (org.junit.Before)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)5 EventExecution (com.netflix.conductor.common.metadata.events.EventExecution)5 EventHandler (com.netflix.conductor.common.metadata.events.EventHandler)5 Action (com.netflix.conductor.common.metadata.events.EventHandler.Action)5 Type (com.netflix.conductor.common.metadata.events.EventHandler.Action.Type)5 StartWorkflow (com.netflix.conductor.common.metadata.events.EventHandler.StartWorkflow)5 TaskDetails (com.netflix.conductor.common.metadata.events.EventHandler.TaskDetails)5 Task (com.netflix.conductor.common.metadata.tasks.Task)5 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)5