@Test public void testOnViewClickedWhenGetPublicKeyIsFailure() { KeyItem keyItem = mock(KeyItem.class); MessageDialog messageDialog = mock(MessageDialog.class); when(dialogFactory.createMessageDialog(anyString(), anyString(), (ConfirmCallback)anyObject())).thenReturn(messageDialog); presenter.onViewClicked(keyItem); verify(service).getPublicKey((KeyItem)anyObject(), publicKeyCallbackCaptor.capture()); AsyncRequestCallback<PublicKey> publicKeyCallback = publicKeyCallbackCaptor.getValue(); GwtReflectionUtils.callOnFailure(publicKeyCallback, new Exception("")); verify(loader).hide(anyString()); verify(dialogFactory, never()).createMessageDialog(anyString(), anyString(), (ConfirmCallback)anyObject()); verify(messageDialog, never()).show(); verify(notificationManager).showError(anyString()); verify(eventBus).fireEvent(Matchers.<ExceptionThrownEvent>anyObject()); }
@Override public void onViewClicked(@Nonnull final KeyItem key) { service.getPublicKey(key, new AsyncRequestCallback<PublicKey>(dtoUnmarshallerFactory.newUnmarshaller(PublicKey.class)) { @Override public void onSuccess(PublicKey result) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); dialogFactory.createMessageDialog(constant.publicSshKeyField() + key.getHost(), result.getKey(), null).show(); } @Override public void onFailure(Throwable exception) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); notificationManager.showError(SafeHtmlUtils.fromString(exception.getMessage()).asString()); eventBus.fireEvent(new ExceptionThrownEvent(exception)); } }); }
SshKeyManagerPresenter extends AbstractPreferencePagePresenter implements SshKeyManagerView.ActionDelegate { @Override public void onViewClicked(@Nonnull final KeyItem key) { service.getPublicKey(key, new AsyncRequestCallback<PublicKey>(dtoUnmarshallerFactory.newUnmarshaller(PublicKey.class)) { @Override public void onSuccess(PublicKey result) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); dialogFactory.createMessageDialog(constant.publicSshKeyField() + key.getHost(), result.getKey(), null).show(); } @Override public void onFailure(Throwable exception) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); notificationManager.showError(SafeHtmlUtils.fromString(exception.getMessage()).asString()); eventBus.fireEvent(new ExceptionThrownEvent(exception)); } }); } }
SshKeyManagerPresenter extends AbstractPreferencePagePresenter implements SshKeyManagerView.ActionDelegate { @Override public void onViewClicked(@Nonnull final KeyItem key) { service.getPublicKey(key, new AsyncRequestCallback<PublicKey>(dtoUnmarshallerFactory.newUnmarshaller(PublicKey.class)) { @Override public void onSuccess(PublicKey result) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); dialogFactory.createMessageDialog(constant.publicSshKeyField() + key.getHost(), result.getKey(), null).show(); } @Override public void onFailure(Throwable exception) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); notificationManager.showError(SafeHtmlUtils.fromString(exception.getMessage()).asString()); eventBus.fireEvent(new ExceptionThrownEvent(exception)); } }); } @Inject  SshKeyManagerPresenter(SshKeyManagerView view,
                                  SshKeyService service,
                                  SshResources resources,
                                  AppContext appContext,
                                  SshLocalizationConstant constant,
                                  EventBus eventBus,
                                  AsyncRequestLoader loader,
                                  UploadSshKeyPresenter uploadSshKeyPresenter,
                                  NotificationManager notificationManager,
                                  DtoUnmarshallerFactory dtoUnmarshallerFactory,
                                  DialogFactory dialogFactory); }
SshKeyManagerPresenter extends AbstractPreferencePagePresenter implements SshKeyManagerView.ActionDelegate { @Override public void onViewClicked(@Nonnull final KeyItem key) { service.getPublicKey(key, new AsyncRequestCallback<PublicKey>(dtoUnmarshallerFactory.newUnmarshaller(PublicKey.class)) { @Override public void onSuccess(PublicKey result) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); dialogFactory.createMessageDialog(constant.publicSshKeyField() + key.getHost(), result.getKey(), null).show(); } @Override public void onFailure(Throwable exception) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); notificationManager.showError(SafeHtmlUtils.fromString(exception.getMessage()).asString()); eventBus.fireEvent(new ExceptionThrownEvent(exception)); } }); } @Inject  SshKeyManagerPresenter(SshKeyManagerView view,
                                  SshKeyService service,
                                  SshResources resources,
                                  AppContext appContext,
                                  SshLocalizationConstant constant,
                                  EventBus eventBus,
                                  AsyncRequestLoader loader,
                                  UploadSshKeyPresenter uploadSshKeyPresenter,
                                  NotificationManager notificationManager,
                                  DtoUnmarshallerFactory dtoUnmarshallerFactory,
                                  DialogFactory dialogFactory); @Override void onViewClicked(@Nonnull final KeyItem key); @Override void onDeleteClicked(@Nonnull final KeyItem key); @Override void onGenerateClicked(); @Override void onUploadClicked(); @Override void onGenerateGithubKeyClicked(); @Override boolean isDirty(); @Override void go(AcceptsOneWidget container); @Override void storeChanges(); @Override void revertChanges(); }
SshKeyManagerPresenter extends AbstractPreferencePagePresenter implements SshKeyManagerView.ActionDelegate { @Override public void onViewClicked(@Nonnull final KeyItem key) { service.getPublicKey(key, new AsyncRequestCallback<PublicKey>(dtoUnmarshallerFactory.newUnmarshaller(PublicKey.class)) { @Override public void onSuccess(PublicKey result) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); dialogFactory.createMessageDialog(constant.publicSshKeyField() + key.getHost(), result.getKey(), null).show(); } @Override public void onFailure(Throwable exception) { loader.hide(constant.loaderGetPublicSshKeyMessage(key.getHost())); notificationManager.showError(SafeHtmlUtils.fromString(exception.getMessage()).asString()); eventBus.fireEvent(new ExceptionThrownEvent(exception)); } }); } @Inject  SshKeyManagerPresenter(SshKeyManagerView view,
                                  SshKeyService service,
                                  SshResources resources,
                                  AppContext appContext,
                                  SshLocalizationConstant constant,
                                  EventBus eventBus,
                                  AsyncRequestLoader loader,
                                  UploadSshKeyPresenter uploadSshKeyPresenter,
                                  NotificationManager notificationManager,
                                  DtoUnmarshallerFactory dtoUnmarshallerFactory,
                                  DialogFactory dialogFactory); @Override void onViewClicked(@Nonnull final KeyItem key); @Override void onDeleteClicked(@Nonnull final KeyItem key); @Override void onGenerateClicked(); @Override void onUploadClicked(); @Override void onGenerateGithubKeyClicked(); @Override boolean isDirty(); @Override void go(AcceptsOneWidget container); @Override void storeChanges(); @Override void revertChanges(); static final String GITHUB_HOST; }