-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Fix failing SetProcessorTests.testCopyFromOtherField test #70150
Fix failing SetProcessorTests.testCopyFromOtherField test #70150
Conversation
Pinging @elastic/es-core-features (Team:Core/Features) |
private static void assertMapEquals(Object actual, Object expected) { | ||
if (expected instanceof Map) { | ||
Map<?, ?> expectedMap = (Map<?, ?>) expected; | ||
Map<?, ?> actualMap = (Map<?, ?>) actual; | ||
assertThat(actualMap.keySet().toArray(), arrayContainingInAnyOrder(expectedMap.keySet().toArray())); | ||
for (Map.Entry<?, ?> entry : actualMap.entrySet()) { | ||
if (entry.getValue() instanceof Map) { | ||
assertMapEquals(entry.getValue(), expectedMap.get(entry.getKey())); | ||
} else { | ||
assertThat(entry.getValue(), equalTo(expectedMap.get(entry.getKey()))); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be happy if there were some Hamcrest magic that did this "deep-compare" of objects within maps automatically, but I couldn't find anything along those lines.
@elasticmachine update branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks, @dakrone! |
Fixes two problems with the
testCopyFromOtherField
test -- it should not choose a sub-object of the copy_from field as the target field and it should "deep-compare" any copied objects contained within maps as they will not be reference-equal after the fix in #69349.Fixes #69876.