@Test public void testOnSessionDiagramSavedEvent() { observer.onSessionDiagramSavedEvent(new SessionDiagramSavedEvent(session)); allSessionDiagramSavedHandlers.forEach(handler -> verify(handler).accepts(diagram)); acceptsDiagramSessionDiagramSavedHandlers.forEach(handler -> verify(handler).onSessionDiagramSaved(session)); dontAcceptsDiagramSessionDiagramSavedHandlers.forEach(handler -> verify(handler, never()).onSessionDiagramSaved(session)); }
void onSessionDiagramSavedEvent(@Observes final SessionDiagramSavedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramSavedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramSaved(event.getSession())); }
SessionEventObserver { void onSessionDiagramSavedEvent(@Observes final SessionDiagramSavedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramSavedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramSaved(event.getSession())); } }
SessionEventObserver { void onSessionDiagramSavedEvent(@Observes final SessionDiagramSavedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramSavedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramSaved(event.getSession())); } SessionEventObserver(); @Inject  SessionEventObserver(@Any final Instance<SessionDiagramOpenedHandler> sessionDiagramOpenedHandlersInstance,
                                @Any final Instance<SessionDiagramSavedHandler> sessionDiagramSavedHandlersInstance); }
SessionEventObserver { void onSessionDiagramSavedEvent(@Observes final SessionDiagramSavedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramSavedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramSaved(event.getSession())); } SessionEventObserver(); @Inject  SessionEventObserver(@Any final Instance<SessionDiagramOpenedHandler> sessionDiagramOpenedHandlersInstance,
                                @Any final Instance<SessionDiagramSavedHandler> sessionDiagramSavedHandlersInstance);  }
SessionEventObserver { void onSessionDiagramSavedEvent(@Observes final SessionDiagramSavedEvent event) { final Diagram currentDiagram = event.getSession().getCanvasHandler().getDiagram(); sessionDiagramSavedHandlers.stream() .filter(handler -> handler.accepts(currentDiagram)) .forEach(handler -> handler.onSessionDiagramSaved(event.getSession())); } SessionEventObserver(); @Inject  SessionEventObserver(@Any final Instance<SessionDiagramOpenedHandler> sessionDiagramOpenedHandlersInstance,
                                @Any final Instance<SessionDiagramSavedHandler> sessionDiagramSavedHandlersInstance);   }