Delegatee { @NotNull String[] syncAllExternalUsers() { ResultMessages messages = new ResultMessages(); context.setForceGroupSync(true).setForceUserSync(true); try { List<SyncResult> results = new ArrayList<>(batchSize); Iterator<ExternalUser> it = idp.listUsers(); while (it.hasNext()) { ExternalUser user = it.next(); results = syncUser(user, results, messages); } commit(messages, results, NO_BATCH_SIZE); return messages.getMessages(); } catch (ExternalIdentityException e) { throw new SyncRuntimeException("Unable to retrieve external users", e); } } private  Delegatee(@NotNull SyncHandler handler, @NotNull ExternalIdentityProvider idp,
                      @NotNull ContentSession systemSession, @NotNull SecurityProvider securityProvider, int batchSize);   }
@Test public void testSyncAllExternalUsersSaveError() throws Exception { Root r = preventRootCommit(delegatee);; String[] result = delegatee.syncAllExternalUsers(); assertResultMessages(result, ImmutableMap.of( ID_TEST_USER, "ERR", TestIdentityProvider.ID_SECOND_USER, "ERR", TestIdentityProvider.ID_WILDCARD_USER, "ERR")); assertFalse(r.hasPendingChanges()); }
@Test(expected = SyncRuntimeException.class) public void testSyncAllExternalUsersThrowingIDP() { Delegatee dg = createDelegatee(new TestIdentityProvider("throwing") { @NotNull @Override public Iterator<ExternalUser> listUsers() throws ExternalIdentityException { throw new ExternalIdentityException(); } }, new DefaultSyncHandler(syncConfig)); dg.syncAllExternalUsers(); }