@Test public void testFilterMlags() { ImmutableSortedMap<String, Configuration> configs = getConfigs(); TableAnswerElement answer = computeAnswer(ImmutableSet.of("n1", "n2"), ImmutableSet.of("ID2"), configs); assertThat( answer.getRowsList(), contains( allOf( hasColumn(equalTo(COL_NODE), equalTo(new Node("n2")), Schema.NODE), hasColumn(equalTo(COL_MLAG_ID), equalTo("ID2"), Schema.STRING)))); }
@VisibleForTesting @Nonnull static TableAnswerElement computeAnswer( Set<String> nodes, Set<String> mlagIds, SortedMap<String, Configuration> configs) { ImmutableList<NodeToMlags> mlagConfigs = nodes.stream() .map(configs::get) .filter(Objects::nonNull) .map( c -> new NodeToMlags( c.getHostname(), c.getMlags().values().stream() .filter(mlag -> mlagIds.contains(mlag.getId())) .collect(Collectors.toList()))) .filter(mc -> !mc._mlags.isEmpty()) .collect(ImmutableList.toImmutableList()); TableAnswerElement answer = new TableAnswerElement(getMetadata()); mlagConfigs.forEach( c -> c._mlags.forEach(mlag -> answer.addRow(configToRow(c._hostname, mlag)))); return answer; }
MlagPropertiesAnswerer extends Answerer { @VisibleForTesting @Nonnull static TableAnswerElement computeAnswer( Set<String> nodes, Set<String> mlagIds, SortedMap<String, Configuration> configs) { ImmutableList<NodeToMlags> mlagConfigs = nodes.stream() .map(configs::get) .filter(Objects::nonNull) .map( c -> new NodeToMlags( c.getHostname(), c.getMlags().values().stream() .filter(mlag -> mlagIds.contains(mlag.getId())) .collect(Collectors.toList()))) .filter(mc -> !mc._mlags.isEmpty()) .collect(ImmutableList.toImmutableList()); TableAnswerElement answer = new TableAnswerElement(getMetadata()); mlagConfigs.forEach( c -> c._mlags.forEach(mlag -> answer.addRow(configToRow(c._hostname, mlag)))); return answer; } }
MlagPropertiesAnswerer extends Answerer { @VisibleForTesting @Nonnull static TableAnswerElement computeAnswer( Set<String> nodes, Set<String> mlagIds, SortedMap<String, Configuration> configs) { ImmutableList<NodeToMlags> mlagConfigs = nodes.stream() .map(configs::get) .filter(Objects::nonNull) .map( c -> new NodeToMlags( c.getHostname(), c.getMlags().values().stream() .filter(mlag -> mlagIds.contains(mlag.getId())) .collect(Collectors.toList()))) .filter(mc -> !mc._mlags.isEmpty()) .collect(ImmutableList.toImmutableList()); TableAnswerElement answer = new TableAnswerElement(getMetadata()); mlagConfigs.forEach( c -> c._mlags.forEach(mlag -> answer.addRow(configToRow(c._hostname, mlag)))); return answer; } MlagPropertiesAnswerer(Question question, IBatfish batfish); }
MlagPropertiesAnswerer extends Answerer { @VisibleForTesting @Nonnull static TableAnswerElement computeAnswer( Set<String> nodes, Set<String> mlagIds, SortedMap<String, Configuration> configs) { ImmutableList<NodeToMlags> mlagConfigs = nodes.stream() .map(configs::get) .filter(Objects::nonNull) .map( c -> new NodeToMlags( c.getHostname(), c.getMlags().values().stream() .filter(mlag -> mlagIds.contains(mlag.getId())) .collect(Collectors.toList()))) .filter(mc -> !mc._mlags.isEmpty()) .collect(ImmutableList.toImmutableList()); TableAnswerElement answer = new TableAnswerElement(getMetadata()); mlagConfigs.forEach( c -> c._mlags.forEach(mlag -> answer.addRow(configToRow(c._hostname, mlag)))); return answer; } MlagPropertiesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
MlagPropertiesAnswerer extends Answerer { @VisibleForTesting @Nonnull static TableAnswerElement computeAnswer( Set<String> nodes, Set<String> mlagIds, SortedMap<String, Configuration> configs) { ImmutableList<NodeToMlags> mlagConfigs = nodes.stream() .map(configs::get) .filter(Objects::nonNull) .map( c -> new NodeToMlags( c.getHostname(), c.getMlags().values().stream() .filter(mlag -> mlagIds.contains(mlag.getId())) .collect(Collectors.toList()))) .filter(mc -> !mc._mlags.isEmpty()) .collect(ImmutableList.toImmutableList()); TableAnswerElement answer = new TableAnswerElement(getMetadata()); mlagConfigs.forEach( c -> c._mlags.forEach(mlag -> answer.addRow(configToRow(c._hostname, mlag)))); return answer; } MlagPropertiesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot);  }