Search in sources :

Example 1 with Namespace

use of org.eclipse.rdf4j.model.Namespace 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 Namespace

use of org.eclipse.rdf4j.model.Namespace 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 Namespace

use of org.eclipse.rdf4j.model.Namespace 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 Namespace

use of org.eclipse.rdf4j.model.Namespace 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 Namespace

use of org.eclipse.rdf4j.model.Namespace 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)20 SimpleNamespace (org.eclipse.rdf4j.model.impl.SimpleNamespace)14 LinkedHashSet (java.util.LinkedHashSet)12 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 Statement (org.eclipse.rdf4j.model.Statement)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)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 NamespaceAware (org.eclipse.rdf4j.model.NamespaceAware)1 Value (org.eclipse.rdf4j.model.Value)1 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)1 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)1