Search in sources :

Example 1 with EventHandler

use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.

the class AbstractProtoMapper method fromProto.

public EventHandler fromProto(EventHandlerPb.EventHandler from) {
    EventHandler to = new EventHandler();
    to.setName(from.getName());
    to.setEvent(from.getEvent());
    to.setCondition(from.getCondition());
    to.setActions(from.getActionsList().stream().map(this::fromProto).collect(Collectors.toCollection(ArrayList::new)));
    to.setActive(from.getActive());
    return to;
}
Also used : ArrayList(java.util.ArrayList) EventHandler(com.netflix.conductor.common.metadata.events.EventHandler)

Example 2 with EventHandler

use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.

the class EventResourceTest method testUpdateEventHandler.

@Test
public void testUpdateEventHandler() {
    EventHandler eventHandler = new EventHandler();
    eventResource.updateEventHandler(eventHandler);
    verify(mockEventService, times(1)).updateEventHandler(any(EventHandler.class));
}
Also used : EventHandler(com.netflix.conductor.common.metadata.events.EventHandler) Test(org.junit.Test)

Example 3 with EventHandler

use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.

the class EventResourceTest method testAddEventHandler.

@Test
public void testAddEventHandler() {
    EventHandler eventHandler = new EventHandler();
    eventResource.addEventHandler(eventHandler);
    verify(mockEventService, times(1)).addEventHandler(any(EventHandler.class));
}
Also used : EventHandler(com.netflix.conductor.common.metadata.events.EventHandler) Test(org.junit.Test)

Example 4 with EventHandler

use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.

the class EventResourceTest method testGetEventHandlersForEvent.

@Test
public void testGetEventHandlersForEvent() {
    EventHandler eventHandler = new EventHandler();
    eventResource.addEventHandler(eventHandler);
    List<EventHandler> listOfEventHandler = new ArrayList<>();
    listOfEventHandler.add(eventHandler);
    when(mockEventService.getEventHandlersForEvent(anyString(), anyBoolean())).thenReturn(listOfEventHandler);
    assertEquals(listOfEventHandler, eventResource.getEventHandlersForEvent("testEvent", true));
}
Also used : ArrayList(java.util.ArrayList) EventHandler(com.netflix.conductor.common.metadata.events.EventHandler) Test(org.junit.Test)

Example 5 with EventHandler

use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.

the class CassandraDAOTest method testEventHandlerCRUD.

@Test
public void testEventHandlerCRUD() {
    String event = "event";
    String eventHandlerName1 = "event_handler1";
    String eventHandlerName2 = "event_handler2";
    EventHandler eventHandler = new EventHandler();
    eventHandler.setName(eventHandlerName1);
    eventHandler.setEvent(event);
    // create event handler
    eventHandlerDAO.addEventHandler(eventHandler);
    // fetch all event handlers for event
    List<EventHandler> handlers = eventHandlerDAO.getEventHandlersForEvent(event, false);
    assertNotNull(handlers);
    assertEquals(1, handlers.size());
    assertEquals(eventHandler.getName(), handlers.get(0).getName());
    assertEquals(eventHandler.getEvent(), handlers.get(0).getEvent());
    assertFalse(handlers.get(0).isActive());
    // add an active event handler for the same event
    EventHandler eventHandler1 = new EventHandler();
    eventHandler1.setName(eventHandlerName2);
    eventHandler1.setEvent(event);
    eventHandler1.setActive(true);
    eventHandlerDAO.addEventHandler(eventHandler1);
    // fetch all event handlers
    handlers = eventHandlerDAO.getAllEventHandlers();
    assertNotNull(handlers);
    assertEquals(2, handlers.size());
    // fetch all event handlers for event
    handlers = eventHandlerDAO.getEventHandlersForEvent(event, false);
    assertNotNull(handlers);
    assertEquals(2, handlers.size());
    // fetch only active handlers for event
    handlers = eventHandlerDAO.getEventHandlersForEvent(event, true);
    assertNotNull(handlers);
    assertEquals(1, handlers.size());
    assertEquals(eventHandler1.getName(), handlers.get(0).getName());
    assertEquals(eventHandler1.getEvent(), handlers.get(0).getEvent());
    assertTrue(handlers.get(0).isActive());
    // remove event handler
    eventHandlerDAO.removeEventHandler(eventHandlerName1);
    handlers = eventHandlerDAO.getAllEventHandlers();
    assertNotNull(handlers);
    assertEquals(1, handlers.size());
}
Also used : EventHandler(com.netflix.conductor.common.metadata.events.EventHandler) Test(org.junit.Test)

Aggregations

EventHandler (com.netflix.conductor.common.metadata.events.EventHandler)26 Test (org.junit.Test)14 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)13 Action (com.netflix.conductor.common.metadata.events.EventHandler.Action)6 ArrayList (java.util.ArrayList)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 TaskDetails (com.netflix.conductor.common.metadata.events.EventHandler.TaskDetails)4 TestConfiguration (com.netflix.conductor.core.execution.TestConfiguration)4 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 TimeUnit (java.util.concurrent.TimeUnit)4 EventExecution (com.netflix.conductor.common.metadata.events.EventExecution)3 StartWorkflow (com.netflix.conductor.common.metadata.events.EventHandler.StartWorkflow)3 Message (com.netflix.conductor.core.events.queue.Message)3 ObservableQueue (com.netflix.conductor.core.events.queue.ObservableQueue)3 JsonUtils (com.netflix.conductor.core.utils.JsonUtils)3 ExecutionService (com.netflix.conductor.service.ExecutionService)3 MetadataService (com.netflix.conductor.service.MetadataService)3 LinkedList (java.util.LinkedList)3