package com.gentics.mesh.graphdb.orientdb;

import org.junit.Before;
import org.junit.Test;

import com.syncleus.ferma.DelegatingFramedTransactionalGraph;
import com.syncleus.ferma.FramedTransactionalGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph;

public class OrientDBFermaMultithreadingReducedTest extends AbstractOrientDBTest {

	OrientTransactionalGraph memoryGraph = new OrientGraph("memory:tinkerpop");
	OrientGraphFactory factory = new OrientGraphFactory("memory:tinkerpop");//.setupPool(5, 100);

	FramedTransactionalGraph fg;

	@Before
	public void setup() {
		fg = new DelegatingFramedTransactionalGraph<>(factory.getTx(), true, false);
	}

	@Test
	public void testMultithreading() {
		runAndWait(() -> {
			Person p = addPersonWithFriends(fg);
			p.setName("joe");
			runAndWait(() -> {
				manipulatePerson(p);
			});
		});
	}

}

@@ -192,32 +192,92 @@
 sactionalGraph;%0A
+import com.tinkerpop.blueprints.impls.orient.OrientElement;%0A
 import com.tinke
@@ -386,79 +386,8 @@
 ory;
-%0Aimport com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph;
 %0A%0Apu
@@ -472,85 +472,8 @@
  %7B%0A%0A
-%09OrientTransactionalGraph memoryGraph = new OrientGraph(%22memory:tinkerpop%22);%0A
 %09Ori
@@ -593,16 +593,36 @@
 raph fg;
+%0A%09OrientGraph graph;
 %0A%0A%09@Befo
@@ -647,16 +647,43 @@
 tup() %7B%0A
+%09%09graph = factory.getTx();%0A
 %09%09fg = n
@@ -722,31 +722,21 @@
 Graph%3C%3E(
-factory.getTx()
+graph
 , true, 
@@ -790,38 +790,16 @@
 ing() %7B%0A
-%09%09runAndWait(() -%3E %7B%0A%09
 %09%09Person
@@ -831,17 +831,16 @@
 (fg);%0A%09%09
-%09
 p.setNam
@@ -850,16 +850,73 @@
 joe%22);%0A%09
+%09System.out.println(p.getGraph().getClass().getName());%0A%0A
 %09%09runAnd
@@ -928,17 +928,117 @@
 () -%3E %7B%0A
+//
 %09
+%09%09graph.getRawGraph().activateOnCurrentThread();%0A%09%09%09graph.attach((OrientElement) p.getElement());%0A
 %09%09%09manip
@@ -1057,15 +1057,8 @@
 p);%0A
-%09%09%09%7D);%0A
 %09%09%7D)

Remove bogus line