@Test public void fillDefinitionsSafely_null() throws Exception { final Map<IpAddress, RoutingDefinition> targetMap = new HashMap<>(); final SxpClusterRoute sxpClusterRoute = new SxpClusterRouteBuilder().build(); reactor.fillDefinitionsSafely(sxpClusterRoute, targetMap); Assert.assertEquals(0, targetMap.size()); }
@VisibleForTesting void fillDefinitionsSafely(final @Nullable SxpClusterRoute route, final Map<IpAddress, RoutingDefinition> definitions) { final Optional<Stream<RoutingDefinition>> routingDefinition = Optional.ofNullable(route) .map(SxpClusterRoute::getRoutingDefinition) .map(Collection::stream); routingDefinition.ifPresent(routingDefinitions -> routingDefinitions.forEach(definition -> definitions.put(definition.getIpAddress(), definition) )); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void fillDefinitionsSafely(final @Nullable SxpClusterRoute route, final Map<IpAddress, RoutingDefinition> definitions) { final Optional<Stream<RoutingDefinition>> routingDefinition = Optional.ofNullable(route) .map(SxpClusterRoute::getRoutingDefinition) .map(Collection::stream); routingDefinition.ifPresent(routingDefinitions -> routingDefinitions.forEach(definition -> definitions.put(definition.getIpAddress(), definition) )); } }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void fillDefinitionsSafely(final @Nullable SxpClusterRoute route, final Map<IpAddress, RoutingDefinition> definitions) { final Optional<Stream<RoutingDefinition>> routingDefinition = Optional.ofNullable(route) .map(SxpClusterRoute::getRoutingDefinition) .map(Collection::stream); routingDefinition.ifPresent(routingDefinitions -> routingDefinitions.forEach(definition -> definitions.put(definition.getIpAddress(), definition) )); } RouteReactorImpl(final DataBroker dataBroker, final RoutingServiceFactory routingServiceFactory); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void fillDefinitionsSafely(final @Nullable SxpClusterRoute route, final Map<IpAddress, RoutingDefinition> definitions) { final Optional<Stream<RoutingDefinition>> routingDefinition = Optional.ofNullable(route) .map(SxpClusterRoute::getRoutingDefinition) .map(Collection::stream); routingDefinition.ifPresent(routingDefinitions -> routingDefinitions.forEach(definition -> definitions.put(definition.getIpAddress(), definition) )); } RouteReactorImpl(final DataBroker dataBroker, final RoutingServiceFactory routingServiceFactory); @Override FluentFuture<? extends CommitInfo> updateRouting(@Nullable final SxpClusterRoute oldRoute,
                                                            @Nullable final SxpClusterRoute newRoute); @Override FluentFuture<? extends CommitInfo> wipeRouting(); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void fillDefinitionsSafely(final @Nullable SxpClusterRoute route, final Map<IpAddress, RoutingDefinition> definitions) { final Optional<Stream<RoutingDefinition>> routingDefinition = Optional.ofNullable(route) .map(SxpClusterRoute::getRoutingDefinition) .map(Collection::stream); routingDefinition.ifPresent(routingDefinitions -> routingDefinitions.forEach(definition -> definitions.put(definition.getIpAddress(), definition) )); } RouteReactorImpl(final DataBroker dataBroker, final RoutingServiceFactory routingServiceFactory); @Override FluentFuture<? extends CommitInfo> updateRouting(@Nullable final SxpClusterRoute oldRoute,
                                                            @Nullable final SxpClusterRoute newRoute); @Override FluentFuture<? extends CommitInfo> wipeRouting();  }