@Override public ImmutableGraph getImmutableGraph(IRI name) throws NoSuchEntityException { for (TcProvider provider : providerList) { try { return provider.getImmutableGraph(name); } catch (NoSuchEntityException e) { //we do nothing and try our luck with the next provider } catch (IllegalArgumentException e) { //we do nothing and try our luck with the next provider } } throw new NoSuchEntityException(name); }
@Override public ImmutableGraph getImmutableGraph(IRI name) throws NoSuchEntityException { for (TcProvider provider : providerList) { try { return provider.getImmutableGraph(name); } catch (NoSuchEntityException e) { //we do nothing and try our luck with the next provider } catch (IllegalArgumentException e) { //we do nothing and try our luck with the next provider } } throw new NoSuchEntityException(name); }
@Test public void testGraphDeletion() throws Exception { Graph triples = createTestTripleCollection(createTestTriple()); TcProvider provider = getInstance(); IRI name1 = new IRI("http://myGraph1"); ImmutableGraph graph = provider.createImmutableGraph(name1, triples); IRI name2 = new IRI("http://myGraph2"); ImmutableGraph secondGraph = provider.createImmutableGraph(name2, triples); //if we delete graph with name1, the second graph should still be there provider.deleteGraph(name1); provider = getInstance(); ImmutableGraph firstGraph = provider.getImmutableGraph(name2); assertNotNull(firstGraph); //check second name is not there boolean expThrown = false; try { ImmutableGraph g = provider.getImmutableGraph(name1); } catch(NoSuchEntityException nses) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(name2); }
@Test public void testGraphDeletion() throws Exception { Graph triples = createTestTripleCollection(createTestTriple()); TcProvider provider = getInstance(); IRI name1 = new IRI("http://myGraph1"); ImmutableGraph graph = provider.createImmutableGraph(name1, triples); IRI name2 = new IRI("http://myGraph2"); ImmutableGraph secondGraph = provider.createImmutableGraph(name2, triples); //if we delete graph with name1, the second graph should still be there provider.deleteGraph(name1); provider = getInstance(); ImmutableGraph firstGraph = provider.getImmutableGraph(name2); assertNotNull(firstGraph); //check second name is not there boolean expThrown = false; try { ImmutableGraph g = provider.getImmutableGraph(name1); } catch(NoSuchEntityException nses) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(name2); }
@Test public void testCreateGraphExtended() throws Exception { TcProvider provider = getInstance(); Graph graph = provider.createGraph(graphIRI); assertNotNull(graph); //get a new provider and check that graph is there provider = getInstance(); graph = provider.getGraph(graphIRI); assertNotNull(graph); //check that there is no such graph, but only the mgraph boolean expThrown = false; try { ImmutableGraph g = provider.getImmutableGraph(graphIRI); } catch(NoSuchEntityException e) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(graphIRI); }
@Test public void testCreateImmutableGraphExtended() throws Exception { TcProvider provider = getInstance(); ImmutableGraph graph = provider.createImmutableGraph(graphIRI, null); assertNotNull(graph); //get a new provider and check that graph is there provider = getInstance(); graph = provider.getImmutableGraph(graphIRI); assertNotNull(graph); //check that there is no such mgraph, but only the graph boolean expThrown = false; try { Graph g = provider.getMGraph(graphIRI); } catch(NoSuchEntityException e) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(graphIRI); }
@Test public void testCreateGraphExtended() throws Exception { TcProvider provider = getInstance(); Graph graph = provider.createGraph(graphIRI); assertNotNull(graph); //get a new provider and check that graph is there provider = getInstance(); graph = provider.getGraph(graphIRI); assertNotNull(graph); //check that there is no such graph, but only the mgraph boolean expThrown = false; try { ImmutableGraph g = provider.getImmutableGraph(graphIRI); } catch(NoSuchEntityException e) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(graphIRI); }
@Test public void testCreateImmutableGraphExtended() throws Exception { TcProvider provider = getInstance(); ImmutableGraph graph = provider.createImmutableGraph(graphIRI, null); assertNotNull(graph); //get a new provider and check that graph is there provider = getInstance(); graph = provider.getImmutableGraph(graphIRI); assertNotNull(graph); //check that there is no such mgraph, but only the graph boolean expThrown = false; try { Graph g = provider.getMGraph(graphIRI); } catch(NoSuchEntityException e) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(graphIRI); }
@Test public void testDeleteEntity() { TcProvider simpleTcmProvider = getInstance(); Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); ImmutableGraph graph = mGraph.getImmutableGraph(); simpleTcmProvider.createImmutableGraph(uriRefA, graph); simpleTcmProvider.createImmutableGraph(uriRefC, graph); simpleTcmProvider.deleteGraph(uriRefA); try { simpleTcmProvider.getGraph(uriRefA); assertTrue(false); } catch (NoSuchEntityException e) { assertTrue(true); } // Check that graph is still available under uriRefC ImmutableGraph cGraph = simpleTcmProvider.getImmutableGraph(uriRefC); assertNotNull(cGraph); simpleTcmProvider.deleteGraph(uriRefC); }
@Test public void testGetImmutableGraph() { TcProvider simpleTcmProvider = getInstance(); // add Graphs Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); simpleTcmProvider.createImmutableGraph(uriRefA, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1)); simpleTcmProvider.createImmutableGraph(uriRefA1, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB)); simpleTcmProvider.createImmutableGraph(uriRefB, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1)); simpleTcmProvider.createImmutableGraph(uriRefB1, mGraph); ImmutableGraph bGraph = simpleTcmProvider.getImmutableGraph(uriRefB); Iterator<Triple> iterator = bGraph.iterator(); assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next()); assertFalse(iterator.hasNext()); simpleTcmProvider.deleteGraph(uriRefA); simpleTcmProvider.deleteGraph(uriRefA1); simpleTcmProvider.deleteGraph(uriRefB); simpleTcmProvider.deleteGraph(uriRefB1); }
@Test public void testDeleteEntity() { TcProvider simpleTcmProvider = getInstance(); Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); ImmutableGraph graph = mGraph.getImmutableGraph(); simpleTcmProvider.createImmutableGraph(uriRefA, graph); simpleTcmProvider.createImmutableGraph(uriRefC, graph); simpleTcmProvider.deleteGraph(uriRefA); try { simpleTcmProvider.getGraph(uriRefA); assertTrue(false); } catch (NoSuchEntityException e) { assertTrue(true); } // Check that graph is still available under uriRefC ImmutableGraph cGraph = simpleTcmProvider.getImmutableGraph(uriRefC); assertNotNull(cGraph); simpleTcmProvider.deleteGraph(uriRefC); }
@Test public void testGetImmutableGraph() { TcProvider simpleTcmProvider = getInstance(); // add Graphs Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); simpleTcmProvider.createImmutableGraph(uriRefA, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1)); simpleTcmProvider.createImmutableGraph(uriRefA1, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB)); simpleTcmProvider.createImmutableGraph(uriRefB, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1)); simpleTcmProvider.createImmutableGraph(uriRefB1, mGraph); ImmutableGraph bGraph = simpleTcmProvider.getImmutableGraph(uriRefB); Iterator<Triple> iterator = bGraph.iterator(); assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next()); assertFalse(iterator.hasNext()); simpleTcmProvider.deleteGraph(uriRefA); simpleTcmProvider.deleteGraph(uriRefA1); simpleTcmProvider.deleteGraph(uriRefB); simpleTcmProvider.deleteGraph(uriRefB1); }