Search in sources :

Example 6 with TransactionalGraph

use of com.tinkerpop.blueprints.TransactionalGraph in project blueprints by tinkerpop.

the class GraphSailConnection method commitInternal.

public void commitInternal() throws SailException {
    if (store.isTransactional) {
        ((TransactionalGraph) store.graph).commit();
    }
    if (statementsAdded || statementsRemoved) {
        DefaultSailChangedEvent e = new DefaultSailChangedEvent(store.sail);
        e.setStatementsAdded(statementsAdded);
        e.setStatementsRemoved(statementsRemoved);
        store.sail.notifySailChanged(e);
    }
}
Also used : DefaultSailChangedEvent(org.openrdf.sail.helpers.DefaultSailChangedEvent) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph)

Example 7 with TransactionalGraph

use of com.tinkerpop.blueprints.TransactionalGraph in project frames by tinkerpop.

the class FramedTransactionalGraphTest method testTransactions.

@Test
public void testTransactions() {
    TransactionalGraph t = Mockito.mock(TransactionalGraph.class);
    FramedTransactionalGraph<TransactionalGraph> g = new FramedTransactionalGraph<TransactionalGraph>(t, new FramedGraphConfiguration());
    g.commit();
    Mockito.verify(t).commit();
    Mockito.reset(t);
    g.rollback();
    Mockito.verify(t).rollback();
}
Also used : TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) Test(org.junit.Test)

Example 8 with TransactionalGraph

use of com.tinkerpop.blueprints.TransactionalGraph in project frames by tinkerpop.

the class AbstractModuleTest method testWrapping.

@Test
public void testWrapping() {
    Graph baseGraph = Mockito.mock(Graph.class);
    TransactionalGraph baseTransactionalGraph = Mockito.mock(TransactionalGraph.class);
    Graph wrappedGraph = Mockito.mock(Graph.class);
    TransactionalGraph wrappedTransactionalGraph = Mockito.mock(TransactionalGraph.class);
    FramedGraphConfiguration config = new FramedGraphConfiguration();
    AbstractModule module = Mockito.mock(AbstractModule.class);
    Mockito.when(module.doConfigure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).thenReturn(wrappedGraph);
    Graph configuredGraph = module.configure(baseGraph, config);
    Assert.assertEquals(wrappedGraph, configuredGraph);
    Mockito.reset(module);
    Mockito.when(module.doConfigure(Mockito.any(TransactionalGraph.class), Mockito.any(FramedGraphConfiguration.class))).thenReturn(wrappedTransactionalGraph);
    Graph configuredTransactionalGraph = module.configure(baseTransactionalGraph, config);
    Assert.assertEquals(wrappedTransactionalGraph, configuredTransactionalGraph);
}
Also used : Graph(com.tinkerpop.blueprints.Graph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) FramedGraphConfiguration(com.tinkerpop.frames.FramedGraphConfiguration) AbstractModule(com.tinkerpop.frames.modules.AbstractModule) Test(org.junit.Test)

Example 9 with TransactionalGraph

use of com.tinkerpop.blueprints.TransactionalGraph in project frames by tinkerpop.

the class AbstractModuleTest method testNoWrapping.

@Test
public void testNoWrapping() {
    Graph baseGraph = Mockito.mock(Graph.class);
    TransactionalGraph baseTransactionalGraph = Mockito.mock(TransactionalGraph.class);
    FramedGraphConfiguration config = new FramedGraphConfiguration();
    AbstractModule module = Mockito.mock(AbstractModule.class);
    Mockito.when(module.doConfigure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).thenCallRealMethod();
    Graph configuredGraph = module.configure(baseGraph, config);
    Assert.assertEquals(baseGraph, configuredGraph);
    Mockito.verify(module).doConfigure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class));
    Mockito.verify(module).doConfigure(Mockito.any(FramedGraphConfiguration.class));
    Mockito.reset(module);
    Mockito.when(module.doConfigure(Mockito.any(TransactionalGraph.class), Mockito.any(FramedGraphConfiguration.class))).thenCallRealMethod();
    Graph configuredTransactionalGraph = module.configure(baseTransactionalGraph, config);
    Assert.assertEquals(baseTransactionalGraph, configuredTransactionalGraph);
    Mockito.verify(module).doConfigure(Mockito.any(TransactionalGraph.class), Mockito.any(FramedGraphConfiguration.class));
    Mockito.verify(module).doConfigure(Mockito.any(FramedGraphConfiguration.class));
}
Also used : Graph(com.tinkerpop.blueprints.Graph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) FramedGraphConfiguration(com.tinkerpop.frames.FramedGraphConfiguration) AbstractModule(com.tinkerpop.frames.modules.AbstractModule) Test(org.junit.Test)

Example 10 with TransactionalGraph

use of com.tinkerpop.blueprints.TransactionalGraph in project frames by tinkerpop.

the class FramedGraphFactoryTest method testWrappingError.

@Test(expected = UnsupportedOperationException.class)
public void testWrappingError() {
    Graph wrapper = Mockito.mock(Graph.class);
    Mockito.when(mockModule.configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).thenReturn(wrapper);
    FramedGraphFactory graphFactory = new FramedGraphFactory(mockModule);
    TransactionalGraph baseTransactional = Mockito.mock(TransactionalGraph.class);
    graphFactory.create(baseTransactional);
}
Also used : Graph(com.tinkerpop.blueprints.Graph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) Test(org.junit.Test)

Aggregations

TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)12 Graph (com.tinkerpop.blueprints.Graph)6 Test (org.junit.Test)6 Vertex (com.tinkerpop.blueprints.Vertex)2 FramedGraphConfiguration (com.tinkerpop.frames.FramedGraphConfiguration)2 AbstractModule (com.tinkerpop.frames.modules.AbstractModule)2 ArrayList (java.util.ArrayList)2 Element (com.tinkerpop.blueprints.Element)1 KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)1 GraphTest (com.tinkerpop.blueprints.impls.GraphTest)1 GraphMLReader (com.tinkerpop.blueprints.util.io.graphml.GraphMLReader)1 Module (com.tinkerpop.frames.modules.Module)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ReturnsArgumentAt (org.mockito.internal.stubbing.answers.ReturnsArgumentAt)1 DefaultSailChangedEvent (org.openrdf.sail.helpers.DefaultSailChangedEvent)1