PageUtil { public boolean isPageResource(Resource resource) { if (resource == null) { return false; } String path = resource.getPath(); if (!path.startsWith(CONTENT) || path.contains(JcrConstants.JCR_CONTENT)) { return false; } String primaryType = resource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class); return NameConstants.NT_PAGE.equals(primaryType); }  boolean isPageResource(Resource resource);  }
@Test public void isPageResource() { PageUtil util = new PageUtil(); assertTrue(util.isPageResource(resource)); }
@Test public void isPageResource_noContent() { when(resource.getPath()).thenReturn("/var/project/something"); PageUtil util = new PageUtil(); assertFalse(util.isPageResource(resource)); }
@Test public void isPageResource_subnode() { when(resource.getPath()).thenReturn("/content/project/something/jcr:content/node"); PageUtil util = new PageUtil(); assertFalse(util.isPageResource(resource)); }
@Test public void isPageResource_wrongPrimaryType() { when(valueMap.get(JcrConstants.JCR_PRIMARYTYPE, String.class)).thenReturn(JcrConstants.NT_FOLDER); PageUtil util = new PageUtil(); assertFalse(util.isPageResource(resource)); }