/** * Loads the group management provider's settings into cache. * @param callback Load finished callback. */ private void loadGroupSettings(final Command callback, final ErrorCallback<Message> errorCallback) { if (null == groupManagerSettings) { groupsManagerService.call(new RemoteCallback<GroupManagerSettings>() { @Override public void callback(final GroupManagerSettings groupManagerSettings) { ClientUserSystemManager.this.groupManagerSettings = groupManagerSettings; if (null != callback) { callback.execute(); } } }, errorCallback).getSettings(); } else { callback.execute(); } }
@Test public void testOnDeleteGroup() throws Exception { final DeleteGroupEvent deleteGroupEvent = mock(DeleteGroupEvent.class); presenter.context = mock(ExplorerViewContext.class); presenter.onGroupDeleted(deleteGroupEvent); verify(groupsManagerService, times(1)).search(any(AbstractEntityManager.SearchRequest.class)); }
@Test public void testCheckCreateExisting() { when(groupsManagerService.get(anyString())).thenReturn(group); when(createEntity.getEntityIdentifier()).thenReturn("group1"); tested.checkCreate(); verify(loadingBox, times(1)).show(); verify(loadingBox, times(1)).hide(); verify(errorEvent, times(1)).fire(any(OnErrorEvent.class)); verify(createEntity, times(1)).setErrorState(); }
@Before public void setup() { super.setup(); when(group.getName()).thenReturn("group1"); when(view.setWidget(any(IsWidget.class))).thenReturn(view); when(view.clearNotifications()).thenReturn(view); when(view.setCallback(any(EntityWorkflowView.Callback.class))).thenReturn(view); when(view.setCancelButtonVisible(anyBoolean())).thenReturn(view); when(view.setSaveButtonEnabled(anyBoolean())).thenReturn(view); when(view.setSaveButtonVisible(anyBoolean())).thenReturn(view); when(view.setSaveButtonText(anyString())).thenReturn(view); when(view.showNotification(anyString())).thenReturn(view); when(groupsManagerService.get(anyString())).thenReturn(group); GroupManagerSettings settings = mock(GroupManagerSettings.class); when(settings.allowEmpty()).thenReturn(true); when(userSystemManager.getGroupManagerSettings()).thenReturn(settings); tested = new GroupCreationWorkflow(userSystemManager, errorEvent, confirmBox, loadingBox, workbenchNotification, createEntity, groupUsersAssignment, onCreateGroupEvent, view); }
/** * Loads the group management provider's settings into cache. * @param callback Load finished callback. */ private void loadGroupSettings(final Command callback, final ErrorCallback<Message> errorCallback) { if (null == groupManagerSettings) { groupsManagerService.call(new RemoteCallback<GroupManagerSettings>() { @Override public void callback(final GroupManagerSettings groupManagerSettings) { ClientUserSystemManager.this.groupManagerSettings = groupManagerSettings; if (null != callback) { callback.execute(); } } }, errorCallback).getSettings(); } else { callback.execute(); } }
@Test public void testOnCreateGroup() throws Exception { final CreateGroupEvent createGroupEvent = mock(CreateGroupEvent.class); presenter.context = mock(ExplorerViewContext.class); presenter.onGroupCreated(createGroupEvent); verify(groupsManagerService, times(1)).search(any(AbstractEntityManager.SearchRequest.class)); }
when(view.setSaveButtonText(anyString())).thenReturn(view); when(view.showNotification(anyString())).thenReturn(view); when(groupsManagerService.get(anyString())).thenReturn(group);
@Test public void testInitCache() { tested.initCache(); verify(userManagerService, times(1)).getSettings(); verify(groupsManagerService, times(1)).getSettings(); }
@Test public void testOnAddUsersToGroupEvent() throws Exception { final AddUsersToGroupEvent addUsersToGroupEvent = mock(AddUsersToGroupEvent.class); presenter.context = mock(ExplorerViewContext.class); presenter.onAddUsersToGroup(addUsersToGroupEvent); verify(groupsManagerService, times(1)).search(any(AbstractEntityManager.SearchRequest.class)); }
@Test public void testInitCache() { tested.initCache(); verify(userManagerService, times(1)).getSettings(); verify(groupsManagerService, times(1)).getSettings(); }
@Test public void testOnDeleteGroupButNoContext() throws Exception { final DeleteGroupEvent deleteGroupEvent = mock(DeleteGroupEvent.class); presenter.context = null; presenter.onGroupDeleted(deleteGroupEvent); verify(groupsManagerService, never()).search(any(AbstractEntityManager.SearchRequest.class)); }
@Before public void setup() { MockitoAnnotations.initMocks(this); final UserManagerSettings userManagerSettings = getUserSettings(); when(userManagerService.getSettings()).thenReturn(userManagerSettings); final GroupManagerSettings groupManagerSettings = getGroupSettings(); when(groupsManagerService.getSettings()).thenReturn(groupManagerSettings); usersManagerServiceCaller = new CallerMock<UserManagerService>(userManagerService); groupsManagerServiceCaller = new CallerMock<GroupManagerService>(groupsManagerService); rolesManagerServiceCaller = new CallerMock<RoleManagerService>(rolesManagerService); tested = spy(new ClientUserSystemManager(usersManagerServiceCaller, groupsManagerServiceCaller, rolesManagerServiceCaller, new ClientSecurityExceptionMessageResolver(), errorPopupPresenter)); }
@Test public void testOnCreateGroupButNoContext() throws Exception { final CreateGroupEvent createGroupEvent = mock(CreateGroupEvent.class); presenter.context = null; presenter.onGroupCreated(createGroupEvent); verify(groupsManagerService, never()).search(any(AbstractEntityManager.SearchRequest.class)); }
@Before public void setup() { MockitoAnnotations.initMocks(this); final UserManagerSettings userManagerSettings = getUserSettings(); when(userManagerService.getSettings()).thenReturn(userManagerSettings); final GroupManagerSettings groupManagerSettings = getGroupSettings(); when(groupsManagerService.getSettings()).thenReturn(groupManagerSettings); usersManagerServiceCaller = new CallerMock<UserManagerService>(userManagerService); groupsManagerServiceCaller = new CallerMock<GroupManagerService>(groupsManagerService); rolesManagerServiceCaller = new CallerMock<RoleManagerService>(rolesManagerService); tested = spy(new ClientUserSystemManager(usersManagerServiceCaller, groupsManagerServiceCaller, rolesManagerServiceCaller, new ClientSecurityExceptionMessageResolver(), errorPopupPresenter)); }
@Test public void testOnAddUsersToGroupEventButNoContext() throws Exception { final AddUsersToGroupEvent addUsersToGroupEvent = mock(AddUsersToGroupEvent.class); presenter.context = null; presenter.onAddUsersToGroup(addUsersToGroupEvent); verify(groupsManagerService, never()).search(any(AbstractEntityManager.SearchRequest.class)); }
private void testShow(final ExplorerViewContext context, final AbstractEntityManager.SearchResponse<Group> response) { when(groupsManagerService.search(any(AbstractEntityManager.SearchRequest.class))).thenAnswer(new Answer<AbstractEntityManager.SearchResponse<Group>>() { @Override public AbstractEntityManager.SearchResponse<Group> answer(InvocationOnMock invocationOnMock) throws Throwable {