use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignWriterTest method writeConfiguration_multiplePlotOptions_allPlotOptionsAreChildrenOfPlotOptionsTag.
@Test
public void writeConfiguration_multiplePlotOptions_allPlotOptionsAreChildrenOfPlotOptionsTag() {
DesignContext designContext = new DesignContext();
Configuration configuration = new Configuration();
PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
plotOptionsLine.setAnimation(false);
PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
plotOptionsSpline.setVisible(false);
configuration.setPlotOptions(plotOptionsLine, plotOptionsSpline);
Element parent = new Element(Tag.valueOf("test"), "");
ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
// Expected (the order of plot options is unknown):
// "<plot-options>
// <line animation=\"false\">
// </line>
// <spline visible=\"false\">
// </spline>
// </plot-options>"
assertEquals("plot-options", parent.child(0).tagName());
Elements plotOptions = parent.child(0).children();
assertEquals(2, plotOptions.size());
assertPlotOptions("line", "animation", "false", plotOptions);
assertPlotOptions("spline", "visible", "false", plotOptions);
}
use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_axisTitleHasTextOnlyContent_theContentIsSetAsTitleText.
@Test
public void readConfiguration_axisTitleHasTextOnlyContent_theContentIsSetAsTitleText() {
Elements elements = createElements("<y-axis><chart-title>my title</chart-title></y-axis>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
assertEquals("my title", configuration.getyAxis().getTitle().getText());
}
use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_multiplePlotOptions_attributesAreReadToCorrectPlotOptions.
@Test
public void readConfiguration_multiplePlotOptions_attributesAreReadToCorrectPlotOptions() {
Elements elements = createElements("<plot-options>" + "<line animation=\"true\"></line>" + "<spline animation=\"false\"></spline>" + "</plot-options>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
PlotOptionsLine line = (PlotOptionsLine) configuration.getPlotOptions(ChartType.LINE);
PlotOptionsSpline spline = (PlotOptionsSpline) configuration.getPlotOptions(ChartType.SPLINE);
assertFalse(spline.getAnimation());
assertTrue(line.getAnimation());
}
use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_multiplePlotOptions_plotOptionsLineIsAddedToConfiguration.
@Test
public void readConfiguration_multiplePlotOptions_plotOptionsLineIsAddedToConfiguration() {
Elements elements = createElements("<plot-options><line></line><spline></spline></plot-options>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
assertEquals(2, configuration.getPlotOptions().size());
assertThat(configuration.getPlotOptions(ChartType.LINE), instanceOf(PlotOptionsLine.class));
assertThat(configuration.getPlotOptions(ChartType.SPLINE), instanceOf(PlotOptionsSpline.class));
}
use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_titleWithStyleAsInnerElement_theTitleAndStyleAreInConfiguration.
@Test
public void readConfiguration_titleWithStyleAsInnerElement_theTitleAndStyleAreInConfiguration() {
Elements elements = createElements("<chart-title text=\"foobar\"><chart-style top=\"12\"></chart-style></chart-title>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
assertEquals("12", configuration.getTitle().getStyle().getTop());
assertEquals("foobar", configuration.getTitle().getText());
}
Aggregations