[ 
https://issues.apache.org/jira/browse/SLING-12833?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Konrad Windszus resolved SLING-12833.
-------------------------------------
    Fix Version/s: Testing Hamcrest 1.1.0
       Resolution: Fixed

Fixed in 
https://github.com/apache/sling-org-apache-sling-testing-hamcrest/commit/2d645c914ded3cea54e7e8dc9bac82cbce579624.

> Better description of mismatch in ResourcePropertiesMatcher
> -----------------------------------------------------------
>
>                 Key: SLING-12833
>                 URL: https://issues.apache.org/jira/browse/SLING-12833
>             Project: Sling
>          Issue Type: Improvement
>          Components: Testing
>    Affects Versions: Testing Hamcrest 1.0.2
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>            Priority: Major
>             Fix For: Testing Hamcrest 1.1.0
>
>
> When using ResourcePropertiesMatcher with lots of properties it is hard to 
> spot the actual difference from the output message. It should highlight
> - the first property name where a difference occurs
> - the expected value and type vs the actual value and type for that property
> Current example output of 1.0.2
> {code}
> java.lang.AssertionError: 
> Expected: Resource with properties 
> [<dictionaryPath=/content/dictionaries/fruit/i18n>,<editable=true>,<en=foo>,<escapedKey=test\r\n%&special··test\t·characters>,<key=test
> %&special  test        
> characters>,<languages=[en,nl_BE]>,<messageEntryPaths=[/content/dictionaries/fruit/i18n/en/specialkey]>,<validationMessages=[]>]
>      but: was Resource with properties 
> [<dictionaryPath=/content/dictionaries/fruit/i18n>,<editable=true>,<en=foo>,<escapedKey=test\r\n%&special··test\t·characters>,<key=test
> %&special  test        
> characters>,<languages=[en,nl_BE]>,<messageEntryPaths=[/content/dictionaries/fruit/i18n/en/specialkey]>,<validationMessages=[]>]
>  (resource: <ValueMapResource, 
> type=aem-dictionary-translator/components/combining-message-entry, 
> path=/mnt/dictionary/content/dictionaries/fruit/i18n/test\u000D\u000A\u0025&special
>   test     characters>)
>       at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
>       at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
>       at 
> be.orbinson.aem.dictionarytranslator.services.impl.CombiningMessageEntryResourceProviderTest.syntheticMessageEntryPathShouldReturnProperResource(CombiningMessageEntryResourceProviderTest.java:109)
>       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>       at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
>       at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
> {code}
> Proposed improved Output
> {code}
> java.lang.AssertionError: 
> Expected: Resource with properties 
> [<dictionaryPath=/content/dictionaries/fruit/i18n>,<editable=true>,<en=foo>,<escapedKey=test\r\n%&special··test\t·characters>,<key=test
> %&special  test        
> characters>,<languages=[en,nl_BE]>,<messageEntryPaths=[/content/dictionaries/fruit/i18n/en/specialkey]>,<validationMessages=[]>]
>      but: was Resource with properties 
> [<dictionaryPath=/content/dictionaries/fruit/i18n>,<editable=true>,<en=foo>,<escapedKey=test\r\n%&special··test\t·characters>,<key=test
> %&special  test        
> characters>,<languages=[en,nl_BE]>,<messageEntryPaths=[/content/dictionaries/fruit/i18n/en/specialkey]>,<validationMessages=[]>]
>  (resource: <ValueMapResource, 
> type=aem-dictionary-translator/components/combining-message-entry, 
> path=/mnt/dictionary/content/dictionaries/fruit/i18n/test\u000D\u000A\u0025&special
>   test     characters>)
>      First mismatch in property "validationMessages": expected value [] of 
> type "[Ljava.lang.String;" but was value <[]> of type "java.util.TreeSet"
>       at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
>       at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
>       at 
> be.orbinson.aem.dictionarytranslator.services.impl.CombiningMessageEntryResourceProviderTest.syntheticMessageEntryPathShouldReturnProperResource(CombiningMessageEntryResourceProviderTest.java:109)
>       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>       at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
>       at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to