### Question:
ResourceHashModel implements TemplateHashModelEx, TemplateScalarModel, ResourceTemplate { @Override public TemplateModel get(String s) throws TemplateModelException { String uri = prefixMapping.expandPrefix(s); Property property = ResourceFactory.createProperty(uri); if (!resource.hasProperty(property)) { return null; } List<TemplateModel> list = new ArrayList<TemplateModel>(); StmtIterator iter = resource.listProperties(property); while (iter.hasNext()) { list.add(resolveModel(iter.next().getObject())); } Collections.sort(list, new McaJenaResourceComparator()); return new SimpleSequence(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 testGet() throws TemplateModelException, ParseException { SimpleSequence collection = (SimpleSequence) resourceHashModel.get(RDFS.label.getURI()); assertEquals("There should only be one label", 1, collection.size()); assertTrue("Expected a SimpleScalar", collection.get(0) instanceof SimpleScalar); assertEquals("Unexpected value", testStringLiteral, collection.get(0).toString()); collection = (SimpleSequence) resourceHashModel.get(DC.identifier.getURI()); assertEquals("There should only be one int", 1, collection.size()); assertTrue("Expected a SimpleNumber", collection.get(0) instanceof SimpleNumber); assertEquals("Unexpected value", testIntegerLiteral, ((SimpleNumber) collection.get(0)).getAsNumber()); collection = (SimpleSequence) resourceHashModel.get(VCARD.CATEGORIES.getURI()); assertEquals("There should only be one double", 1, collection.size()); assertTrue("Expected a SimpleNumber", collection.get(0) instanceof SimpleNumber); assertEquals("Unexpected value", testDoubleLiteral, ((SimpleNumber) collection.get(0)).getAsNumber()); collection = (SimpleSequence) resourceHashModel.get(DC.date.getURI()); assertEquals("There should only be one date", 1, collection.size()); assertTrue("Expected a SimpleDate", collection.get(0) instanceof SimpleDate); DateFormat df = new SimpleDateFormat(DATE_FORMAT); Date date = df.parse(testDate); assertEquals("Unexpected value", date.getTime(), ((SimpleDate) collection.get(0)).getAsDate().getTime()); collection = (SimpleSequence) resourceHashModel.get(DC.publisher.getURI()); assertEquals("There should only be one uri", 1, collection.size()); assertTrue("Expected a ResourceHashModel", collection.get(0) instanceof ResourceHashModel); assertEquals("Unexpected value", secondUri, ((ResourceHashModel) collection.get(0)).getAsString()); }