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