@Test public void testGroupTraces() { Trace t1 = new Trace(ACCEPTED, ImmutableList.of()); Trace t2 = new Trace(EXITS_NETWORK, ImmutableList.of()); Trace t3 = new Trace(NEIGHBOR_UNREACHABLE, ImmutableList.of()); Trace t4 = new Trace(DENIED_IN, ImmutableList.of()); FirewallSessionTraceInfo session1 = new FirewallSessionTraceInfo( "session1", Accept.INSTANCE, ImmutableSet.of(), DUMMY_SESSION_FLOW, null); FirewallSessionTraceInfo session2 = new FirewallSessionTraceInfo( "session2", Accept.INSTANCE, ImmutableSet.of(), DUMMY_SESSION_FLOW, null); { BidirectionalTrace bt1 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(), REVERSE_FLOW, t3); BidirectionalTrace bt2 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(), REVERSE_FLOW, t4); BidirectionalTrace bt3 = new BidirectionalTrace(FORWARD_FLOW, t2, ImmutableSet.of(), REVERSE_FLOW, t3); BidirectionalTrace bt4 = new BidirectionalTrace(FORWARD_FLOW, t2, ImmutableSet.of(), REVERSE_FLOW, t4); List<BidirectionalTrace> bts = ImmutableList.of(bt1, bt2, bt3, bt4); assertThat(groupTraces(bts), hasEntry(equalTo(bt1.getKey()), equalTo(bts))); } { BidirectionalTrace bt1 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(), REVERSE_FLOW, t2); BidirectionalTrace bt2 = new BidirectionalTrace(REVERSE_FLOW, t1, ImmutableSet.of(), REVERSE_FLOW, t2); assertThat( groupTraces(ImmutableList.of(bt1, bt2)), equalTo( ImmutableMap.of( bt1.getKey(), ImmutableList.of(bt1), bt2.getKey(), ImmutableList.of(bt2)))); } { BidirectionalTrace bt1 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(), REVERSE_FLOW, t2); BidirectionalTrace bt2 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(session1), REVERSE_FLOW, t2); assertThat( groupTraces(ImmutableList.of(bt1, bt2)), equalTo( ImmutableMap.of( bt1.getKey(), ImmutableList.of(bt1), bt2.getKey(), ImmutableList.of(bt2)))); } { BidirectionalTrace bt1 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(session1), REVERSE_FLOW, t2); BidirectionalTrace bt2 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(session2), REVERSE_FLOW, t2); assertThat( groupTraces(ImmutableList.of(bt1, bt2)), equalTo( ImmutableMap.of( bt1.getKey(), ImmutableList.of(bt1), bt2.getKey(), ImmutableList.of(bt2)))); } { BidirectionalTrace bt1 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(), REVERSE_FLOW, t2); BidirectionalTrace bt2 = new BidirectionalTrace(FORWARD_FLOW, t1, ImmutableSet.of(), FORWARD_FLOW, t2); assertThat( groupTraces(ImmutableList.of(bt1, bt2)), equalTo( ImmutableMap.of( bt1.getKey(), ImmutableList.of(bt1), bt2.getKey(), ImmutableList.of(bt2)))); } }
@VisibleForTesting static Map<BidirectionalTrace.Key, List<BidirectionalTrace>> groupTraces( List<BidirectionalTrace> traces) { return traces.stream() .collect(Collectors.groupingBy(BidirectionalTrace::getKey, Collectors.toList())); }
BidirectionalTracerouteAnswerer extends Answerer { @VisibleForTesting static Map<BidirectionalTrace.Key, List<BidirectionalTrace>> groupTraces( List<BidirectionalTrace> traces) { return traces.stream() .collect(Collectors.groupingBy(BidirectionalTrace::getKey, Collectors.toList())); } }
BidirectionalTracerouteAnswerer extends Answerer { @VisibleForTesting static Map<BidirectionalTrace.Key, List<BidirectionalTrace>> groupTraces( List<BidirectionalTrace> traces) { return traces.stream() .collect(Collectors.groupingBy(BidirectionalTrace::getKey, Collectors.toList())); } BidirectionalTracerouteAnswerer(Question question, IBatfish batfish); }
BidirectionalTracerouteAnswerer extends Answerer { @VisibleForTesting static Map<BidirectionalTrace.Key, List<BidirectionalTrace>> groupTraces( List<BidirectionalTrace> traces) { return traces.stream() .collect(Collectors.groupingBy(BidirectionalTrace::getKey, Collectors.toList())); } BidirectionalTracerouteAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); static AnswerElement bidirectionalTracerouteAnswerElement(
      Question question,
      Set<Flow> flows,
      TracerouteEngine tracerouteEngine,
      boolean ignoreFilters,
      @Nullable Integer maxTraces); static TableMetadata metadata(); }
BidirectionalTracerouteAnswerer extends Answerer { @VisibleForTesting static Map<BidirectionalTrace.Key, List<BidirectionalTrace>> groupTraces( List<BidirectionalTrace> traces) { return traces.stream() .collect(Collectors.groupingBy(BidirectionalTrace::getKey, Collectors.toList())); } BidirectionalTracerouteAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); static AnswerElement bidirectionalTracerouteAnswerElement(
      Question question,
      Set<Flow> flows,
      TracerouteEngine tracerouteEngine,
      boolean ignoreFilters,
      @Nullable Integer maxTraces); static TableMetadata metadata();  }