### Question:
IsPublishableResourceContainer implements Predicate<Resource> { @Override public boolean test(Resource r) { return Optional.ofNullable(r).map(Resource::getResourceType) .map(rt -> JcrResourceConstants.NT_SLING_FOLDER.equals(rt) || JcrResourceConstants.NT_SLING_ORDERED_FOLDER.equals(rt) || CMSConstants.NT_FILE.equals(rt) || CMSConstants.NT_SITE.equals(rt) || CMSConstants.NT_PAGE.equals(rt)) .orElse(false); }  @Override boolean test(Resource r);  }### Answer:
@Test public void testTypes(){ IsPublishableResourceContainer predicate = new IsPublishableResourceContainer(); Resource folder = mockResource(JcrConstants.NT_FOLDER); Resource slingFolder = mockResource(JcrResourceConstants.NT_SLING_FOLDER); Resource orderedFolder = mockResource(JcrResourceConstants.NT_SLING_ORDERED_FOLDER); Resource slingFile = mockResource(CMSConstants.NT_FILE); Resource site = mockResource(CMSConstants.NT_SITE); Resource page = mockResource(CMSConstants.NT_PAGE); Resource config = mockResource(CMSConstants.NT_CONFIG); Resource component = mockResource("a/resource/type"); assertFalse(predicate.test(null)); assertFalse(predicate.test(folder)); assertTrue(predicate.test(slingFolder)); assertTrue(predicate.test(orderedFolder)); assertTrue(predicate.test(slingFile)); assertTrue(predicate.test(site)); assertTrue(predicate.test(page)); assertFalse(predicate.test(config)); assertFalse(predicate.test(component)); }