com.vaadin.flow.component.virtuallist.

Class VirtualListTester<T extends VirtualList<Y>,Y>

java.lang.Object
com.vaadin.testbench.unit.ComponentTester<T>
com.vaadin.flow.component.virtuallist.VirtualListTester<T,Y>

Type Parameters:

T - component type

Y - value type

public class VirtualListTester<T extends VirtualList<Y>,Y> extends ComponentTester<T>

Tester for VirtualList components.

  • Constructor Details

    • VirtualListTester

      public VirtualListTester(T component)

      Wrap given component for testing.

      Parameters:

      component - target component

  • Method Details

    • size

      public int size()

      Get the amount of items in the virtual list.

      Returns:

      number of items in the virtual list

    • getItem

      public Y getItem(int index)

      Get the item at the given index.

      Parameters:

      index - the zero-based index of the item to get

      Returns:

      virtual list item at index

    • getItemText

      public String getItemText(int index)

      Get the text that is shown on the client for the item at index.

      The index is zero-based.

      For the default renderer ColumnPathRenderer the result is the sent text for defined object path.

      For a ComponentRenderer the result is the rendered component as prettyString.

      More to be added as we find other renderers that need handling.

      Parameters:

      index - the zero-based index of the item

      Returns:

      item content that is sent to the client

    • getItemComponent

      public Component getItemComponent(int index)

      Get an initialized copy of the component for the item.

      Note, this is not the actual component.

      Parameters:

      index - the zero-based index of the item

      Returns:

      initialized component for the target item

      Throws:

      IllegalArgumentException - when the VirtualList is not using a ComponentRenderer

    • getLitRendererPropertyValue

      public <V> V getLitRendererPropertyValue(int index, String propertyName, Class<V> propertyClass)

      Get property value for item's LitRenderer.

      Type Parameters:

      V - the type of the LitRenderer property

      Parameters:

      index - the zero-based index of the item

      propertyName - the name of the LitRenderer property

      propertyClass - the class of the value of the LitRenderer property

      Returns:

      value of the LitRenderer property

      Throws:

      IllegalArgumentException - when the VirtualList is not using a LitRenderer or when the given type of the property does not match the actual property type

    • invokeLitRendererFunction

      public void invokeLitRendererFunction(int index, String functionName, elemental.json.JsonArray jsonArray)

      Invoke named function for item's LitRenderer using the supplied JSON arguments.

      Parameters:

      index - the zero-based index of the item

      functionName - the name of the LitRenderer function to invoke

      jsonArray - the arguments to pass to the function

      Throws:

      IllegalArgumentException - when the VirtualList is not using a LitRenderer

      See Also:

    • invokeLitRendererFunction

      public void invokeLitRendererFunction(int index, String functionName)

      Invoke named function for item's LitRenderer.

      Parameters:

      index - the zero-based index of the item

      functionName - the name of the LitRenderer function to invoke

      Throws:

      IllegalArgumentException - when the VirtualList is not using a LitRenderer

      See Also: