Delegatee { @NotNull String[] syncUsers(@NotNull String[] userIds, boolean purge) { context.setKeepMissing(!purge) .setForceGroupSync(true) .setForceUserSync(true); ResultMessages messages = new ResultMessages(); List<SyncResult> results = new ArrayList<>(batchSize); for (String userId : userIds) { results = syncUser(userId, false, results, messages); } commit(messages, results, NO_BATCH_SIZE); return messages.getMessages(); } private  Delegatee(@NotNull SyncHandler handler, @NotNull ExternalIdentityProvider idp,
                      @NotNull ContentSession systemSession, @NotNull SecurityProvider securityProvider, int batchSize);   }
@Test public void testSyncUsersBeforeSaveError() throws Exception { Root r = preventRootCommit(delegatee);; String[] result = delegatee.syncUsers(TEST_IDS, false); assertResultMessages(result, ImmutableMap.of( ID_TEST_USER, "nsa", TestIdentityProvider.ID_SECOND_USER, "nsa", TestIdentityProvider.ID_WILDCARD_USER, "nsa")); assertFalse(r.hasPendingChanges()); }
@Test public void testSyncUsersSaveError() throws Exception { sync(idp, ID_TEST_USER, false); sync(foreignIDP, TestIdentityProvider.ID_SECOND_USER, false); Root r = preventRootCommit(delegatee); String[] result = delegatee.syncUsers(new String[] { ID_TEST_USER, TestIdentityProvider.ID_SECOND_USER, TestIdentityProvider.ID_WILDCARD_USER}, false); assertResultMessages(result, ImmutableMap.of( ID_TEST_USER, "ERR", TestIdentityProvider.ID_SECOND_USER, "for", TestIdentityProvider.ID_WILDCARD_USER, "nsa")); assertFalse(r.hasPendingChanges()); }