### Question:
ParsysRewriteRule implements StructureRewriteRule { @Override public boolean matches(Node root) throws RepositoryException { if (!root.hasProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY)) { return false; } try { String resourceType = root.getProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY).getString(); return PARSYS_RESOURCE_TYPE.equals(resourceType); } catch (RepositoryException ex) { logger.error("Error looking up sling:resourceType: {}", ex.getMessage()); } return false; }  @Override boolean matches(Node root); @Override Node applyTo(Node root, Set<Node> finalNodes); @Override int getRanking();  }### Answer:
@Test public void testMatches() throws Exception { Node rootNode = context.resourceResolver().getResource(ROOTS_PATH + "/matches/jcr:content/par").adaptTo(Node.class); ParsysRewriteRule rule = new ParsysRewriteRule(); assertTrue(rule.matches(rootNode)); }
@Test public void testDoesNotMatch() throws Exception { Node rootNode = context.resourceResolver().getResource(ROOTS_PATH + "/matches/jcr:content").adaptTo(Node.class); ParsysRewriteRule rule = new ParsysRewriteRule(); assertFalse(rule.matches(rootNode)); }