LineGraph implements HighChart { @Override public String toHighChartsSeries() { StringBuilder arrayBuilder = new StringBuilder("["); int size = points.size(); Long lastX = null; for (int i = 0; i < size; i++) { Point point = points.get(i); Double y = point.getY(); long date = (long) point.getX(); if (displayGaps && lastX != null && date - lastX > TimeUnit.MINUTES.toMillis(3L)) { addMissingPoints(arrayBuilder, lastX, date); } lastX = date; arrayBuilder.append("[").append(date).append(",").append(y).append("]"); if (i < size - 1) { arrayBuilder.append(","); } } arrayBuilder.append("]"); return arrayBuilder.toString(); } LineGraph(List<Point> points, boolean displayGaps); @Override String toHighChartsSeries(); List<Point> getPoints();  }
@Test void testLineGraphsForBracketErrors() { TPSMutator mutator = new TPSMutator(DATA); LineGraph[] graphs = new LineGraph[]{ new CPUGraph(mutator, true), new PlayersOnlineGraph(mutator, false), new RamGraph(mutator, true), new TPSGraph(mutator, false), new EntityGraph(mutator, true), new ChunkGraph(mutator, false), new DiskGraph(mutator, false) }; for (LineGraph graph : graphs) { System.out.print("Bracket Test: " + graph.getClass().getSimpleName() + " | "); String series = graph.toHighChartsSeries(); System.out.println(series); char[] chars = series.toCharArray(); assertBracketMatch(chars); } }