@Test public void testResolveSourceIpSpace_emptyLocations() throws InvalidReachabilityParametersException { ReachabilityParameters reachabilityParameters = ReachabilityParameters.builder() .setActions(ImmutableSortedSet.of(ACCEPTED)) .setFinalNodesSpecifier(AllNodesNodeSpecifier.INSTANCE) .setDestinationIpSpaceSpecifier(new ConstantIpSpaceSpecifier(EmptyIpSpace.INSTANCE)) .setSourceLocationSpecifier( new NodeNameRegexInterfaceLinkLocationSpecifier(Pattern.compile(""))) .build(); ReachabilityParametersResolver resolver = new ReachabilityParametersResolver(_batfish, reachabilityParameters, _snapshot); exception.expect(InvalidReachabilityParametersException.class); exception.expectMessage("No matching source locations"); resolver.resolveSourceIpSpaceAssignment(); }
@VisibleForTesting IpSpaceAssignment resolveSourceIpSpaceAssignment() throws InvalidReachabilityParametersException { Set<Location> sourceLocations = resolveActiveLocations(_params.getSourceLocationSpecifier(), _context); if (sourceLocations.isEmpty()) { throw new InvalidReachabilityParametersException("No matching source locations"); } IpSpaceAssignment sourceIpSpaceAssignment = IpSpaceAssignment.of( _params.getSourceIpSpaceSpecifier().resolve(sourceLocations, _context).getEntries() .stream() .filter( entry -> _ipSpaceRepresentative.getRepresentative(entry.getIpSpace()).isPresent()) .collect(ImmutableList.toImmutableList())); if (sourceIpSpaceAssignment.getEntries().isEmpty()) { throw new InvalidReachabilityParametersException("All sources have empty source IpSpaces"); } return sourceIpSpaceAssignment; }
ReachabilityParametersResolver { @VisibleForTesting IpSpaceAssignment resolveSourceIpSpaceAssignment() throws InvalidReachabilityParametersException { Set<Location> sourceLocations = resolveActiveLocations(_params.getSourceLocationSpecifier(), _context); if (sourceLocations.isEmpty()) { throw new InvalidReachabilityParametersException("No matching source locations"); } IpSpaceAssignment sourceIpSpaceAssignment = IpSpaceAssignment.of( _params.getSourceIpSpaceSpecifier().resolve(sourceLocations, _context).getEntries() .stream() .filter( entry -> _ipSpaceRepresentative.getRepresentative(entry.getIpSpace()).isPresent()) .collect(ImmutableList.toImmutableList())); if (sourceIpSpaceAssignment.getEntries().isEmpty()) { throw new InvalidReachabilityParametersException("All sources have empty source IpSpaces"); } return sourceIpSpaceAssignment; } }
ReachabilityParametersResolver { @VisibleForTesting IpSpaceAssignment resolveSourceIpSpaceAssignment() throws InvalidReachabilityParametersException { Set<Location> sourceLocations = resolveActiveLocations(_params.getSourceLocationSpecifier(), _context); if (sourceLocations.isEmpty()) { throw new InvalidReachabilityParametersException("No matching source locations"); } IpSpaceAssignment sourceIpSpaceAssignment = IpSpaceAssignment.of( _params.getSourceIpSpaceSpecifier().resolve(sourceLocations, _context).getEntries() .stream() .filter( entry -> _ipSpaceRepresentative.getRepresentative(entry.getIpSpace()).isPresent()) .collect(ImmutableList.toImmutableList())); if (sourceIpSpaceAssignment.getEntries().isEmpty()) { throw new InvalidReachabilityParametersException("All sources have empty source IpSpaces"); } return sourceIpSpaceAssignment; } @VisibleForTesting  ReachabilityParametersResolver(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); }
ReachabilityParametersResolver { @VisibleForTesting IpSpaceAssignment resolveSourceIpSpaceAssignment() throws InvalidReachabilityParametersException { Set<Location> sourceLocations = resolveActiveLocations(_params.getSourceLocationSpecifier(), _context); if (sourceLocations.isEmpty()) { throw new InvalidReachabilityParametersException("No matching source locations"); } IpSpaceAssignment sourceIpSpaceAssignment = IpSpaceAssignment.of( _params.getSourceIpSpaceSpecifier().resolve(sourceLocations, _context).getEntries() .stream() .filter( entry -> _ipSpaceRepresentative.getRepresentative(entry.getIpSpace()).isPresent()) .collect(ImmutableList.toImmutableList())); if (sourceIpSpaceAssignment.getEntries().isEmpty()) { throw new InvalidReachabilityParametersException("All sources have empty source IpSpaces"); } return sourceIpSpaceAssignment; } @VisibleForTesting  ReachabilityParametersResolver(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); static ResolvedReachabilityParameters resolveReachabilityParameters(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); }
ReachabilityParametersResolver { @VisibleForTesting IpSpaceAssignment resolveSourceIpSpaceAssignment() throws InvalidReachabilityParametersException { Set<Location> sourceLocations = resolveActiveLocations(_params.getSourceLocationSpecifier(), _context); if (sourceLocations.isEmpty()) { throw new InvalidReachabilityParametersException("No matching source locations"); } IpSpaceAssignment sourceIpSpaceAssignment = IpSpaceAssignment.of( _params.getSourceIpSpaceSpecifier().resolve(sourceLocations, _context).getEntries() .stream() .filter( entry -> _ipSpaceRepresentative.getRepresentative(entry.getIpSpace()).isPresent()) .collect(ImmutableList.toImmutableList())); if (sourceIpSpaceAssignment.getEntries().isEmpty()) { throw new InvalidReachabilityParametersException("All sources have empty source IpSpaces"); } return sourceIpSpaceAssignment; } @VisibleForTesting  ReachabilityParametersResolver(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); static ResolvedReachabilityParameters resolveReachabilityParameters(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot);  }