View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.commons.rdf.api;
19  
20  import static org.junit.Assert.*;
21  
22  import org.junit.Test;
23  
24  public class DummyDatasetTest {
25      Dataset dataset = new DummyDataset();
26  
27      @Test
28      public void add() throws Exception {
29          dataset.add(new DummyQuad());
30      }
31  
32      @Test
33      public void addSPO() throws Exception {
34          dataset.add(null, new DummyIRI(1), new DummyIRI(2), new DummyIRI(3));
35      }
36  
37      @Test
38      public void contains() throws Exception {
39          assertTrue(dataset.contains(new DummyQuad()));
40      }
41  
42      @Test
43      public void containsSPO() throws Exception {
44          assertTrue(dataset.contains(null, null, null, null));
45          assertTrue(dataset.contains(null, new DummyIRI(1), new DummyIRI(2), new DummyIRI(3)));
46          assertFalse(dataset.contains(null, new DummyIRI(0), new DummyIRI(0), new DummyIRI(0)));
47      }
48  
49      @Test(expected = IllegalStateException.class)
50      public void clearNotSupported() throws Exception {
51          dataset.clear();
52      }
53  
54      @Test(expected = IllegalStateException.class)
55      public void remove() throws Exception {
56          dataset.remove(new DummyQuad());
57      }
58  
59      @Test
60      public void removeSPO() throws Exception {
61          dataset.remove(null, new DummyIRI(0), new DummyIRI(0), new DummyIRI(0));
62      }
63  
64      @Test
65      public void size() throws Exception {
66          assertEquals(1, dataset.size());
67      }
68  
69      @Test
70      public void stream() throws Exception {
71          assertEquals(new DummyQuad(), dataset.stream().findAny().get());
72      }
73  
74      @Test
75      public void streamFiltered() throws Exception {
76          assertEquals(new DummyQuad(), dataset.stream(null, null, null, null).findAny().get());
77          assertEquals(new DummyQuad(),
78                  dataset.stream(null, new DummyIRI(1), new DummyIRI(2), new DummyIRI(3)).findAny().get());
79          assertFalse(dataset.stream(null, new DummyIRI(0), new DummyIRI(0), new DummyIRI(0)).findAny().isPresent());
80      }
81  
82      @Test
83      public void getGraph() throws Exception {
84          assertTrue(dataset.getGraph() instanceof DummyGraph);
85      }
86  
87      @Test
88      public void getGraphNull() throws Exception {
89          assertTrue(dataset.getGraph(null).get() instanceof DummyGraph);
90      }
91  
92      @Test
93      public void getGraphNamed() throws Exception {
94          assertFalse(dataset.getGraph(new DummyIRI(0)).isPresent());
95      }
96  
97      @Test
98      public void getGraphNames() throws Exception {
99          assertFalse(dataset.getGraphNames().findAny().isPresent());
100     }
101 }