CommunicationSeverityAnalyser { protected static void deriveSeverity(CommunicationSummaryStatistics css, long max, Map<String, CommunicationSummaryStatistics> nodeMap) { max = findParentsMaxAvgDuration(css, max, nodeMap); int relative = (int) (css.getAverageDuration() * 10.0 / max); if (relative >= 10) { css.setSeverity(MAX_SEVERITY); } else if (relative <= 1) { css.setSeverity(0); } else { relative -= 1; css.setSeverity(((int) (relative * 0.5)) + 1); if (css.getSeverity() > MAX_SEVERITY) { css.setSeverity(MAX_SEVERITY); } } }  void evaluateCommunicationSummarySeverity(Collection<CommunicationSummaryStatistics> nodes);  }
@Test public void testDeriveSeverityOverMax() { Map<String,CommunicationSummaryStatistics> nodes=new HashMap<String,CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css = new CommunicationSummaryStatistics(); css.setId("css1"); css.setAverageDuration(1300); nodes.put(css.getId(), css); long max = 1000; CommunicationSeverityAnalyser.deriveSeverity(css, max, nodes); assertEquals(5, css.getSeverity()); }
@Test public void testDeriveSeverityMid1() { Map<String,CommunicationSummaryStatistics> nodes=new HashMap<String,CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css = new CommunicationSummaryStatistics(); css.setId("css1"); css.setAverageDuration(700); nodes.put(css.getId(), css); long max = 1000; CommunicationSeverityAnalyser.deriveSeverity(css, max, nodes); assertEquals(4, css.getSeverity()); }
@Test public void testDeriveSeverityMid2() { Map<String,CommunicationSummaryStatistics> nodes=new HashMap<String,CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css = new CommunicationSummaryStatistics(); css.setId("css1"); css.setAverageDuration(500); nodes.put(css.getId(), css); long max = 1000; CommunicationSeverityAnalyser.deriveSeverity(css, max, nodes); assertEquals(3, css.getSeverity()); }
@Test public void testDeriveSeverityMid3() { Map<String,CommunicationSummaryStatistics> nodes=new HashMap<String,CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css = new CommunicationSummaryStatistics(); css.setId("css1"); css.setAverageDuration(597); nodes.put(css.getId(), css); long max = 1789; CommunicationSeverityAnalyser.deriveSeverity(css, max, nodes); assertEquals(2, css.getSeverity()); }
@Test public void testDeriveSeverityMax() { Map<String,CommunicationSummaryStatistics> nodes=new HashMap<String,CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css = new CommunicationSummaryStatistics(); css.setId("css1"); css.setAverageDuration(1000); nodes.put(css.getId(), css); long max = 1000; CommunicationSeverityAnalyser.deriveSeverity(css, max, nodes); assertEquals(5, css.getSeverity()); }
@Test public void testDeriveSeverityMin() { Map<String,CommunicationSummaryStatistics> nodes=new HashMap<String,CommunicationSummaryStatistics>(); CommunicationSummaryStatistics css = new CommunicationSummaryStatistics(); css.setId("css1"); css.setAverageDuration(100); nodes.put(css.getId(), css); long max = 1000; CommunicationSeverityAnalyser.deriveSeverity(css, max, nodes); assertEquals(0, css.getSeverity()); }