Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchElementException from CompareMatcher#describeTo(Description) #107

Closed
chludwig-haufe opened this issue Nov 7, 2017 · 5 comments
Closed
Milestone

Comments

@chludwig-haufe
Copy link

One of our integration tests fails with a NoSuchElementException escaping from CompareMatcher#describeTo(Description). We use org.xmlunit:xmlunit-matchers:2.5.0.

In the debugger, I can see that the matcher's diffResult is != null, but diffResult.hasDifferences() == false. Since describeTo(Description) only checks for diffResult == null, the code flow enters ComparisonMatcher#firstComparison() where the subexpression diffResult.getDifferences().iterator().next() throws the NoSuchElementException.

The fix seems easy: Simply test for diffResult == null || !diffResult.hasDifferences() at the beginning of CompareMatcher#describeTo(Description).

@bodewig
Copy link
Member

bodewig commented Nov 8, 2017

Thanks a lot.

Given this hasn't come up before it seems describeTo usually isn't invoked if matches returns true, I wonder what you are doing to trigger this. :-)

Nevertheless this certainly is a bug. It's fixed on a branch of which I intend to cut 2.5.1 during the weekend.

@bodewig bodewig added this to the 2.5.1 milestone Nov 8, 2017
@chludwig-haufe
Copy link
Author

Thanks.

Since you wondered: I encountered the bug in a rest-assured body check that calls a hierarchy of delegating matchers:

// ...
 .body(isDocumentFrom(getRequestTarget())
                .thatMatches(
                    allOf(
                        metadataIsEqualTo(expectedMetaElement),
                        baselineContent(isSimilarTo(baselineControl)),
                        nativeContent(isSimilarTo(nativeControl)))));

@bodewig
Copy link
Member

bodewig commented Nov 8, 2017

Thank you. This is a slightly different incarnation of #81 - sorry for not catching the problem back then.

I've published new 2.5.1-SNAPSHOT artifacts if you need the fix before the weekend.

@bodewig bodewig closed this as completed in 5405286 Nov 9, 2017
@bodewig
Copy link
Member

bodewig commented Nov 9, 2017

carved out some time today, 2.5.1 has just been released, I'll officially announce it later.

@chludwig-haufe
Copy link
Author

Great, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants