Skip to content

Add TypeMatcher in xmlunit-matchers#137

Merged
bodewig merged 6 commits into
masterfrom
type-matcher
Aug 24, 2018
Merged

Add TypeMatcher in xmlunit-matchers#137
bodewig merged 6 commits into
masterfrom
type-matcher

Conversation

@krystiankaluzny

Copy link
Copy Markdown
Member

TypeMatcher allows to check if an examined string value can be converted to specified type and perform matching on the converted value.
For now 4 types are support: BigDecimal, Double, Integer and Boolean
This feature is response on #133 and works well with EvaluateXPathMatcher:

assertThat(xml, hasXPath("count(//fruits/fruit)", asBigDecimal(is(greaterThan(BigDecimal.ONE)))));

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.05%) to 91.982% when pulling a2e4e59 on type-matcher into 3fda805 on master.

@coveralls

coveralls commented Aug 22, 2018

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.05%) to 91.982% when pulling e570015 on type-matcher into 3fda805 on master.

@bodewig bodewig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks, looks good.

I'm not totally sure about accepting 0/1 as booleans, one could argue that it should also accept on/off or something similar.

We may want to extend this with a TypeMatcher<Date> later.

@krystiankaluzny

Copy link
Copy Markdown
Member Author

Using 1/0 as true/false is natural in C/C++ or, at least it was, when I used those languages few years ago.
So it was natural for me to treat 0/1 as boleans.
If you think it is confusing, we can remove it now and if users need this feature, we will simply add it.

@phbenisc

Copy link
Copy Markdown
Contributor

You might also consider following information: In XML Schema 1.0 a boolean can be one of these: true, false, 1 or 0. See https://www.w3.org/TR/xmlschema-2/#boolean . In XML Schema 1.1 this Issue is "fixed" https://www.w3.org/TR/xmlschema11-2/#boolean

I also believe prior to SOAP 1.2 XML Schema 1.0 is used. Quite a few SOAP-Services should accept 1 and 0 as valid boolean values. So you could argue that it still is quite common. I personally think 1/0 is nowadays a bad practice and should be avoided.

@krystiankaluzny

Copy link
Copy Markdown
Member Author

Ok, to be consistent I also removed 0/1 to boolean conversion from assertj module

@bodewig

bodewig commented Aug 24, 2018

Copy link
Copy Markdown
Member

we may want to note this as a breaking change inside the AsserJ module.

@bodewig bodewig merged commit 412916b into master Aug 24, 2018
bodewig added a commit that referenced this pull request Aug 24, 2018
@krystiankaluzny krystiankaluzny deleted the type-matcher branch January 2, 2019 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants