@Test public void testResolve() { Configuration c1 = new Configuration("node1", ConfigurationFormat.CISCO_IOS); c1.setDeviceType(DeviceType.HOST); Configuration c2 = new Configuration("node2", ConfigurationFormat.CISCO_IOS); c2.setDeviceType(DeviceType.ROUTER); MockSpecifierContext ctxt = MockSpecifierContext.builder() .setConfigs(ImmutableMap.of("node1", c1, "node2", c2)) .build(); assertThat( new TypesNodeSpecifier(ImmutableSet.of(DeviceType.HOST)).resolve(ctxt), equalTo(ImmutableSet.of("node1"))); assertThat( new TypesNodeSpecifier(ImmutableSet.of(DeviceType.SWITCH)).resolve(ctxt), equalTo(ImmutableSet.of())); }
@Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> _types.contains(c.getDeviceType())) .map(Configuration::getHostname) .collect(ImmutableSet.toImmutableSet()); }
TypesNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> _types.contains(c.getDeviceType())) .map(Configuration::getHostname) .collect(ImmutableSet.toImmutableSet()); } }
TypesNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> _types.contains(c.getDeviceType())) .map(Configuration::getHostname) .collect(ImmutableSet.toImmutableSet()); } TypesNodeSpecifier(Set<DeviceType> types); }
TypesNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> _types.contains(c.getDeviceType())) .map(Configuration::getHostname) .collect(ImmutableSet.toImmutableSet()); } TypesNodeSpecifier(Set<DeviceType> types); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<String> resolve(SpecifierContext ctxt); }
TypesNodeSpecifier implements NodeSpecifier { @Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> _types.contains(c.getDeviceType())) .map(Configuration::getHostname) .collect(ImmutableSet.toImmutableSet()); } TypesNodeSpecifier(Set<DeviceType> types); @Override boolean equals(Object o); @Override int hashCode(); @Override Set<String> resolve(SpecifierContext ctxt);  }