UserCreationWorkflow extends BaseUserEditorWorkflow { void onCreateEntityClick() { final String identifier = createEntity.getEntityIdentifier(); if (identifier != null) { checkCreate(identifier, new CheckCreateCallback() { @Override public void valid() { createEntity.clear(); UserCreationWorkflow.this.user = userEditorDriver.createNewUser(identifier); doEdit(); } @Override public void invalid(final SecurityManagementException exception) { showError(exception); createEntity.setErrorState(); } @Override public void error(final Throwable error) { showError(error); } }); } } @Inject  UserCreationWorkflow(final ClientUserSystemManager userSystemManager,
                                final Event<OnErrorEvent> errorEvent,
                                final Event<NotificationEvent> workbenchNotification,
                                final Event<DeleteUserEvent> deleteUserEvent,
                                final Event<SaveUserEvent> saveUserEvent,
                                final Event<CreateUserEvent> createUserEvent,
                                final ConfirmBox confirmBox,
                                final CreateEntity createEntity,
                                final UserEditor userEditor,
                                final UserEditorDriver userEditorDriver,
                                final ChangePassword changePassword,
                                final LoadingBox loadingBox,
                                final EntityWorkflowView view); @PostConstruct void init(); void create(); @Override void clear();  }
@Test public void testOnCreateEntityAlreadyExisting() { when(userManagerService.get(anyString())).thenReturn(user); when(createEntity.getEntityIdentifier()).thenReturn("user1"); tested.onCreateEntityClick(); verify(loadingBox, times(1)).show(); verify(loadingBox, times(1)).hide(); verify(createEntity, times(1)).setErrorState(); }