DefaultSyncHandler implements SyncHandler { @Override public SyncedIdentity findIdentity(@NotNull UserManager userManager, @NotNull String id) throws RepositoryException { return DefaultSyncContext.createSyncedIdentity(userManager.getAuthorizable(id)); } @SuppressWarnings("UnusedDeclaration")  DefaultSyncHandler();  DefaultSyncHandler(DefaultSyncConfig config); @NotNull @Override String getName(); @NotNull @Override SyncContext createContext(@NotNull ExternalIdentityProvider idp, @NotNull UserManager userManager,
                                     @NotNull ValueFactory valueFactory); @Override SyncedIdentity findIdentity(@NotNull UserManager userManager, @NotNull String id); @Override boolean requiresSync(@NotNull SyncedIdentity identity); @NotNull @Override Iterator<SyncedIdentity> listIdentities(@NotNull UserManager userManager);  }
@Test public void testFindMissingIdentity() throws Exception { SyncedIdentity id = syncHandler.findIdentity(userManager, "foobar"); assertNull("unknown authorizable should not exist", id); }
@Test public void testFindLocalIdentity() throws Exception { SyncedIdentity id = syncHandler.findIdentity(userManager, "admin"); assertNotNull("known authorizable should exist", id); assertNull("local user should not have external ref", id.getExternalIdRef()); }
@Test public void testFindGroupIdentity() throws Exception { SyncedIdentity si = syncHandler.findIdentity(userManager, "c"); assertNull(si); sync("c", true); si = syncHandler.findIdentity(userManager, "c"); assertNotNull(si); assertTrue(si.isGroup()); assertNotNull(si.getExternalIdRef()); }
@Test public void testFindIdentityWithRemovedExternalId() throws Exception { sync(USER_ID, false); Authorizable authorizable = userManager.getAuthorizable(USER_ID); Root systemRoot = getSystemRoot(); systemRoot.getTree(authorizable.getPath()).removeProperty(DefaultSyncContext.REP_EXTERNAL_ID); systemRoot.commit(); root.refresh(); SyncedIdentity si = syncHandler.findIdentity(userManager, USER_ID); assertNotNull(si); assertNull(si.getExternalIdRef()); }