Delegatee { @NotNull String[] purgeOrphanedUsers() { context.setKeepMissing(false); ResultMessages messages = new ResultMessages(); Iterator<String> orphanedIdentities = internalListOrphanedIdentities(); List<SyncResult> results = new ArrayList<>(batchSize); while (orphanedIdentities.hasNext()) { String userId = orphanedIdentities.next(); results = syncUser(userId, true, 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 testPurgeOrphanedSaveError() throws Exception { sync(new TestIdentityProvider.TestUser("third", idp.getName()), idp); sync(new TestIdentityProvider.TestUser("forth", idp.getName()), idp); sync(idp, ID_TEST_USER, false); Root r = preventRootCommit(delegatee);; String[] result = delegatee.purgeOrphanedUsers(); assertResultMessages(result, ImmutableMap.of( "third", "ERR", "forth", "ERR")); assertFalse(r.hasPendingChanges()); }