Search in sources :

Example 1 with GraknTxTinker

use of ai.grakn.kb.internal.GraknTxTinker in project grakn by graknlabs.

the class GraknTxTinkerFactoryTest method whenGettingGraphFromFactoryClosingItAndGettingItAgain_ReturnGraph.

@Test
public void whenGettingGraphFromFactoryClosingItAndGettingItAgain_ReturnGraph() {
    TxFactoryTinker factory = new TxFactoryTinker(session);
    GraknTx graph1 = factory.open(GraknTxType.WRITE);
    graph1.close();
    GraknTxTinker graph2 = factory.open(GraknTxType.WRITE);
    assertEquals(graph1, graph2);
}
Also used : GraknTx(ai.grakn.GraknTx) EmbeddedGraknTx(ai.grakn.kb.internal.EmbeddedGraknTx) GraknTxTinker(ai.grakn.kb.internal.GraknTxTinker) Test(org.junit.Test)

Example 2 with GraknTxTinker

use of ai.grakn.kb.internal.GraknTxTinker in project grakn by graknlabs.

the class GraknTxTinkerFactoryTest method whenBuildingTxFromTheSameFactory_ReturnSingletonGraphs.

@Test
public void whenBuildingTxFromTheSameFactory_ReturnSingletonGraphs() {
    GraknTx tx1 = tinkerGraphFactory.open(GraknTxType.WRITE);
    TinkerGraph tinkerGraph1 = ((GraknTxTinker) tx1).getTinkerPopGraph();
    tx1.close();
    GraknTx tx1_copy = tinkerGraphFactory.open(GraknTxType.WRITE);
    tx1_copy.close();
    GraknTx tx2 = tinkerGraphFactory.open(GraknTxType.BATCH);
    TinkerGraph tinkerGraph2 = ((GraknTxTinker) tx2).getTinkerPopGraph();
    tx2.close();
    GraknTx tx2_copy = tinkerGraphFactory.open(GraknTxType.BATCH);
    assertEquals(tx1, tx1_copy);
    assertEquals(tx2, tx2_copy);
    assertNotEquals(tx1, tx2);
    assertEquals(tinkerGraph1, tinkerGraph2);
}
Also used : GraknTx(ai.grakn.GraknTx) EmbeddedGraknTx(ai.grakn.kb.internal.EmbeddedGraknTx) TinkerGraph(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph) GraknTxTinker(ai.grakn.kb.internal.GraknTxTinker) Test(org.junit.Test)

Aggregations

GraknTx (ai.grakn.GraknTx)2 EmbeddedGraknTx (ai.grakn.kb.internal.EmbeddedGraknTx)2 GraknTxTinker (ai.grakn.kb.internal.GraknTxTinker)2 Test (org.junit.Test)2 TinkerGraph (org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph)1