@Test public void testSyncPolicy_noEndpointsInConfiguration() throws Exception { RendererEndpoint rendererEndpoint = createRendererEndpoint(contextId_1, contextId_2, null); Configuration policyConfiguration = createTestConfiguration(null, Collections.singletonList(rendererEndpoint), null, null); ListenableFuture result = policyManager.syncPolicy(policyConfiguration, null, 0); assertTrue((boolean) result.get()); }
@Override @Nonnull public ListenableFuture<Boolean> syncPolicy(@Nullable final Configuration dataAfter, @Nullable final Configuration dataBefore, final long version) { ListenableFuture<Optional<Status>> creationResult; if (dataBefore == null && dataAfter != null) { creationResult = syncEndpoints(dataAfter, Create); } else if (dataBefore != null && dataAfter == null) { creationResult = syncEndpoints(dataBefore, Delete); } else { final ListenableFuture<Optional<Status>> deletionResult = syncEndpoints(dataBefore, Delete); creationResult = Futures.transformAsync(deletionResult, new AsyncFunction<Optional<Status>, Optional<Status>>() { @Nonnull @Override public ListenableFuture<Optional<Status>> apply(@Nonnull Optional<Status> deletionResult) throws Exception { if (deletionResult.isPresent()) { deletionResult.get(); } return syncEndpoints(dataAfter, Create); } }, MoreExecutors.directExecutor()); } return Futures.transformAsync(creationResult, new AsyncFunction<Optional<Status>, Boolean>() { @Override public ListenableFuture<Boolean> apply(@Nullable final Optional<Status> statusValue) throws Exception { Preconditions.checkArgument(statusValue != null, "provided status must not be null"); return Futures.transform(reportPolicy(version, statusValue), new Function<Void, Boolean>() { @Override public Boolean apply(@Nullable final Void input) { return Boolean.TRUE; } }, MoreExecutors.directExecutor()); } }, MoreExecutors.directExecutor()); }
PolicyManagerImpl implements PolicyManager { @Override @Nonnull public ListenableFuture<Boolean> syncPolicy(@Nullable final Configuration dataAfter, @Nullable final Configuration dataBefore, final long version) { ListenableFuture<Optional<Status>> creationResult; if (dataBefore == null && dataAfter != null) { creationResult = syncEndpoints(dataAfter, Create); } else if (dataBefore != null && dataAfter == null) { creationResult = syncEndpoints(dataBefore, Delete); } else { final ListenableFuture<Optional<Status>> deletionResult = syncEndpoints(dataBefore, Delete); creationResult = Futures.transformAsync(deletionResult, new AsyncFunction<Optional<Status>, Optional<Status>>() { @Nonnull @Override public ListenableFuture<Optional<Status>> apply(@Nonnull Optional<Status> deletionResult) throws Exception { if (deletionResult.isPresent()) { deletionResult.get(); } return syncEndpoints(dataAfter, Create); } }, MoreExecutors.directExecutor()); } return Futures.transformAsync(creationResult, new AsyncFunction<Optional<Status>, Boolean>() { @Override public ListenableFuture<Boolean> apply(@Nullable final Optional<Status> statusValue) throws Exception { Preconditions.checkArgument(statusValue != null, "provided status must not be null"); return Futures.transform(reportPolicy(version, statusValue), new Function<Void, Boolean>() { @Override public Boolean apply(@Nullable final Void input) { return Boolean.TRUE; } }, MoreExecutors.directExecutor()); } }, MoreExecutors.directExecutor()); } }
PolicyManagerImpl implements PolicyManager { @Override @Nonnull public ListenableFuture<Boolean> syncPolicy(@Nullable final Configuration dataAfter, @Nullable final Configuration dataBefore, final long version) { ListenableFuture<Optional<Status>> creationResult; if (dataBefore == null && dataAfter != null) { creationResult = syncEndpoints(dataAfter, Create); } else if (dataBefore != null && dataAfter == null) { creationResult = syncEndpoints(dataBefore, Delete); } else { final ListenableFuture<Optional<Status>> deletionResult = syncEndpoints(dataBefore, Delete); creationResult = Futures.transformAsync(deletionResult, new AsyncFunction<Optional<Status>, Optional<Status>>() { @Nonnull @Override public ListenableFuture<Optional<Status>> apply(@Nonnull Optional<Status> deletionResult) throws Exception { if (deletionResult.isPresent()) { deletionResult.get(); } return syncEndpoints(dataAfter, Create); } }, MoreExecutors.directExecutor()); } return Futures.transformAsync(creationResult, new AsyncFunction<Optional<Status>, Boolean>() { @Override public ListenableFuture<Boolean> apply(@Nullable final Optional<Status> statusValue) throws Exception { Preconditions.checkArgument(statusValue != null, "provided status must not be null"); return Futures.transform(reportPolicy(version, statusValue), new Function<Void, Boolean>() { @Override public Boolean apply(@Nullable final Void input) { return Boolean.TRUE; } }, MoreExecutors.directExecutor()); } }, MoreExecutors.directExecutor()); } PolicyManagerImpl(final DataBroker dataBroker,
                             final NodeManager nodeManager, final EPToSgtMapper epToSgtMapper,
                             final IpSgtDistributionService ipSgtDistributor); }
PolicyManagerImpl implements PolicyManager { @Override @Nonnull public ListenableFuture<Boolean> syncPolicy(@Nullable final Configuration dataAfter, @Nullable final Configuration dataBefore, final long version) { ListenableFuture<Optional<Status>> creationResult; if (dataBefore == null && dataAfter != null) { creationResult = syncEndpoints(dataAfter, Create); } else if (dataBefore != null && dataAfter == null) { creationResult = syncEndpoints(dataBefore, Delete); } else { final ListenableFuture<Optional<Status>> deletionResult = syncEndpoints(dataBefore, Delete); creationResult = Futures.transformAsync(deletionResult, new AsyncFunction<Optional<Status>, Optional<Status>>() { @Nonnull @Override public ListenableFuture<Optional<Status>> apply(@Nonnull Optional<Status> deletionResult) throws Exception { if (deletionResult.isPresent()) { deletionResult.get(); } return syncEndpoints(dataAfter, Create); } }, MoreExecutors.directExecutor()); } return Futures.transformAsync(creationResult, new AsyncFunction<Optional<Status>, Boolean>() { @Override public ListenableFuture<Boolean> apply(@Nullable final Optional<Status> statusValue) throws Exception { Preconditions.checkArgument(statusValue != null, "provided status must not be null"); return Futures.transform(reportPolicy(version, statusValue), new Function<Void, Boolean>() { @Override public Boolean apply(@Nullable final Void input) { return Boolean.TRUE; } }, MoreExecutors.directExecutor()); } }, MoreExecutors.directExecutor()); } PolicyManagerImpl(final DataBroker dataBroker,
                             final NodeManager nodeManager, final EPToSgtMapper epToSgtMapper,
                             final IpSgtDistributionService ipSgtDistributor); @Override @Nonnull ListenableFuture<Boolean> syncPolicy(@Nullable final Configuration dataAfter, @Nullable final Configuration dataBefore,
                                                final long version); @Override void close(); }
PolicyManagerImpl implements PolicyManager { @Override @Nonnull public ListenableFuture<Boolean> syncPolicy(@Nullable final Configuration dataAfter, @Nullable final Configuration dataBefore, final long version) { ListenableFuture<Optional<Status>> creationResult; if (dataBefore == null && dataAfter != null) { creationResult = syncEndpoints(dataAfter, Create); } else if (dataBefore != null && dataAfter == null) { creationResult = syncEndpoints(dataBefore, Delete); } else { final ListenableFuture<Optional<Status>> deletionResult = syncEndpoints(dataBefore, Delete); creationResult = Futures.transformAsync(deletionResult, new AsyncFunction<Optional<Status>, Optional<Status>>() { @Nonnull @Override public ListenableFuture<Optional<Status>> apply(@Nonnull Optional<Status> deletionResult) throws Exception { if (deletionResult.isPresent()) { deletionResult.get(); } return syncEndpoints(dataAfter, Create); } }, MoreExecutors.directExecutor()); } return Futures.transformAsync(creationResult, new AsyncFunction<Optional<Status>, Boolean>() { @Override public ListenableFuture<Boolean> apply(@Nullable final Optional<Status> statusValue) throws Exception { Preconditions.checkArgument(statusValue != null, "provided status must not be null"); return Futures.transform(reportPolicy(version, statusValue), new Function<Void, Boolean>() { @Override public Boolean apply(@Nullable final Void input) { return Boolean.TRUE; } }, MoreExecutors.directExecutor()); } }, MoreExecutors.directExecutor()); } PolicyManagerImpl(final DataBroker dataBroker,
                             final NodeManager nodeManager, final EPToSgtMapper epToSgtMapper,
                             final IpSgtDistributionService ipSgtDistributor); @Override @Nonnull ListenableFuture<Boolean> syncPolicy(@Nullable final Configuration dataAfter, @Nullable final Configuration dataBefore,
                                                final long version); @Override void close(); static final RendererName IOS_XE_RENDERER; }