### Question:
TextAreaSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, TextArea, TextAreaDOMElement> { @Override protected KeyDownHandlerCommon destroyOrFlushKeyDownHandler() { return new KeyDownHandlerCommon(gridPanel, gridLayer, gridWidget, this, true, false, true); } TextAreaSingletonDOMElementFactory(final DMNGridPanel gridPanel,
                                              final GridLayer gridLayer,
                                              final GridWidget gridWidget,
                                              final SessionManager sessionManager,
                                              final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                              final Function<GridCellTuple, Command> hasNoValueCommand,
                                              final Function<GridCellValueTuple, Command> hasValueCommand); Function<GridCellTuple, Command> getHasNoValueCommand(); Function<GridCellValueTuple, Command> getHasValueCommand(); @Override TextArea createWidget();  }### Answer:
@Test public void testKeyDownHandlerCommon_KEY_TAB() { final TextAreaSingletonDOMElementFactory factory = spy(getFactoryForAttachDomElementTest()); final KeyDownHandlerCommon keyDownHandlerCommon = factory.destroyOrFlushKeyDownHandler(); when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_TAB); keyDownHandlerCommon.onKeyDown(event); verify(factory).flush(); }
@Test public void testKeyDownHandlerCommon_KEY_ENTER() { final TextAreaSingletonDOMElementFactory factory = spy(getFactoryForAttachDomElementTest()); final KeyDownHandlerCommon keyDownHandlerCommon = factory.destroyOrFlushKeyDownHandler(); when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_ENTER); keyDownHandlerCommon.onKeyDown(event); verify(factory, never()).flush(); }
@Test public void testKeyDownHandlerCommon_KEY_ESCAPE() { final TextAreaSingletonDOMElementFactory factory = spy(getFactoryForAttachDomElementTest()); final KeyDownHandlerCommon keyDownHandlerCommon = factory.destroyOrFlushKeyDownHandler(); when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_ESCAPE); keyDownHandlerCommon.onKeyDown(event); verify(factory, never()).flush(); }