KnownURIsDictionary extends SingleIndexValueDictionary implements ManageableKnownURIsDictionary { boolean contains(final String prefix) { for (final String domain : _domains) { if (domain.equals(prefix)) { return true; } } return false; } KnownURIsDictionary(final String id, final ITopLevelDictionary decoratee);  KnownURIsDictionary(final String id, final ITopLevelDictionary decoratee, final String ... domains); @Override void initialiseInternal(final DataAccessLayerFactory factory); @Override void removeValue(final Value value, final boolean p); @Override boolean isBNode(final byte[] id); @Override boolean isLiteral(final byte[] id); @Override boolean isResource(final byte[] id); @Override long getIdKnownURIsHitsCount(); @Override long getValueKnownURIsHitsCount();  }
@Test public void getIdWithIgnorableURI() throws Exception { final String[] ignorableNamespaces = { "http: "http: "http: }; for (final String ignorableNamespace : ignorableNamespaces) { assertFalse(_cut.contains(ignorableNamespace)); final Value ignorableURI = buildResource(ignorableNamespace + randomString()); _cut.getID(ignorableURI, _isPredicate); verify(_decoratee).getID(ignorableURI, _isPredicate); } }
@Test public void getIdWithManagedURI() throws Exception { final String[] managedNamespaces = { FOAF.NAMESPACE, RDFS.NAMESPACE, OWL.NAMESPACE }; for (final String managedNamespace : managedNamespaces) { assertTrue(_cut.contains(managedNamespace)); final Value uri = buildResource(managedNamespace + randomString()); final String n3 = NTriplesUtil.toNTriplesString(uri); when(_dummyIndex.get(n3)).thenReturn(ValueDictionaryBase.NOT_SET); byte[] id = _cut.getID(uri, _isPredicate); assertEquals(KnownURIsDictionary.ID_LENGTH, id.length); assertEquals(KnownURIsDictionary.KNOWN_URI_MARKER, id[0]); assertEquals(ValueDictionaryBase.RESOURCE_BYTE_FLAG, id[1]); verify(_decoratee, times(0)).getID(uri, _isPredicate); verify(_dummyIndex).putQuick(n3, id); reset(_decoratee, _dummyIndex); } }