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 DummyGraphTest {
25      Graph graph = new DummyGraph();
26  
27      @Test
28      public void add() throws Exception {
29          graph.add(new DummyTriple());
30      }
31  
32      @Test
33      public void addSPO() throws Exception {
34          graph.add(new DummyIRI(1), new DummyIRI(2), new DummyIRI(3));
35      }
36  
37      @Test
38      public void contains() throws Exception {
39          assertTrue(graph.contains(new DummyTriple()));
40      }
41  
42      @Test
43      public void containsSPO() throws Exception {
44          assertTrue(graph.contains(null, null, null));
45          assertTrue(graph.contains(new DummyIRI(1), new DummyIRI(2), new DummyIRI(3)));
46          assertFalse(graph.contains(new DummyIRI(0), new DummyIRI(0), new DummyIRI(0)));
47      }
48  
49      @Test(expected = IllegalStateException.class)
50      public void clearNotSupported() throws Exception {
51          graph.clear();
52      }
53  
54      @Test(expected = IllegalStateException.class)
55      public void remove() throws Exception {
56          graph.remove(new DummyTriple());
57      }
58  
59      @Test
60      public void removeSPO() throws Exception {
61          graph.remove(new DummyIRI(0), new DummyIRI(0), new DummyIRI(0));
62      }
63  
64      @Test
65      public void size() throws Exception {
66          assertEquals(1, graph.size());
67      }
68  
69      @Test
70      public void stream() throws Exception {
71          assertEquals(new DummyTriple(), graph.stream().findAny().get());
72      }
73  
74      @Test
75      public void streamFiltered() throws Exception {
76          assertEquals(new DummyTriple(), graph.stream(null, null, null).findAny().get());
77          assertEquals(new DummyTriple(),
78                  graph.stream(new DummyIRI(1), new DummyIRI(2), new DummyIRI(3)).findAny().get());
79          assertFalse(graph.stream(new DummyIRI(0), new DummyIRI(0), new DummyIRI(0)).findAny().isPresent());
80      }
81  
82  
83  
84  }