/** * Run the following test case. * * <ol> * <li>Attempt to log-off * <li>Have the log-off succeed * <li>Make sure the onSuccess handler is called * <li>Make sure the onLogout handler is called * </ol> */ @Test public void testLogoffAsync_success() { Object model = new Object(); when(mockAsyncQuery.getModel()).thenReturn(model); DbUser testUser = new DbUser(); testUser.setLoginName("testUser"); // $NON-NLS-1$ frontend.logoffAsync(testUser, mockAsyncQuery); verify(mockService).logOff(eq(testUser), callbackAction.capture()); VdcReturnValueBase returnValue = new VdcReturnValueBase(); callbackAction.getValue().onSuccess(returnValue); verify(mockAsyncCallback).onSuccess(model, returnValue); verify(mockLoginHandler).onLogout(); }
/** * Run the following test case. * * <ol> * <li>Attempt to log-off * <li>Have the log-off fail with a status code of 0, which is an ignored failure * <li>Check to make sure the callback is not called * <li>Check to make sure the events handler is never called * <li>Make sure the onSuccess handler is never called * </ol> */ @Test public void testLogoffAsync_ignored_failure() { Object model = new Object(); when(mockAsyncQuery.getModel()).thenReturn(model); DbUser testUser = new DbUser(); testUser.setLoginName("testUser"); // $NON-NLS-1$ frontend.logoffAsync(testUser, mockAsyncQuery); verify(mockService).logOff(eq(testUser), callbackAction.capture()); StatusCodeException exception = new StatusCodeException(0, "0 status code"); // $NON-NLS-1$ callbackAction.getValue().onFailure(exception); verify(mockFrontendFailureEvent, never()).raise(eq(Frontend.class), (EventArgs) any()); verify(mockEventsHandler, never()).runQueryFailed(null); verify(mockAsyncCallback, never()).onSuccess(model, null); }
@Override protected void addGroupsToModel(VdcQueryReturnValue returnValue, Set<String> excludeUsers) { Iterable<DbGroup> filteredGroups = Linq.where( (ArrayList<DbGroup>) returnValue.getReturnValue(), new Linq.DbGroupPredicate(getTargetDbGroup())); for (DbGroup group : filteredGroups) { if (!excludeUsers.contains(group.getId().toString())) { DbUser dbUser = new DbUser(); dbUser.setExternalId(group.getExternalId()); dbUser.setFirstName(group.getName()); dbUser.setLastName(""); // $NON-NLS-1$ dbUser.setLoginName(""); // $NON-NLS-1$ dbUser.setDomain(group.getDomain()); dbUser.setNamespace(group.getNamespace()); EntityModel entity = new EntityModel(); entity.setEntity(dbUser); getgroups().add(entity); } } }
private DbUser getTargetDbUser() { DbUser dbUser = new DbUser(); dbUser.setLoginName(getSearchString()); dbUser.setDomain((getProfile().getSelectedItem()).getAuthz()); return dbUser; }