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;
}
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));
}
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));
}
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));
}
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());
}
Aggregations