SaveFilterPopoverView implements IsElement { @EventHandler("name") public void onKeyPressEvent(final KeyDownEvent e) { if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) { e.preventDefault(); onSave(null); } }  void setCancelCallback(final Command cancelCallback); void setSaveCallback(final ParameterizedCommand<String> saveCallback); @Override HTMLElement getElement(); @EventHandler("save") void onSave(@ForEvent("click") Event e); @EventHandler("name") void onKeyPressEvent(final KeyDownEvent e); void onOpen(); void onShow(); void setError(final String message); @EventHandler("cancel") void onCancel(@ForEvent("click") Event e);  }
@Test public void testOnKeyPressEvent() { final String value = "value"; filterName.value = value; final ParameterizedCommand<String> callback = mock(ParameterizedCommand.class); popoverView.setSaveCallback(callback); final KeyDownEvent event = mock(KeyDownEvent.class); when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_ENTER, KeyCodes.KEY_A); popoverView.onKeyPressEvent(event); popoverView.onKeyPressEvent(event); verify(callback).execute(value); }