Search in sources :

Example 21 with SystemPropertiesConfiguration

use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.

the class TestKafkaPublishTask method noSerializer_StringObject.

@Test
public void noSerializer_StringObject() {
    KafkaPublishTask kPublishTask = new KafkaPublishTask(new SystemPropertiesConfiguration(), new KafkaProducerManager(new SystemPropertiesConfiguration()), objectMapper);
    KafkaPublishTask.Input input = new KafkaPublishTask.Input();
    input.setKey("testStringKey");
    Assert.assertEquals(kPublishTask.getKey(input), "testStringKey");
}
Also used : SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) Test(org.junit.Test)

Example 22 with SystemPropertiesConfiguration

use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.

the class TestKafkaPublishTask method kafkaPublishExecutionException_Fail.

@Test
public void kafkaPublishExecutionException_Fail() throws ExecutionException, InterruptedException {
    Task task = getTask();
    KafkaProducerManager producerManager = Mockito.mock(KafkaProducerManager.class);
    KafkaPublishTask kPublishTask = new KafkaPublishTask(new SystemPropertiesConfiguration(), producerManager, objectMapper);
    Producer producer = Mockito.mock(Producer.class);
    Mockito.when(producerManager.getProducer(Mockito.any())).thenReturn(producer);
    Future publishingFuture = Mockito.mock(Future.class);
    Mockito.when(producer.send(Mockito.any())).thenReturn(publishingFuture);
    ExecutionException executionException = Mockito.mock(ExecutionException.class);
    Mockito.when(executionException.getMessage()).thenReturn("Execution exception");
    Mockito.when(publishingFuture.get()).thenThrow(executionException);
    kPublishTask.start(Mockito.mock(Workflow.class), task, Mockito.mock(WorkflowExecutor.class));
    Assert.assertEquals(Task.Status.FAILED, task.getStatus());
    Assert.assertEquals("Failed to invoke kafka task due to: Execution exception", task.getReasonForIncompletion());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) Producer(org.apache.kafka.clients.producer.Producer) Future(java.util.concurrent.Future) Workflow(com.netflix.conductor.common.run.Workflow) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) WorkflowExecutor(com.netflix.conductor.core.execution.WorkflowExecutor) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

SystemPropertiesConfiguration (com.netflix.conductor.core.config.SystemPropertiesConfiguration)22 Test (org.junit.Test)21 Configuration (com.netflix.conductor.core.config.Configuration)9 Task (com.netflix.conductor.common.metadata.tasks.Task)7 Workflow (com.netflix.conductor.common.run.Workflow)7 WorkflowExecutor (com.netflix.conductor.core.execution.WorkflowExecutor)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 Producer (org.apache.kafka.clients.producer.Producer)4 Future (java.util.concurrent.Future)3 Properties (java.util.Properties)2 ModulesProvider (com.netflix.conductor.bootstrap.ModulesProvider)1 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 IntegerSerializer (org.apache.kafka.common.serialization.IntegerSerializer)1 LongSerializer (org.apache.kafka.common.serialization.LongSerializer)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1