@Test public void testResolve() { Configuration node1 = new Configuration("node1", ConfigurationFormat.CISCO_IOS); Configuration node2 = new Configuration("node2", ConfigurationFormat.CISCO_IOS); Interface iface1node1 = Interface.builder().setName("iface1").setOwner(node1).build(); Interface iface2node1 = Interface.builder().setName("iface2").setOwner(node1).build(); Interface iface1node2 = Interface.builder().setName("iface1").setOwner(node2).build(); node1.setInterfaces( ImmutableSortedMap.of( iface1node1.getName(), iface1node1, iface2node1.getName(), iface2node1)); node2.setInterfaces(ImmutableSortedMap.of(iface1node2.getName(), iface1node2)); MockSpecifierContext ctxt = MockSpecifierContext.builder() .setConfigs(ImmutableMap.of(node1.getHostname(), node1, node2.getHostname(), node2)) .build(); assertThat( new NodeSpecifierInterfaceSpecifier(new NameNodeSpecifier("node1")) .resolve(ImmutableSet.of("node1", "node2"), ctxt), containsInAnyOrder(NodeInterfacePair.of(iface1node1), NodeInterfacePair.of(iface2node1))); assertThat( new NodeSpecifierInterfaceSpecifier(new NameNodeSpecifier("node1")) .resolve(ImmutableSet.of("node2"), ctxt), empty()); }
@Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return Sets.intersection(_nodeSpecifier.resolve(ctxt), nodes).stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); }
NodeSpecifierInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return Sets.intersection(_nodeSpecifier.resolve(ctxt), nodes).stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } }
NodeSpecifierInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return Sets.intersection(_nodeSpecifier.resolve(ctxt), nodes).stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } NodeSpecifierInterfaceSpecifier(NodeSpecifier nodeSpecifier); }
NodeSpecifierInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return Sets.intersection(_nodeSpecifier.resolve(ctxt), nodes).stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } NodeSpecifierInterfaceSpecifier(NodeSpecifier nodeSpecifier); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt); }
NodeSpecifierInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return Sets.intersection(_nodeSpecifier.resolve(ctxt), nodes).stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } NodeSpecifierInterfaceSpecifier(NodeSpecifier nodeSpecifier); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt);  }