@Test public void resolve() { Configuration node1 = new Configuration("node1", ConfigurationFormat.CISCO_IOS); Configuration node2 = new Configuration("node2", ConfigurationFormat.CISCO_IOS); Vrf vrf1node1 = new Vrf("vrf1"); Vrf vrf2node1 = new Vrf("vrf2"); Vrf vrf1node2 = new Vrf("vrf1"); Interface iface11 = Interface.builder().setName("iface11").setOwner(node1).setVrf(vrf1node1).build(); Interface.builder().setName("iface12").setOwner(node1).setVrf(vrf2node1).build(); Interface iface2 = Interface.builder().setName("iface2").setOwner(node2).setVrf(vrf1node2).build(); node1.setVrfs(ImmutableSortedMap.of("vrf1", vrf1node1, "vrf2", vrf2node1)); node2.setVrfs(ImmutableSortedMap.of("vrf1", vrf1node2)); MockSpecifierContext ctxt = MockSpecifierContext.builder() .setConfigs(ImmutableMap.of("node1", node1, "node2", node2)) .build(); assertThat( new VrfNameInterfaceSpecifier("vrf1").resolve(ImmutableSet.of("node1"), ctxt), contains(NodeInterfacePair.of(iface11))); assertThat( new VrfNameInterfaceSpecifier("vrf1").resolve(ImmutableSet.of("node1", "node2"), ctxt), containsInAnyOrder(NodeInterfacePair.of(iface11), NodeInterfacePair.of(iface2))); assertThat( new VrfNameInterfaceSpecifier("VrF1").resolve(ImmutableSet.of("node1"), ctxt), contains(NodeInterfacePair.of(iface11))); assertThat( new VrfNameInterfaceSpecifier("vrf").resolve(ImmutableSet.of("node1"), ctxt), empty()); assertThat( new VrfNameInterfaceSpecifier("v.*").resolve(ImmutableSet.of("node1"), ctxt), empty()); }
@Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return nodes.stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .filter(i -> _name.equalsIgnoreCase(i.getVrfName())) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); }
VrfNameInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return nodes.stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .filter(i -> _name.equalsIgnoreCase(i.getVrfName())) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } }
VrfNameInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return nodes.stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .filter(i -> _name.equalsIgnoreCase(i.getVrfName())) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } VrfNameInterfaceSpecifier(String name); }
VrfNameInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return nodes.stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .filter(i -> _name.equalsIgnoreCase(i.getVrfName())) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } VrfNameInterfaceSpecifier(String name); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt); }
VrfNameInterfaceSpecifier implements InterfaceSpecifier { @Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return nodes.stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .filter(i -> _name.equalsIgnoreCase(i.getVrfName())) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } VrfNameInterfaceSpecifier(String name); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt);  }