MetricsUtils { public static TopologySummary getTopologySummary(ClusterSummary cs, String name) { for (TopologySummary ts : cs.get_topologies()) { if (name.equals(ts.get_name())) { return ts; } } return null; } private  MetricsUtils(); static void addLatency(Map<String, List<Double>> stats, String id, double lat); static TopologySummary getTopologySummary(ClusterSummary cs, String name); static double getSpoutCompleteLatency(SpoutStats stats, String window, String stream); static long getSpoutAcked(SpoutStats stats, String window, String stream); static long getTransferred(ExecutorStats stats, String window, String stream); static double getThroughput(double throughputDiff, long timeDiff); static double getThroughputMB(double throughputDiff, long timeDiff, int msgSize);  }
@Test public void testGetTopologySummary() { ClusterSummary cs = mock(ClusterSummary.class); TopologySummary ts = mock(TopologySummary.class); String tsName = "benchmarks"; String fakeName = "fake"; when(cs.get_topologies()).thenReturn(Lists.newArrayList(ts)); when(ts.get_name()).thenReturn(tsName); assertThat(MetricsUtils.getTopologySummary(cs, tsName)).isEqualTo(ts); assertThat(MetricsUtils.getTopologySummary(cs, fakeName)).isNull(); }