@Test public void testLocationIsActive() { NetworkFactory nf = new NetworkFactory(); Configuration node = nf.configurationBuilder().setConfigurationFormat(CISCO_IOS).build(); Vrf vrf = nf.vrfBuilder().setOwner(node).build(); Interface activeInterface = nf.interfaceBuilder().setOwner(node).setVrf(vrf).build(); Interface inactiveInterface = nf.interfaceBuilder().setActive(false).setOwner(node).setVrf(vrf).build(); SortedMap<String, Configuration> configs = ImmutableSortedMap.of(node.getHostname(), node); String hostname = node.getHostname(); assertTrue(isActive(new InterfaceLinkLocation(hostname, activeInterface.getName()), configs)); assertFalse( isActive(new InterfaceLinkLocation(hostname, inactiveInterface.getName()), configs)); assertTrue(isActive(new InterfaceLinkLocation(hostname, activeInterface.getName()), configs)); assertFalse( isActive(new InterfaceLinkLocation(hostname, inactiveInterface.getName()), configs)); }
@VisibleForTesting static boolean isActive(Location l, Map<String, Configuration> configs) { NodeInterfacePair iface; if (l instanceof InterfaceLocation) { iface = NodeInterfacePair.of( ((InterfaceLocation) l).getNodeName(), ((InterfaceLocation) l).getInterfaceName()); } else { assert l instanceof InterfaceLinkLocation; iface = NodeInterfacePair.of( ((InterfaceLinkLocation) l).getNodeName(), ((InterfaceLinkLocation) l).getInterfaceName()); } return configs .get(iface.getHostname()) .getAllInterfaces() .get(iface.getInterface()) .getActive(); }
SpecifierUtils { @VisibleForTesting static boolean isActive(Location l, Map<String, Configuration> configs) { NodeInterfacePair iface; if (l instanceof InterfaceLocation) { iface = NodeInterfacePair.of( ((InterfaceLocation) l).getNodeName(), ((InterfaceLocation) l).getInterfaceName()); } else { assert l instanceof InterfaceLinkLocation; iface = NodeInterfacePair.of( ((InterfaceLinkLocation) l).getNodeName(), ((InterfaceLinkLocation) l).getInterfaceName()); } return configs .get(iface.getHostname()) .getAllInterfaces() .get(iface.getInterface()) .getActive(); } }
SpecifierUtils { @VisibleForTesting static boolean isActive(Location l, Map<String, Configuration> configs) { NodeInterfacePair iface; if (l instanceof InterfaceLocation) { iface = NodeInterfacePair.of( ((InterfaceLocation) l).getNodeName(), ((InterfaceLocation) l).getInterfaceName()); } else { assert l instanceof InterfaceLinkLocation; iface = NodeInterfacePair.of( ((InterfaceLinkLocation) l).getNodeName(), ((InterfaceLinkLocation) l).getInterfaceName()); } return configs .get(iface.getHostname()) .getAllInterfaces() .get(iface.getInterface()) .getActive(); } private  SpecifierUtils(); }
SpecifierUtils { @VisibleForTesting static boolean isActive(Location l, Map<String, Configuration> configs) { NodeInterfacePair iface; if (l instanceof InterfaceLocation) { iface = NodeInterfacePair.of( ((InterfaceLocation) l).getNodeName(), ((InterfaceLocation) l).getInterfaceName()); } else { assert l instanceof InterfaceLinkLocation; iface = NodeInterfacePair.of( ((InterfaceLinkLocation) l).getNodeName(), ((InterfaceLinkLocation) l).getInterfaceName()); } return configs .get(iface.getHostname()) .getAllInterfaces() .get(iface.getInterface()) .getActive(); } private  SpecifierUtils(); static Set<Location> resolveActiveLocations(
      LocationSpecifier locationSpecifier, SpecifierContext context); }
SpecifierUtils { @VisibleForTesting static boolean isActive(Location l, Map<String, Configuration> configs) { NodeInterfacePair iface; if (l instanceof InterfaceLocation) { iface = NodeInterfacePair.of( ((InterfaceLocation) l).getNodeName(), ((InterfaceLocation) l).getInterfaceName()); } else { assert l instanceof InterfaceLinkLocation; iface = NodeInterfacePair.of( ((InterfaceLinkLocation) l).getNodeName(), ((InterfaceLinkLocation) l).getInterfaceName()); } return configs .get(iface.getHostname()) .getAllInterfaces() .get(iface.getInterface()) .getActive(); } private  SpecifierUtils(); static Set<Location> resolveActiveLocations(
      LocationSpecifier locationSpecifier, SpecifierContext context);  }