public final class ResourceMatchers extends Object
Modifier and Type | Method and Description |
---|---|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
containsChildren(String... children)
Matches resources which have exactly the children with the names given in children.
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
containsChildrenInAnyOrder(String... children)
Matches resources which have exactly the children with the names given in children.
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
hasChildren(String... children)
Matches resources which have amongst their children the specified children.
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
name(String name)
Matches only if the resource has the given name
assertThat(resource, resourceWithName('resource1'));
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
nameAndProps(String name,
Map<String,Object> properties)
Matches resources which has the given name and at least the specified properties defined with matching values
Values not declared in the the properties parameter are not validated.
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
nameAndProps(String name,
Object... properties)
Matches resources which has the given name and at least the specified properties defined with matching values
Values not declared in the the properties parameter are not validated.
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
path(String path)
Matches only if the resource has the given path
assertThat(resource, hasName('/a/b/c'));
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
props(Map<String,Object> properties)
Matches resources which has at least the specified properties defined with matching values
Values not declared in the the properties parameter are not validated.
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
props(Object... properties)
Matches resources which has at least the specified properties defined with matching values
Values not declared in the the properties parameter are not validated.
|
static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> |
resourceType(String resourceType)
Matches resources with a resource type set to the specified resourceType
assertThat(resource, resourceOfType('my/app'));
|
public static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> hasChildren(String... children)
assertThat(resource, hasChildren('child1', 'child2'));
children
- the expected children, not null
or emptypublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> containsChildren(String... children)
assertThat(resource, containsChildren('child1', 'child2'));
children
- the expected children, not null
or emptypublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> containsChildrenInAnyOrder(String... children)
assertThat(resource, containsChildrenInAnyOrder('child1', 'child2'));
children
- the expected children, not null
or emptypublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> path(String path)
assertThat(resource, hasName('/a/b/c'));
path
- the resources path, not null
or emptypublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> name(String name)
assertThat(resource, resourceWithName('resource1'));
name
- the resources name, not null
or emptypublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> resourceType(String resourceType)
assertThat(resource, resourceOfType('my/app'));
resourceType
- the resource type to matchpublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> props(Map<String,Object> properties)
Values not declared in the the properties parameter are not validated.
Map<String, Object> expectedProperties = new HashMap<>(); expectedProperties.put("jcr:title", "Node title"); expectedProperties.put("jcr:text", "Some long text"); assertThat(resource, resourceWithProps(expectedProperties));
properties
- the properties to matchpublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> props(Object... properties)
Values not declared in the the properties parameter are not validated.
Map<String, Object> expectedProperties = new HashMap<>(); expectedProperties.put("jcr:title", "Node title"); expectedProperties.put("jcr:text", "Some long text"); assertThat(resource, resourceWithProps(expectedProperties));
properties
- the properties to matchpublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> nameAndProps(String name, Map<String,Object> properties)
Values not declared in the the properties parameter are not validated.
Map<String, Object> expectedProperties = new HashMap<>(); expectedProperties.put("jcr:title", "Node title"); expectedProperties.put("jcr:text", "Some long text"); assertThat(resource, resourceWithProps(expectedProperties));
name
- the expected name of the resourceproperties
- the properties to matchpublic static org.hamcrest.Matcher<org.apache.sling.api.resource.Resource> nameAndProps(String name, Object... properties)
Values not declared in the the properties parameter are not validated.
Map<String, Object> expectedProperties = new HashMap<>(); expectedProperties.put("jcr:title", "Node title"); expectedProperties.put("jcr:text", "Some long text"); assertThat(resource, resourceWithProps(expectedProperties));
name
- the expected name of the resourceproperties
- the properties to matchCopyright © 2007–2017 The Apache Software Foundation. All rights reserved.