[MAGNOLIA-5784] NodeMatchers improvements: Property matchers Created: 23/May/14 Updated: 04/Feb/15 Resolved: 23/May/14 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | testing |
| Affects Version/s: | None |
| Fix Version/s: | 5.3 |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Magnolia International | Assignee: | Magnolia International |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Description |
|
It'd be useful to have matchers like hasProperty() where we can match on the property's name, value, or anything. Example use cases:
assertThat(node, allOf(
hasProperty(propertyName(containsString("y"))),
hasProperty("abc", containsString("oo")),
hasProperty(
Matchers.<Property>allOf(
propertyName(containsString("ef")),
propertyValue(isA(Long.class))
)
)
));
// It's a pity we have to help the either().or() matcher with generics here, but I couldn't find a way around that. Other option is to use anyOf() which I find less readable.
assertThat(node, everyProperty(Matchers.<Property>either(propertyName(startsWith("jcr:"))).or(propertyValue(equalTo("mgnl:dummyNode")))));
|
| Comments |
| Comment by Magnolia International [ 23/May/14 ] |
|
Pushed on the |