use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.
the class ChartDesignWriterTest method writeConfiguration_emptyObject_nothingIsAddedToParentElement.
@Test
public void writeConfiguration_emptyObject_nothingIsAddedToParentElement() {
DesignContext designContext = new DesignContext();
Configuration configuration = new Configuration();
Element parent = new Element(Tag.valueOf("test"), "");
ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
assertEquals("<test></test>", parent.toString());
}
use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.
the class ChartDesignWriterTest method writeConfiguration_enableDataLabelsInPlotoptions_plotOptionsElementHasInnerTypeElement.
@Test
public void writeConfiguration_enableDataLabelsInPlotoptions_plotOptionsElementHasInnerTypeElement() {
DesignContext designContext = new DesignContext();
Configuration configuration = new Configuration();
DataLabels dataLabels = new DataLabels(true);
PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
plotOptionsLine.setDataLabels(dataLabels);
configuration.setPlotOptions(plotOptionsLine);
Element parent = new Element(Tag.valueOf("test"), "");
ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
assertEquals("<plot-options><line><data-labels enabled></data-labels></line></plot-options>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.
the class ChartDesignWriterTest method writeConfiguration_arrayNode_theValuesInArrayAreSeparatedWithComma.
@Test
public void writeConfiguration_arrayNode_theValuesInArrayAreSeparatedWithComma() {
DesignContext designContext = new DesignContext();
Configuration configuration = new Configuration();
configuration.getxAxis().setCategories("Jan", "Feb", "Mar");
Element parent = new Element(Tag.valueOf("test"), "");
ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
assertEquals("<x-axis><categories>Jan, Feb, Mar</categories></x-axis>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.
the class ChartDesignWriterTest method writeConfiguration_numberValueDefinedInConfiguration_theValueIsAddedAsAttribute.
@Test
public void writeConfiguration_numberValueDefinedInConfiguration_theValueIsAddedAsAttribute() {
DesignContext designContext = new DesignContext();
Configuration configuration = new Configuration();
Legend legend = new Legend();
legend.setY(100);
configuration.setLegend(legend);
Element parent = new Element(Tag.valueOf("test"), "");
ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
assertEquals("<legend y=\"100\"></legend>", parent.child(0).toString());
}
use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.
the class ChartDesignWriterTest method writeConfiguration_plotLines_thePlotLinesAreTheElement.
@Test
public void writeConfiguration_plotLines_thePlotLinesAreTheElement() {
DesignContext designContext = new DesignContext();
Configuration configuration = new Configuration();
PlotLine plotLine = new PlotLine();
plotLine.setValue(0);
plotLine.setWidth(2);
configuration.getyAxis().setPlotLines(plotLine);
Element parent = new Element(Tag.valueOf("test"), "");
ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
assertEquals("<y-axis><plot-lines value=\"0\" width=\"2\"></plot-lines></y-axis>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
Aggregations