0

I'm trying to use isEqualToComparingFieldByFieldRecursively from AssertJ to compare HSSFWorkbooks from Apache POI

However when I try to use it with a HSSFWorkbook it does not work:

    HSSFWorkbook wb1 = new HSSFWorkbook();
    HSSFWorkbook wb2 = new HSSFWorkbook();

    assertThat(wb1).isEqualToComparingFieldByFieldRecursively(wb2);

I am not able to use the isEqualToComparingFieldByFieldRecursively method: enter image description here

It looks like since HSSFWorkbook implements Iterable assertThat(wb1) returns a IterableAssert which does not have isEqualToComparingFieldByFieldRecursively like ObjectAssert does.

If I cast the HSSFWorkbook to Object that it will act the correct way but the same problem occurs for the other Apache POI classes (HSSFSheet and HSSFRow). What is the cleanest way to force AssertJ to only use ObjectAssert?

ciferkey
  • 2,064
  • 3
  • 20
  • 28

1 Answers1

0

You can give a try to usingRecursiveFieldByFieldElementComparator, it should be available as HSSFWorkbook is an Iterable.

If it does not work, can you add a comment to https://github.com/joel-costigliola/assertj-core/issues/1002 to get support for your use case in the upcoming recursive comparison api for AssertJ.

Joel Costigliola
  • 6,308
  • 27
  • 35