Delegatee { @NotNull String[] listOrphanedUsers() { return Iterators.toArray(internalListOrphanedIdentities(), String.class); } private  Delegatee(@NotNull SyncHandler handler, @NotNull ExternalIdentityProvider idp,
                      @NotNull ContentSession systemSession, @NotNull SecurityProvider securityProvider, int batchSize);   }
@Test public void testListOrphanedUsersFiltersNullSyncIdentity() throws Exception { Iterator<SyncedIdentity> it = Arrays.asList((SyncedIdentity) null).iterator(); SyncHandler syncHandler = mock(SyncHandler.class); when(syncHandler.listIdentities(any(UserManager.class))).thenReturn(it); Delegatee dg = createDelegatee(new TestIdentityProvider(), syncHandler); assertEquals(0, dg.listOrphanedUsers().length); }
@Test public void testListOrphanedUsersFiltersForeignSyncIdentity() throws Exception { SyncedIdentity foreign = new DefaultSyncedIdentity(ID_TEST_USER, null, false, -1); SyncedIdentity foreign2 = new DefaultSyncedIdentity(ID_TEST_USER, new ExternalIdentityRef(ID_TEST_USER, null), false, -1); SyncedIdentity foreign3 = new DefaultSyncedIdentity(ID_TEST_USER, new ExternalIdentityRef(ID_TEST_USER, "other"), false, -1); SyncedIdentity emptyIdpName = new DefaultSyncedIdentity(ID_TEST_USER, new ExternalIdentityRef(ID_TEST_USER, ""), false, -1); Iterator<SyncedIdentity> it = Arrays.asList(foreign, foreign2, foreign3, emptyIdpName).iterator(); SyncHandler syncHandler = mock(SyncHandler.class); when(syncHandler.listIdentities(any(UserManager.class))).thenReturn(it); Delegatee dg = createDelegatee(new TestIdentityProvider(), syncHandler); assertEquals(0, dg.listOrphanedUsers().length); }