Package com.vaadin.testbench.unit
Class LitRendererTestUtil
java.lang.Object
com.vaadin.testbench.unit.LitRendererTestUtil
Utility methods for unit testing properties and functions of LitRenderers.
-
Method Summary
Modifier and TypeMethodDescriptiongetFunctionNames(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter) Gets the function names for the suppliedLitRendererusing the given field getter.getProperties(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter) Gets the property names for the suppliedLitRendererusing the given field getter.static <Y,V> V getPropertyValue(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter, IntFunction<Y> itemGetter, int index, String propertyName, Class<V> propertyClass) Gets the property value for the suppliedLitRenderer.static <Y> voidinvokeFunction(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter, IntFunction<Y> itemGetter, int index, String functionName, elemental.json.JsonArray jsonArray) Invokes the function by name for the suppliedLitRendererusing the given field getter.
-
Method Details
-
getProperties
public static <Y> Set<String> getProperties(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter) Gets the property names for the suppliedLitRendererusing the given field getter.- Type Parameters:
Y- the type being renderer by the LitRenderer- Parameters:
litRenderer- the LitRenderer with properties to getfieldGetter- the field getter of the ComponentTester- Returns:
- the set of property names of the LitRenderer
-
getPropertyValue
public static <Y,V> V getPropertyValue(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter, IntFunction<Y> itemGetter, int index, String propertyName, Class<V> propertyClass) Gets the property value for the suppliedLitRenderer.- Type Parameters:
Y- the type being renderer by the LitRendererV- the type of the property value- Parameters:
litRenderer- the LitRenderer with properties to getfieldGetter- the field getter of the ComponentTesteritemGetter- the getter for the item rendered by the LitRendererindex- the index of the item rendered by the LitRendererpropertyName- the name of the property of the LitRendererpropertyClass- the type of the property value- Returns:
- the property value
- Throws:
IllegalArgumentException- when the type of property value does not match propertyClass
-
getFunctionNames
public static <Y> Set<String> getFunctionNames(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter) Gets the function names for the suppliedLitRendererusing the given field getter.- Type Parameters:
Y- the type being renderer by the LitRenderer- Parameters:
litRenderer- the LitRenderer with properties to getfieldGetter- the field getter of the ComponentTester- Returns:
- the set of function names of the LitRenderer
-
invokeFunction
public static <Y> void invokeFunction(LitRenderer<Y> litRenderer, BiFunction<Class<?>, String, Field> fieldGetter, IntFunction<Y> itemGetter, int index, String functionName, elemental.json.JsonArray jsonArray) Invokes the function by name for the suppliedLitRendererusing the given field getter.- Type Parameters:
Y- the type being renderer by the LitRenderer- Parameters:
litRenderer- the LitRenderer with properties to getfieldGetter- the field getter of the ComponentTesteritemGetter- the getter for the item rendered by the LitRendererindex- the index of the item rendered by the LitRendererfunctionName- the name of the function of the LitRendererjsonArray- additional parameters to pass to the function- Throws:
IllegalArgumentException- when the function is not registered in LitRenderer
-