Skip to content

withNodeFilter silently overwrites previous set NodeFilter, should throw exception #249

@geertschuring

Description

@geertschuring

The documentation for CompareMatcher.withNodeFilter(...) says Registers a filter for nodes so I created two nodefilters and used them like this:

assertThat(actualMessage, isSimilarTo(expectedMessage)
	.withNodeFilter(new NodeFilterA())
	.withNodeFilter(new NodeFilterB())
);

When this did not work as expected I thought my implementation of the Predicate was incorrect. Only after randomly trying to change things I figured out that only 1 Predicate could be registered as NodeFilter and the documentation was incorrect, or at least incomplete. It should read Registers the filter for nodes or Registers and overwrites the filter for nodes.
Also, when called multiple times it should throw an exception explaining that a second call would overwrite the previously set filter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions