@Test public void resolve() { Configuration node1 = new Configuration("node1", ConfigurationFormat.CISCO_IOS); Configuration node2 = new Configuration("node2", ConfigurationFormat.CISCO_IOS); Vrf vrf1 = new Vrf("vrf1"); Vrf vrf2 = new Vrf("vrf2"); Vrf vrf3 = new Vrf("vrf2"); Interface iface11 = Interface.builder().setName("iface11").setOwner(node1).setVrf(vrf1).build(); Interface.builder().setName("iface12").setOwner(node1).setVrf(vrf2).build(); Interface.builder().setName("iface2").setOwner(node2).setVrf(vrf3).build(); node1.setVrfs(ImmutableSortedMap.of("vrf1", vrf1, "vrf2", vrf2)); node2.setVrfs(ImmutableSortedMap.of("vrf3", vrf3)); MockSpecifierContext ctxt = MockSpecifierContext.builder() .setConfigs(ImmutableMap.of("node1", node1, "node2", node2)) .build(); assertThat( new VrfNameRegexInterfaceSpecifier(Pattern.compile("vrf1")) .resolve(ImmutableSet.of("node1"), ctxt), equalTo(ImmutableSet.of(NodeInterfacePair.of(iface11)))); }
@Override public Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt) { return nodes.stream() .flatMap(n -> ctxt.getConfigs().get(n).getAllInterfaces().values().stream()) .filter(i -> _pattern.matcher(i.getVrfName()).matches()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); }
VrfNameRegexInterfaceSpecifier 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 -> _pattern.matcher(i.getVrfName()).matches()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } }
VrfNameRegexInterfaceSpecifier 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 -> _pattern.matcher(i.getVrfName()).matches()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } VrfNameRegexInterfaceSpecifier(Pattern pattern); }
VrfNameRegexInterfaceSpecifier 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 -> _pattern.matcher(i.getVrfName()).matches()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } VrfNameRegexInterfaceSpecifier(Pattern pattern); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt); }
VrfNameRegexInterfaceSpecifier 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 -> _pattern.matcher(i.getVrfName()).matches()) .map(NodeInterfacePair::of) .collect(ImmutableSet.toImmutableSet()); } VrfNameRegexInterfaceSpecifier(Pattern pattern); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<NodeInterfacePair> resolve(Set<String> nodes, SpecifierContext ctxt);  }