DefaultSyncContext implements SyncContext { @Nullable public static ExternalIdentityRef getIdentityRef(@Nullable Authorizable auth) throws RepositoryException { if (auth == null) { return null; } Value[] v = auth.getProperty(REP_EXTERNAL_ID); if (v == null || v.length == 0) { return null; } return ExternalIdentityRef.fromString(v[0].getString()); } DefaultSyncContext(@NotNull DefaultSyncConfig config, @NotNull ExternalIdentityProvider idp, @NotNull UserManager userManager, @NotNull ValueFactory valueFactory); @Nullable static DefaultSyncedIdentity createSyncedIdentity(@Nullable Authorizable auth); @Nullable static ExternalIdentityRef getIdentityRef(@Nullable Authorizable auth); static String joinPaths(String... paths); @Override void close(); @Override boolean isKeepMissing(); @NotNull @Override SyncContext setKeepMissing(boolean keepMissing); @Override boolean isForceUserSync(); @NotNull @Override SyncContext setForceUserSync(boolean forceUserSync); @Override boolean isForceGroupSync(); @Override @NotNull SyncContext setForceGroupSync(boolean forceGroupSync); @NotNull @Override SyncResult sync(@NotNull ExternalIdentity identity); @NotNull @Override SyncResult sync(@NotNull String id); static final String REP_EXTERNAL_ID; static final String REP_LAST_SYNCED; }
@Test public void testGetIdentityRefNull() throws Exception { assertNull(DefaultSyncContext.getIdentityRef(null)); }
@Test public void testGetIdentityRefLocalGroup() throws Exception { assertNull(DefaultSyncContext.getIdentityRef(createTestGroup())); }
@Test public void testGetIdentityRefLocalUser() throws Exception { assertNull(DefaultSyncContext.getIdentityRef(getTestUser())); }
@Test public void testGetIdentityRefEmptyMvProperty() throws Exception { Group gr = createTestGroup(); gr.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, new Value[0]); ExternalIdentityRef ref = DefaultSyncContext.getIdentityRef(gr); assertNull(ref); }