use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.
the class NamespacesTest method testAsMapMultiple.
/**
* Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#asMap(java.util.Set)}.
*/
@Test
public final void testAsMapMultiple() {
Set<Namespace> input = new HashSet<Namespace>();
input.add(new SimpleNamespace(RDF.PREFIX, RDF.NAMESPACE));
input.add(new SimpleNamespace(RDFS.PREFIX, RDFS.NAMESPACE));
input.add(new SimpleNamespace(DC.PREFIX, DC.NAMESPACE));
input.add(new SimpleNamespace(SKOS.PREFIX, SKOS.NAMESPACE));
input.add(new SimpleNamespace(SESAME.PREFIX, SESAME.NAMESPACE));
Map<String, String> map = Namespaces.asMap(input);
assertFalse(map.isEmpty());
assertEquals(5, map.size());
assertTrue(map.containsKey(RDF.PREFIX));
assertEquals(RDF.NAMESPACE, map.get(RDF.PREFIX));
assertTrue(map.containsKey(RDFS.PREFIX));
assertEquals(RDFS.NAMESPACE, map.get(RDFS.PREFIX));
assertTrue(map.containsKey(DC.PREFIX));
assertEquals(DC.NAMESPACE, map.get(DC.PREFIX));
assertTrue(map.containsKey(SKOS.PREFIX));
assertEquals(SKOS.NAMESPACE, map.get(SKOS.PREFIX));
assertTrue(map.containsKey(SESAME.PREFIX));
assertEquals(SESAME.NAMESPACE, map.get(SESAME.PREFIX));
}
use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.
the class NamespacesTest method testWrapEntrySet.
/**
* Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#wrap(java.util.Set)}.
*/
@Test
public final void testWrapEntrySet() throws Exception {
Set<Namespace> testSet = new LinkedHashSet<Namespace>();
Map<String, String> testMap = Namespaces.wrap(testSet);
Set<Entry<String, String>> entrySet1 = testMap.entrySet();
assertNotNull(entrySet1);
assertTrue(entrySet1.isEmpty());
testSet.add(new SimpleNamespace(testPrefix1, testName1));
Set<Entry<String, String>> entrySet2 = testMap.entrySet();
assertNotNull(entrySet2);
assertFalse(entrySet2.isEmpty());
assertEquals(1, entrySet2.size());
Entry<String, String> nextEntry = entrySet2.iterator().next();
assertEquals(testPrefix1, nextEntry.getKey());
assertEquals(testName1, nextEntry.getValue());
testSet.clear();
Set<Entry<String, String>> entrySet3 = testMap.entrySet();
assertNotNull(entrySet3);
assertTrue(entrySet3.isEmpty());
}
use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.
the class NamespacesTest method testWrapContainsKey.
/**
* Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#wrap(java.util.Set)}.
*/
@Test
public final void testWrapContainsKey() throws Exception {
Set<Namespace> testSet = new LinkedHashSet<Namespace>();
Map<String, String> testMap = Namespaces.wrap(testSet);
// Check no exceptions when calling containsKey on empty backing set
assertFalse(testMap.containsKey(testPrefix1));
testSet.add(new SimpleNamespace(testPrefix1, testName1));
assertTrue(testMap.containsKey(testPrefix1));
testSet.clear();
assertFalse(testMap.containsKey(testPrefix1));
}
Aggregations