DefaultSyncContext implements SyncContext { @Nullable protected Value[] createValues(@NotNull Collection<?> propValues) throws RepositoryException { List<Value> values = new ArrayList<>(); for (Object obj : propValues) { Value v = createValue(obj); if (v != null) { values.add(v); } } return values.toArray(new Value[0]); } 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 testCreateValuesEmptyCollection() throws Exception { Value[] vs = syncCtx.createValues(ImmutableList.of()); assertNotNull(vs); assertEquals(0, vs.length); }
@Test public void testCreateValuesSkipsNull() throws Exception { List<String> strings = Lists.newArrayList("s", null, null, "t"); Value[] vs = syncCtx.createValues(strings); assertNotNull(vs); assertEquals(2, vs.length); }