@Test public void testResolve() { MockSpecifierContext ctxt = MockSpecifierContext.builder() .setConfigs( ImmutableMap.of( "node1", new Configuration("node1", ConfigurationFormat.CISCO_IOS), "node2", new Configuration("node2", ConfigurationFormat.CISCO_IOS))) .build(); assertThat( new NameRegexNodeSpecifier(Pattern.compile("node1")).resolve(ctxt), equalTo(ImmutableSet.of("node1"))); assertThat( new NameRegexNodeSpecifier(Pattern.compile("node")).resolve(ctxt), equalTo(ImmutableSet.of("node1", "node2"))); assertThat( new NameRegexNodeSpecifier(Pattern.compile("node3")).resolve(ctxt), equalTo(ImmutableSet.of())); }
@Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().keySet().stream() .filter(n -> _namePattern.matcher(n).find()) .collect(ImmutableSet.toImmutableSet()); }
NameRegexNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().keySet().stream() .filter(n -> _namePattern.matcher(n).find()) .collect(ImmutableSet.toImmutableSet()); } }
NameRegexNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().keySet().stream() .filter(n -> _namePattern.matcher(n).find()) .collect(ImmutableSet.toImmutableSet()); } NameRegexNodeSpecifier(Pattern namePattern); }
NameRegexNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().keySet().stream() .filter(n -> _namePattern.matcher(n).find()) .collect(ImmutableSet.toImmutableSet()); } NameRegexNodeSpecifier(Pattern namePattern); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<String> resolve(SpecifierContext ctxt); }
NameRegexNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().keySet().stream() .filter(n -> _namePattern.matcher(n).find()) .collect(ImmutableSet.toImmutableSet()); } NameRegexNodeSpecifier(Pattern namePattern); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<String> resolve(SpecifierContext ctxt);  }