CollectionEditorSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, CollectionViewImpl, CollectionEditorDOMElement> { @Override public void registerHandlers(final CollectionViewImpl widget, final CollectionEditorDOMElement widgetDomElement) { widget.addCloseCompositeEventHandler(event -> commonCloseHandling(widgetDomElement)); widget.addSaveEditorEventHandler(event -> { flush(); gridLayer.batch(); gridPanel.setFocus(true); }); } CollectionEditorSingletonDOMElementFactory(final GridLienzoPanel gridPanel,
                                                      final GridLayer gridLayer,
                                                      final GridWidget gridWidget,
                                                      final ScenarioSimulationContext scenarioSimulationContext,
                                                      final ViewsProvider viewsProvider); @Override CollectionViewImpl createWidget(); @Override CollectionEditorDOMElement createDomElement(final GridLayer gridLayer,
                                                       final GridWidget gridWidget); @Override CollectionEditorDOMElement createDomElementInternal(final CollectionViewImpl collectionEditorView,
                                                               final GridLayer gridLayer,
                                                               final GridWidget gridWidget); @Override void registerHandlers(final CollectionViewImpl widget, final CollectionEditorDOMElement widgetDomElement);  }
@Test public void registerHandlers() { CollectionEditorDOMElement collectionEditorDOMElementMock = mock(CollectionEditorDOMElement.class); collectionEditorSingletonDOMElementFactorySpy.registerHandlers(collectionEditorViewImpl, collectionEditorDOMElementMock); ArgumentCaptor<CloseCompositeEventHandler> closeHandler = ArgumentCaptor.forClass(CloseCompositeEventHandler.class); verify(collectionEditorViewImpl, times(1)).addCloseCompositeEventHandler(closeHandler.capture()); closeHandler.getValue().onEvent(mock(CloseCompositeEvent.class)); verify(collectionEditorSingletonDOMElementFactorySpy).destroyResources(); verify(scenarioGridLayerMock).batch(); verify(scenarioGridPanelMock).setFocus(eq(true)); verify(collectionEditorDOMElementMock).stopEditingMode(); reset(collectionEditorSingletonDOMElementFactorySpy); reset(scenarioGridLayerMock); reset(scenarioGridPanelMock); ArgumentCaptor<SaveEditorEventHandler> saveHandler = ArgumentCaptor.forClass(SaveEditorEventHandler.class); verify(collectionEditorViewImpl, times(1)).addSaveEditorEventHandler(saveHandler.capture()); saveHandler.getValue().onEvent(mock(SaveEditorEvent.class)); verify(collectionEditorSingletonDOMElementFactorySpy).flush(); verify(scenarioGridLayerMock).batch(); verify(scenarioGridPanelMock).setFocus(eq(true)); }