@Test public void testOnSessionDiagramOpenedEvent() { observer.onSessionDiagramOpenedEvent(new SessionDiagramOpenedEvent(session)); allSessionDiagramOpenedHandlers.forEach(handler -> verify(handler).accepts(diagram)); acceptsDiagramSessionDiagramOpenedHandlers.forEach(handler -> verify(handler).onSessionDiagramOpened(session)); dontAcceptsDiagramSessionDiagramOpenedHandlers.forEach(handler -> verify(handler, never()).onSessionDiagramOpened(session)); }
void onSessionDiagramOpenedEvent(@Observes final SessionDiagramOpenedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramOpenedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramOpened(event.getSession())); }
SessionEventObserver { void onSessionDiagramOpenedEvent(@Observes final SessionDiagramOpenedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramOpenedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramOpened(event.getSession())); } }
SessionEventObserver { void onSessionDiagramOpenedEvent(@Observes final SessionDiagramOpenedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramOpenedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramOpened(event.getSession())); } SessionEventObserver(); @Inject  SessionEventObserver(@Any final Instance<SessionDiagramOpenedHandler> sessionDiagramOpenedHandlersInstance,
                                @Any final Instance<SessionDiagramSavedHandler> sessionDiagramSavedHandlersInstance); }
SessionEventObserver { void onSessionDiagramOpenedEvent(@Observes final SessionDiagramOpenedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramOpenedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramOpened(event.getSession())); } SessionEventObserver(); @Inject  SessionEventObserver(@Any final Instance<SessionDiagramOpenedHandler> sessionDiagramOpenedHandlersInstance,
                                @Any final Instance<SessionDiagramSavedHandler> sessionDiagramSavedHandlersInstance);  }
SessionEventObserver { void onSessionDiagramOpenedEvent(@Observes final SessionDiagramOpenedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramOpenedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramOpened(event.getSession())); } SessionEventObserver(); @Inject  SessionEventObserver(@Any final Instance<SessionDiagramOpenedHandler> sessionDiagramOpenedHandlersInstance,
                                @Any final Instance<SessionDiagramSavedHandler> sessionDiagramSavedHandlersInstance);   }