@Override protected Stream<Location> getNodeLocations(Configuration node) { return node.getAllInterfaces().values().stream() .map(iface -> new InterfaceLinkLocation(node.getHostname(), iface.getName())); } }
@Override Stream<Location> getNodeLocations(Configuration node) { return node.getAllInterfaces().values().stream() .map(iface -> new InterfaceLinkLocation(node.getHostname(), iface.getName())); } }
@Override public Location visitInterfaceLocation(InterfaceLocation interfaceLocation) { return new InterfaceLinkLocation( interfaceLocation.getNodeName(), interfaceLocation.getInterfaceName()); } });
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(node -> node.getAllInterfaces().values().stream()) .map(iface -> new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName())) .collect(ImmutableSet.toImmutableSet()); } }
@Override protected Stream<Location> getVrfLocations(Vrf vrf) { return vrf.getInterfaces().values().stream() .map(iface -> new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName())); } }
@Override protected Location getLocation(Interface iface) { return new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName()); } }
@Override protected Location getLocation(Interface iface) { return new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName()); } }
/** Do we resolve non empty sets properly? */ @Test public void resolveNonEmptySet() { LocationSpecifier inner = new MockLocationSpecifier( ImmutableSet.of( new InterfaceLocation("foo1", "bar1"), new InterfaceLinkLocation("foo2", "bar2"))); assertThat( new ToInterfaceLinkLocationSpecifier(inner).resolve(_mockContext), equalTo( ImmutableSet.of( new InterfaceLinkLocation("foo1", "bar1"), new InterfaceLinkLocation("foo2", "bar2")))); }
/** Do we convert locations properly? */ @Test public void toInterfaceLinkLocation() { InterfaceLocation ifaceLocation = new InterfaceLocation("foo", "bar"); InterfaceLinkLocation ifaceLinkLocation = new InterfaceLinkLocation("foo", "bar"); assertThat( ToInterfaceLinkLocationSpecifier.toInterfaceLinkLocation(ifaceLocation), equalTo(ifaceLinkLocation)); assertThat( ToInterfaceLinkLocationSpecifier.toInterfaceLinkLocation(ifaceLinkLocation), equalTo(ifaceLinkLocation)); } }