Search in sources :

Example 1 with SimpleNamespace

use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.

the class NamespacesTest method testWrapContainsValue.

/**
 * Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#wrap(java.util.Set)}.
 */
@Test
public final void testWrapContainsValue() 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.containsValue(testName1));
    testSet.add(new SimpleNamespace(testPrefix1, testName1));
    assertTrue(testMap.containsValue(testName1));
    testSet.clear();
    assertFalse(testMap.containsValue(testName1));
}
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)

Example 2 with SimpleNamespace

use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.

the class NamespacesTest method testWrapIsEmpty.

/**
 * Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#wrap(java.util.Set)}.
 */
@Test
public final void testWrapIsEmpty() throws Exception {
    Set<Namespace> testSet = new LinkedHashSet<Namespace>();
    Map<String, String> testMap = Namespaces.wrap(testSet);
    assertTrue(testMap.isEmpty());
    testSet.add(new SimpleNamespace(testPrefix1, testName1));
    assertFalse(testMap.isEmpty());
    testSet.clear();
    assertTrue(testMap.isEmpty());
}
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)

Example 3 with SimpleNamespace

use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.

the class NamespacesTest method testWrapGet.

/**
 * Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#wrap(java.util.Set)}.
 */
@Test
public final void testWrapGet() throws Exception {
    Set<Namespace> testSet = new LinkedHashSet<Namespace>();
    Map<String, String> testMap = Namespaces.wrap(testSet);
    assertNull(testMap.get(testPrefix1));
    testSet.add(new SimpleNamespace(testPrefix1, testName1));
    assertEquals(testName1, testMap.get(testPrefix1));
    testSet.clear();
    assertNull(testMap.get(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)

Example 4 with SimpleNamespace

use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.

the class NamespacesTest method testWrapValues.

/**
 * Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#wrap(java.util.Set)}.
 */
@Test
public final void testWrapValues() throws Exception {
    Set<Namespace> testSet = new LinkedHashSet<Namespace>();
    Map<String, String> testMap = Namespaces.wrap(testSet);
    Collection<String> values1 = testMap.values();
    assertNotNull(values1);
    assertTrue(values1.isEmpty());
    testSet.add(new SimpleNamespace(testPrefix1, testName1));
    Collection<String> values2 = testMap.values();
    assertNotNull(values2);
    assertFalse(values2.isEmpty());
    assertEquals(1, values2.size());
    String nextValue = values2.iterator().next();
    assertEquals(testName1, nextValue);
    testSet.clear();
    Collection<String> values3 = testMap.values();
    assertNotNull(values3);
    assertTrue(values3.isEmpty());
}
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)

Example 5 with SimpleNamespace

use of org.eclipse.rdf4j.model.impl.SimpleNamespace in project rdf4j by eclipse.

the class NamespacesTest method testWrapClear.

/**
 * Test method for {@link org.eclipse.rdf4j.model.util.Namespaces#wrap(java.util.Set)}.
 */
@Test
public final void testWrapClear() throws Exception {
    Set<Namespace> testSet = new LinkedHashSet<Namespace>();
    Map<String, String> testMap = Namespaces.wrap(testSet);
    // Check no exceptions when calling clear on empty backing set
    testMap.clear();
    testSet.add(new SimpleNamespace(testPrefix1, testName1));
    assertFalse(testMap.isEmpty());
    assertEquals(1, testMap.size());
    testMap.clear();
    assertTrue(testMap.isEmpty());
    assertEquals(0, testMap.size());
}
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