This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-hamcrest.git

commit 791c853b2503e7ddfc4ab85b2a2505bcd823f3f6
Author: Robert Munteanu <[email protected]>
AuthorDate: Fri Sep 25 13:32:45 2015 +0000

    SLING-5063 - Create a set of Hamcrest matchers for JUnit tests
    
    Add javadoc for ResourceMatchers
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1705299 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/hamcrest/ResourceMatchers.java    | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/main/java/org/apache/sling/hamcrest/ResourceMatchers.java 
b/src/main/java/org/apache/sling/hamcrest/ResourceMatchers.java
index 7950a2b..dea43d8 100644
--- a/src/main/java/org/apache/sling/hamcrest/ResourceMatchers.java
+++ b/src/main/java/org/apache/sling/hamcrest/ResourceMatchers.java
@@ -32,14 +32,50 @@ import org.hamcrest.Matcher;
  */
 public final class ResourceMatchers {
     
+    /**
+     * Matches resources which have amongst their children the specified 
<tt>children</tt>.
+     * 
+     * Child resources not contained in the specified <tt>children</tt> are 
not validated.
+     * 
+     * <pre>
+     * assertThat(resource, hasChildren('child1', 'child2'));
+     * </pre>
+     * 
+     * @param children the expected children, not <code>null</code> or empty
+     * @return a matcher instance
+     */
     public static Matcher<Resource> hasChildren(String... children) {
         return new ResourceChildrenMatcher(Arrays.asList(children));
     }
     
+    /**
+     * Matches resources with a resource type set to the specified 
<tt>resourceType</tt>
+     * 
+     * <pre>
+     * assertThat(resource, resourceOfType('my/app'));
+     * </pre>
+     * @param resourceType the resource type to match
+     * @return a matcher instance
+     */
     public static Matcher<Resource> resourceOfType(String resourceType) {
         return new ResourceMatcher(Collections.<String, Object> 
singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, resourceType));
     }
 
+    /**
+     * Matches resources which has at least the specified <tt>properties</tt> 
defined with matching values
+     * 
+     * <p>Values not declared in the the <tt>properties</tt> parameter are not 
validated.</p>
+     * <pre>
+     * Map<String, Object> expectedProperties = new HashMap<>();
+     * expectedProperties.put("jcr:title", "Node title");
+     * expectedProperties.put("jcr:text",  "Some long text");
+     * 
+     * assertThat(resource, resourceWithProps(expectedProperties));
+     * </pre>
+     * 
+     * @param resourceType the resource type to match
+     * @return a matcher instance
+     */    
     public static Matcher<Resource> resourceWithProps(Map<String, Object> 
properties) {
         return new ResourceMatcher(properties);
     }

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to