AbstractAnalyticsService implements AnalyticsService { protected static boolean hasMetrics(CommunicationSummaryStatistics css) { if (css.getCount() > 0) { return true; } for (ConnectionStatistics cs : css.getOutbound().values()) { if (cs.getCount() > 0) { return true; } if (cs.getNode() != null) { if (hasMetrics(cs.getNode())) { return true; } } } return false; }  ConfigurationService getConfigurationService(); void setConfigurationService(ConfigurationService cs); @Override List<EndpointInfo> getUnboundEndpoints(String tenantId, long startTime, long endTime, boolean compress); @Override List<EndpointInfo> getBoundEndpoints(String tenantId, String transaction, long startTime,
                                    long endTime); @Override Collection<CommunicationSummaryStatistics> getCommunicationSummaryStatistics(String tenantId,
            Criteria criteria, boolean asTree);  }
@Test public void testHasMetricsNo() { List<CommunicationSummaryStatistics> nodes = new ArrayList<CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css1 = new CommunicationSummaryStatistics(); css1.setId("css1"); nodes.add(css1); CommunicationSummaryStatistics.ConnectionStatistics con1 = new CommunicationSummaryStatistics.ConnectionStatistics(); css1.getOutbound().put("css2", con1); CommunicationSummaryStatistics css2 = new CommunicationSummaryStatistics(); css2.setId("css2"); con1.setNode(css2); CommunicationSummaryStatistics css3 = new CommunicationSummaryStatistics(); css3.setId("css3"); nodes.add(css3); assertFalse(AbstractAnalyticsService.hasMetrics(css1)); }
@Test public void testHasMetricsYesChildNode() { List<CommunicationSummaryStatistics> nodes = new ArrayList<CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css1 = new CommunicationSummaryStatistics(); css1.setId("css1"); nodes.add(css1); CommunicationSummaryStatistics.ConnectionStatistics con1 = new CommunicationSummaryStatistics.ConnectionStatistics(); css1.getOutbound().put("css2", con1); CommunicationSummaryStatistics css2 = new CommunicationSummaryStatistics(); css2.setId("css2"); css2.setCount(1); con1.setNode(css2); CommunicationSummaryStatistics css3 = new CommunicationSummaryStatistics(); css3.setId("css3"); nodes.add(css3); assertTrue(AbstractAnalyticsService.hasMetrics(css1)); }
@Test public void testHasMetricsYesChildLink() { List<CommunicationSummaryStatistics> nodes = new ArrayList<CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css1 = new CommunicationSummaryStatistics(); css1.setId("css1"); nodes.add(css1); CommunicationSummaryStatistics.ConnectionStatistics con1 = new CommunicationSummaryStatistics.ConnectionStatistics(); con1.setCount(1); css1.getOutbound().put("css2", con1); CommunicationSummaryStatistics css2 = new CommunicationSummaryStatistics(); css2.setId("css2"); con1.setNode(css2); CommunicationSummaryStatistics css3 = new CommunicationSummaryStatistics(); css3.setId("css3"); nodes.add(css3); assertTrue(AbstractAnalyticsService.hasMetrics(css1)); }