com.github.mvysny.kaributesting.v10.groovy.IronListUtils.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of karibu-testing-v10-groovy Show documentation
Show all versions of karibu-testing-v10-groovy Show documentation
Karibu Testing, support for browserless Vaadin testing in Kotlin
package com.github.mvysny.kaributesting.v10.groovy
import com.github.mvysny.kaributesting.v10.IronListKt
import com.vaadin.flow.component.ironlist.IronList
import com.vaadin.flow.data.renderer.Renderer
import groovy.transform.CompileStatic
import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable
/**
* A set of basic extension methods for {@link IronList}.
* @author Martin Vysny
*/
@CompileStatic
class IronListUtils {
/**
* Returns the item on given row. Fails if the row index is invalid.
* @param rowIndex the row, 0..size - 1
* @return the item at given row.
* @throws AssertionError if the row index is out of bounds.
*/
@Nullable
static T _get(@NotNull IronList self,
int rowIndex) {
return IronListKt._get(self, rowIndex)
}
/**
* Fetches items from {@link IronList}'s data provider.
*/
@NotNull
static List _fetch(@NotNull IronList self, int offset, int limit) {
return IronListKt._fetch(self, offset, limit)
}
/**
* Returns all items in given data provider.
* @return the list of items.
*/
@NotNull
static List _findAll(@NotNull IronList self) {
return IronListKt._findAll(self)
}
/**
* Returns the number of items in this {@link IronList}.
*/
static int _size(@NotNull IronList> self) {
return IronListKt._size(self)
}
@NotNull
static Renderer get_renderer(@NotNull IronList self) {
return IronListKt.get_renderer(self)
}
/**
* Returns the formatted value as a String. Does not use renderer to render the value - simply calls value provider and presentation provider
* and converts the result to string (even if the result is a {@link com.vaadin.flow.component.Component}).
* @param rowIndex the row index, 0 or higher.
* @param columnId the column ID.
*/
@NotNull
static String _getFormattedRow(@NotNull IronList self, int rowIndex) {
return IronListKt._getFormattedRow(self, rowIndex)
}
/**
* Dumps given range of rows
of the IronList, formatting the values
* using the {@link #_getFormattedRow(com.vaadin.flow.component.ironlist.IronList, int)} function. The output example:
* ```
* ----------------------
* 0: John
* 1: Fred
* --and 198 more
* ```
*/
@NotNull
static String _dump(@NotNull IronList self, @NotNull IntRange rows = 0..10) {
IronListKt._dump(self, new kotlin.ranges.IntRange(rows.getFrom(), rows.getTo()))
}
static void expectRows(@NotNull IronList> self, int count) {
IronListKt.expectRows(self, count)
}
static void expectRow(@NotNull IronList> self, int rowIndex, @NotNull String row) {
IronListKt.expectRow(self, rowIndex, row)
}
}