Class ChartTester<T extends Chart>

java.lang.Object
com.vaadin.testbench.unit.ComponentTester<T>
com.vaadin.flow.component.charts.ChartTester<T>
Type Parameters:
T - component type

public class ChartTester<T extends Chart> extends ComponentTester<T>
Tester for Chart components.
  • Constructor Details

    • ChartTester

      public ChartTester(T component)
      Wrap given component for testing.
      Parameters:
      component - target component
  • Method Details

    • getSeriesValues

      public List<Number> getSeriesValues(int seriesIndex)
      Gets the values for the series at given index. At the moment only ListSeries, DataSeries and DataProviderSeries are supported. For all other series types an exception will be thrown. For DataProviderSeries Y value is expected to be a Number subtype.
      Parameters:
      seriesIndex - zero-based index of the series
      Returns:
      the list of values for the series.
      Throws:
      IndexOutOfBoundsException - if series for the given index does not exist.
      UnsupportedOperationException - if the chart series at give index is not supported.
    • getSeriesValues

      public List<Number> getSeriesValues(String seriesName)
      Gets the values for the series with the given name. At the moment only ListSeries, DataSeries and DataProviderSeries are supported. For all other series types an exception will be thrown. For DataProviderSeries Y value is expected to be a Number subtype.
      Parameters:
      seriesName - name of the series
      Returns:
      the list of values for the series.
      Throws:
      UnsupportedOperationException - if the chart series at give index is not supported.
    • getPointValue

      public Number getPointValue(int seriesIndex, String name)
      Gets the value of the point with given name from the series at given index. The name depends on the series type. For ListSeries it is expected to refer to an X-Axis category, for DataSeries it refers to the item name, for DataProviderSeries it is matched against the value of the configured x attribute. At the moment only ListSeries, DataSeries and DataProviderSeries are supported. For all other series types an exception will be thrown.
      Parameters:
      seriesIndex - zero-based index of the series
      name - name of the point in the series
      Returns:
      the value of the point at given coordinates.
    • getPointValue

      public Number getPointValue(String seriesName, String name)
      Gets the value of the point with given name from the series at given index. The name depends on the series type. For ListSeries it is expected to refer to an X-Axis category, for DataSeries it refers to the item name, for DataProviderSeries it is matched against the value of the configured x attribute. At the moment only ListSeries, DataSeries and DataProviderSeries are supported. For all other series types an exception will be thrown.
      Parameters:
      seriesName - name of the series
      name - name of the point in the series
      Returns:
      the value of the point at given coordinates.
    • clickLegendItem

      public void clickLegendItem(String item)
      Simulates a click on the item of the legend with the given text. Current limitation: it assumes the text corresponds to a series name.
      Parameters:
      item - legend item
    • clickPoint

      public void clickPoint(String seriesName, String name)
      Simulates a click on a point on the chart.
      Parameters:
      seriesName - name of the series
      name - name of the point in the series
    • clickChart

      public void clickChart()
      Simulates a click on the chart, but not on legend items or points.