@Test public void getMatchingNodesByRole() { NodesSpecifier specifier = new NodesSpecifier("role:dim:match.*"); String matchingNode1 = "lhr-border-01"; String matchingNode2 = "svr-border-02"; String nonMatchingNode1 = "svr-core-1"; Set<String> nodes = new ImmutableSet.Builder<String>() .add(matchingNode1) .add(matchingNode2) .add(nonMatchingNode1) .build(); NodeRoleDimension roleDimension = NodeRoleDimension.builder() .setName("dim") .setRoleDimensionMappings( ImmutableList.of( new RoleDimensionMapping( "(.+-.+)-.+", null, ImmutableMap.of( "lhr-border", "match1", "svr-border", "match2", "lhr-core", "dumb0")))) .build(); Set<String> matchingNodes = specifier.getMatchingNodesByRole(roleDimension, nodes); assertThat(matchingNodes, hasItem(matchingNode1)); assertThat(matchingNodes, hasItem(matchingNode2)); assertThat(matchingNodes, not(hasItem(nonMatchingNode1))); }
public Set<String> getMatchingNodesByRole(NodeRoleDimension roleDimension, Set<String> nodes) { return nodes.stream() .filter(n -> nodeNameInMatchingRole(n, roleDimension)) .collect(ImmutableSet.toImmutableSet()); }
NodesSpecifier { public Set<String> getMatchingNodesByRole(NodeRoleDimension roleDimension, Set<String> nodes) { return nodes.stream() .filter(n -> nodeNameInMatchingRole(n, roleDimension)) .collect(ImmutableSet.toImmutableSet()); } }
NodesSpecifier { public Set<String> getMatchingNodesByRole(NodeRoleDimension roleDimension, Set<String> nodes) { return nodes.stream() .filter(n -> nodeNameInMatchingRole(n, roleDimension)) .collect(ImmutableSet.toImmutableSet()); } NodesSpecifier(String expression, boolean caseSensitive); @JsonCreator  NodesSpecifier(String expression); }
NodesSpecifier { public Set<String> getMatchingNodesByRole(NodeRoleDimension roleDimension, Set<String> nodes) { return nodes.stream() .filter(n -> nodeNameInMatchingRole(n, roleDimension)) .collect(ImmutableSet.toImmutableSet()); } NodesSpecifier(String expression, boolean caseSensitive); @JsonCreator  NodesSpecifier(String expression); @Override boolean equals(Object obj); static List<AutocompleteSuggestion> autoComplete(
      String query, Set<String> nodes, NodeRolesData nodeRoleData); String getExpression(); Set<String> getMatchingNodes(IBatfish batfish, NetworkSnapshot snapshot); @JsonIgnore Set<String> getMatchingNodes(SpecifierContext ctxt); Set<String> getMatchingNodesByName(Set<String> nodes); Set<String> getMatchingNodesByRole(NodeRoleDimension roleDimension, Set<String> nodes); @JsonIgnore Pattern getRegex(); @JsonIgnore String getRoleDimension(); @JsonIgnore Type getType(); @JsonIgnore boolean getCaseSensitive(); @Override int hashCode(); @Override @JsonValue String toString(); }
NodesSpecifier { public Set<String> getMatchingNodesByRole(NodeRoleDimension roleDimension, Set<String> nodes) { return nodes.stream() .filter(n -> nodeNameInMatchingRole(n, roleDimension)) .collect(ImmutableSet.toImmutableSet()); } NodesSpecifier(String expression, boolean caseSensitive); @JsonCreator  NodesSpecifier(String expression); @Override boolean equals(Object obj); static List<AutocompleteSuggestion> autoComplete(
      String query, Set<String> nodes, NodeRolesData nodeRoleData); String getExpression(); Set<String> getMatchingNodes(IBatfish batfish, NetworkSnapshot snapshot); @JsonIgnore Set<String> getMatchingNodes(SpecifierContext ctxt); Set<String> getMatchingNodesByName(Set<String> nodes); Set<String> getMatchingNodesByRole(NodeRoleDimension roleDimension, Set<String> nodes); @JsonIgnore Pattern getRegex(); @JsonIgnore String getRoleDimension(); @JsonIgnore Type getType(); @JsonIgnore boolean getCaseSensitive(); @Override int hashCode(); @Override @JsonValue String toString(); static final NodesSpecifier ALL; static final NodesSpecifier NONE; }