NamespaceResolver { public String resolveFullIri(String iri) { Objects.requireNonNull(iri); final int colonIndex = iri.indexOf(':'); if (colonIndex == -1 || colonIndex > iri.length()) { return iri; } final String prefix = iri.substring(0, colonIndex); if (!namespaces.containsKey(prefix)) { return iri; } final String localName = iri.substring(colonIndex + 1); return namespaces.get(prefix) + localName; } NamespaceResolver(); void registerNamespace(String prefix, String namespace); String resolveFullIri(String iri);  }
@Test void resolveReturnsOriginalIriWhenItDoesNotContainPrefix() { assertEquals(DC.Elements.DESCRIPTION, sut.resolveFullIri(DC.Elements.DESCRIPTION)); }
@Test void resolveReturnsOriginalIriWhenPrefixIsNotRegistered() { final String iri = "dc:description"; assertEquals(iri, sut.resolveFullIri(iri)); }
@Test void resolveReturnsPreregisteredIri() { assertEquals(RDFS.LABEL, sut.resolveFullIri("rdfs:label")); }
@Test void resolveReturnsOriginalIriWhenPrefixIsInvalid() { final String invalidIri = "prefixWithoutLocalName"; assertEquals(invalidIri, sut.resolveFullIri(invalidIri)); }