### Question:
ResourceHashModel implements TemplateHashModelEx, TemplateScalarModel, ResourceTemplate { @Override public TemplateCollectionModel keys() throws TemplateModelException { ArrayList<String> list = new ArrayList<String>(); StmtIterator iterator = resource.listProperties(); while (iterator.hasNext()) { list.add(iterator.next().getPredicate().getURI()); } return new SimpleCollection(list); } ResourceHashModel(Resource resource); @Override int size(); @Override TemplateCollectionModel keys(); @Override TemplateCollectionModel values(); @Override TemplateModel get(String s); @Override boolean isEmpty(); @Override String getAsString(); @Override Resource getResource(); final static String INVALID_URL; }### Answer:
@Test public void testKeys() throws TemplateModelException { ArrayList<String> keysList = new ArrayList<String>(); for (TemplateModelIterator i = resourceHashModel.keys().iterator(); i.hasNext();) { keysList.add(((SimpleScalar) i.next()).getAsString()); } assertEquals("Unexpected size", KEY_SIZE, keysList.size()); assertTrue("Expected key: " + RDFS.label.getURI(), keysList.contains(RDFS.label.getURI())); assertTrue("Expected key: " + DC.identifier.getURI(), keysList.contains(DC.identifier.getURI())); assertTrue("Expected key: " + VCARD.CATEGORIES.getURI(), keysList.contains(VCARD.CATEGORIES.getURI())); assertTrue("Expected key: " + DC.publisher.getURI(), keysList.contains(DC.publisher.getURI())); }