Skip to content

Elegant object-oriented hamcrest matchers for Apache POI

License

Notifications You must be signed in to change notification settings

dgroup/xlsx-matchers

Repository files navigation

Maven Javadocs License: MIT Commit activity Hits-of-Code

Build Status 0pdd Dependencies Status Known Vulnerabilities

DevOps By Rultor.com EO badge We recommend IntelliJ IDEA

Qulice SQ maintainability Codebeat Codacy Badge Codecov

What it is

xlsx-matchers is an elegant object-oriented hamcrest matchers for Apache POI.

Principles

Design principles behind xlsx-matchers.

How to use

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();