Search in sources :

Example 11 with SimpleNamespace

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));
}
Also used : SimpleNamespace(org.eclipse.rdf4j.model.impl.SimpleNamespace) Namespace(org.eclipse.rdf4j.model.Namespace) SimpleNamespace(org.eclipse.rdf4j.model.impl.SimpleNamespace) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.junit.Test)

Example 12 with SimpleNamespace

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());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Entry(java.util.Map.Entry) SimpleNamespace(org.eclipse.rdf4j.model.impl.SimpleNamespace) Namespace(org.eclipse.rdf4j.model.Namespace) SimpleNamespace(org.eclipse.rdf4j.model.impl.SimpleNamespace) Test(org.junit.Test)

Example 13 with SimpleNamespace

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));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SimpleNamespace(org.eclipse.rdf4j.model.impl.SimpleNamespace) Namespace(org.eclipse.rdf4j.model.Namespace) SimpleNamespace(org.eclipse.rdf4j.model.impl.SimpleNamespace) Test(org.junit.Test)

Aggregations

Namespace (org.eclipse.rdf4j.model.Namespace)13 SimpleNamespace (org.eclipse.rdf4j.model.impl.SimpleNamespace)13 LinkedHashSet (java.util.LinkedHashSet)12 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 IOException (java.io.IOException)1 AbstractMap (java.util.AbstractMap)1 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Literal (org.eclipse.rdf4j.model.Literal)1 Value (org.eclipse.rdf4j.model.Value)1 BindingSet (org.eclipse.rdf4j.query.BindingSet)1 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)1 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)1 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)1