https://github.com/dgroup/xlsx-matchers
Elegant object-oriented hamcrest matchers for Apache POI
https://github.com/dgroup/xlsx-matchers
apache-poi elegantobjects excel hamcrest hamcrest-matchers java poi tdd tdd-java testing unit-testing
Last synced: about 2 months ago
JSON representation
Elegant object-oriented hamcrest matchers for Apache POI
- Host: GitHub
- URL: https://github.com/dgroup/xlsx-matchers
- Owner: dgroup
- License: mit
- Created: 2019-12-01T15:42:23.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-29T17:50:48.000Z (almost 3 years ago)
- Last Synced: 2025-02-26T19:52:10.374Z (2 months ago)
- Topics: apache-poi, elegantobjects, excel, hamcrest, hamcrest-matchers, java, poi, tdd, tdd-java, testing, unit-testing
- Language: Java
- Size: 93.8 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
[](https://mvnrepository.com/artifact/io.github.dgroup/xlsx-matchers)
[](http://www.javadoc.io/doc/io.github.dgroup/xlsx-matchers)
[](./license.txt)
[](https://github.com/dgroup/xlsx-matchers/graphs/commit-activity)
[](https://hitsofcode.com/view/github/dgroup/xlsx-matchers)[](https://circleci.com/gh/dgroup/xlsx-matchers)
[](http://www.0pdd.com/p?name=dgroup/xlsx-matchers)
[](https://requires.io/github/dgroup/xlsx-matchers/requirements/?branch=master)
[](https://snyk.io/test/github/dgroup/xlsx-matchers)[](http://www.rultor.com/p/dgroup/xlsx-matchers)
[](http://www.elegantobjects.org/#principles)
[](https://www.jetbrains.com/idea/)[](http://www.qulice.com/)
[](https://sonarcloud.io/dashboard?id=io.github.dgroup%3Axlsx-matchers)
[](https://codebeat.co/projects/github-com-dgroup-xlsx-matchers-master)
[](https://www.codacy.com/manual/dgroup/xlsx-matchers?utm_source=github.com&utm_medium=referral&utm_content=dgroup/xlsx-matchers&utm_campaign=Badge_Grade)
[](https://codecov.io/gh/dgroup/xlsx-matchers)## What it is
**xlsx-matchers** is an elegant object-oriented hamcrest matchers for Apache POI.## Principles
[Design principles](http://www.elegantobjects.org#principles) behind xlsx-matchers.## How to use
Get the latest version [here](https://github.com/dgroup/xlsx-matchers/releases):```xml
io.github.dgroup
xlsx-matchers
${version}```
Java version required: 1.8+.
All examples below are using the following frameworks/libs:
- [Hamcrest](https://github.com/hamcrest/JavaHamcrest) - Library of matchers, which can be combined in to create flexible expressions of intent in tests.
- [cactoos](https://github.com/yegor256/cactoos) - Object-Oriented Java primitives, as an alternative to Google Guava and Apache Commons.
- [cactoos-matchers](https://github.com/yegor256/cactoos) - Object-Oriented Hamcrest matchers#### [HasCells](src/main/java/io/github/dgroup/xlsx/cell/HasCells.java)
Ensure that particular Apache POI row has cells with the required data:
```java
// 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();
```