@Override GraphDesc build(JrdsDocument n) throws InvocationTargetException { try { return makeGraphDesc(n); } catch (Exception e) { throw new InvocationTargetException(e, GraphDescBuilder.class.getName()); } }
@Test(expected = NoSuchMethodException.class) public void testBadGraphDescClass() throws Exception { JrdsDocument d = Tools.parseRessource("graphdesc.xml"); d.getRootElement().getElementbyName("graphClass").setTextContent(String.class.getName()); GraphDescBuilder gdbuild = new GraphDescBuilder(); gdbuild.setPm(Tools.makePm(testFolder)); @SuppressWarnings("unused") GraphDesc gd = gdbuild.makeGraphDesc(d); }
@Test(expected = IllegalArgumentException.class) public void testEmptyGraphDescClass() throws Exception { JrdsDocument d = Tools.parseRessource("graphdesc.xml"); d.getRootElement().getElementbyName("graphClass").setTextContent(""); GraphDescBuilder gdbuild = new GraphDescBuilder(); gdbuild.setPm(Tools.makePm(testFolder)); @SuppressWarnings("unused") GraphDesc gd = gdbuild.makeGraphDesc(d); }
@Test public void testCustomGraph() throws Exception { JrdsDocument d = Tools.parseRessource("customgraph.xml"); GraphDescBuilder gdbuild = new GraphDescBuilder(); gdbuild.setPm(Tools.makePm(testFolder)); GraphDesc gd = gdbuild.makeGraphDesc(d); Assert.assertEquals("graph name failed", "graphName", gd.getGraphName()); Assert.assertEquals("graph title failed", "", gd.getGraphTitle()); Assert.assertEquals("graph name failed", "name", gd.getName()); Assert.assertEquals("graph height invalid", 800, gd.getHeight()); Assert.assertEquals("graph width invalid", 600, gd.getWidth()); Assert.assertTrue("Lower limit is a number (not a NaN)" + gd.getUpperLimit(), Double.isNaN(gd.getUpperLimit())); Assert.assertEquals("graph lower limit is invalid", 1000, gd.getLowerLimit(), 0.1); Assert.assertFalse("graph is with legend", gd.withLegend()); Assert.assertFalse("graph is with summary", gd.withSummary()); Assert.assertEquals("legend count failed", 0, gd.getLegendLines()); }