BaseUserEditorWorkflow implements IsWidget { protected void doDelete() { if (user != null && user.getIdentifier() != null) { confirmBox.show(UsersManagementWidgetsConstants.INSTANCE.confirmAction(), UsersManagementWidgetsConstants.INSTANCE.ensureRemoveUser(), new Command() { @Override public void execute() { final String id = user.getIdentifier(); showLoadingBox(); userSystemManager.users(new RemoteCallback<Void>() { @Override public void callback(Void o) { hideLoadingBox(); final String id = user.getIdentifier(); deleteUserEvent.fire(new DeleteUserEvent(id)); workbenchNotification.fire(new NotificationEvent(UsersManagementWidgetsConstants.INSTANCE.userRemoved(id), SUCCESS)); checkClear(); } }, errorCallback).delete(id); } }, new Command() { @Override public void execute() { } }); } } BaseUserEditorWorkflow(final ClientUserSystemManager userSystemManager,
                                  final Event<OnErrorEvent> errorEvent,
                                  final Event<NotificationEvent> workbenchNotification,
                                  final Event<DeleteUserEvent> deleteUserEvent,
                                  final Event<SaveUserEvent> saveUserEvent,
                                  final ConfirmBox confirmBox,
                                  final UserEditor userEditor,
                                  final UserEditorDriver userEditorDriver,
                                  final ChangePassword changePassword,
                                  final LoadingBox loadingBox,
                                  final EntityWorkflowView view); @Override Widget asWidget(); void clear(); UserEditor getUserEditor(); boolean isDirty(); public EntityWorkflowView view; }
@Test public void testDoDelete() { tested.user = user; doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocationOnMock) throws Throwable { final Command callback = (Command) invocationOnMock.getArguments()[2]; callback.execute(); return null; } }).when(confirmBox).show(anyString(), anyString(), any(), any()); tested.doDelete(); verify(confirmBox, times(1)).show(anyString(), anyString(), any(), any()); verify(userManagerService, times(1)).delete(anyString()); verify(loadingBox, times(1)).show(); verify(loadingBox, times(1)).hide(); verify(deleteUserEvent, times(1)).fire(any(DeleteUserEvent.class)); verify(workbenchNotification, times(1)).fire(any(NotificationEvent.class)); verify(view, times(0)).setCancelButtonVisible(anyBoolean()); verify(view, times(0)).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, times(0)).setSaveButtonText(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); verify(view, times(0)).setSaveButtonVisible(anyBoolean()); verify(view, times(1)).setSaveButtonEnabled(false); verify(view, times(0)).showNotification(anyString()); verify(view, times(2)).clearNotifications(); }