xlsx-matchers is an elegant object-oriented hamcrest matchers for Apache POI.
Design principles behind xlsx-matchers.
Get the latest version here:
<dependency>
<groupId>io.github.dgroup</groupId>
<artifactId>xlsx-matchers</artifactId>
<version>${version}</version>
</dependency>
Java version required: 1.8+.
All examples below are using the following frameworks/libs:
- Hamcrest - Library of matchers, which can be combined in to create flexible expressions of intent in tests.
- cactoos - Object-Oriented Java primitives, as an alternative to Google Guava and Apache Commons.
- cactoos-matchers - Object-Oriented Hamcrest matchers
Ensure that particular Apache POI row has cells with the required data:
// Testing prerequisites
final XSSFRow row = new XSSFWorkbook().createSheet().createRow(1);
final XSSFCell name = row.createCell(0);
name.setCellValue("Name");
final XSSFCell birth = row.createCell(1);
birth.setCellValue("Birth");
final XSSFCell phone = row.createCell(2);
phone.setCellValue("Phone");
// Testing ...
MatcherAssert.assertThat(
"The mather matches row with all required cells",
row,
new HasCells<>(
new CellOf<>(0, "Name"),
new CellOf<>(1, "Birth"),
new CellOf<>(2, "Phone")
)
);
// or in cactoos-matchers way
new Assertion<>(
"The mather matches row with all required cells",
row,
new HasCells<>(
new CellOf<>(0, "Name"),
new CellOf<>(1, "Birth"),
new CellOf<>(2, "Phone")
)
).affirm();