From be78ef1ccf8d9c9aa796a600d25b06cc03e4dd48 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Date: Fri, 21 Nov 2014 13:05:00 -0500
Subject: [PATCH] Added a unit test for blueprints-jpa it isnt currently
 working though

---
 pom.xml                                       | 11 +++++++
 .../grail/graph/hibernate/DogBreedTest.java   | 32 +++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/pom.xml b/pom.xml
index b989387..f3adfb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,5 +87,16 @@
             <version>1.2.17</version>
             <scope>runtime</scope>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.7</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.wingnest.blueprints</groupId>
+            <artifactId>blueprints-jpa-graph</artifactId>
+            <version>2.5.0_01</version>
+        </dependency>
     </dependencies>
 </project>
diff --git a/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java b/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java
index 2a2c4f9..f9dfe76 100644
--- a/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java
+++ b/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java
@@ -2,6 +2,7 @@ package com.syncleus.grail.graph.hibernate;
 
 import com.syncleus.grail.graph.hibernate.domain.Breed;
 import com.syncleus.grail.graph.hibernate.domain.Dog;
+import com.tinkerpop.blueprints.Vertex;
 import junit.framework.Assert;
 import org.hibernate.ogm.util.impl.Log;
 import org.hibernate.ogm.util.impl.LoggerFactory;
@@ -11,6 +12,7 @@ import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.EntityTransaction;
 import javax.persistence.Persistence;
+import com.wingnest.blueprints.impls.jpa.*;
 
 public class DogBreedTest {
 
@@ -50,4 +52,34 @@ public class DogBreedTest {
 
 		emf.close();
 	}
+
+	@Test
+	public void testJpa() {
+		//build the EntityManagerFactory as you would build in in Hibernate Core
+		EntityManagerFactory emf = Persistence.createEntityManagerFactory( "ogm-jpa-tutorial" );
+
+		//Persist entities the way you are used to in plain JPA
+		EntityManager em = emf.createEntityManager();
+		EntityTransaction tm = em.getTransaction();
+		tm.begin();
+		Breed collie = new Breed();
+		collie.setName( "Collie" );
+		em.persist( collie );
+		Dog dina = new Dog();
+		dina.setName( "Dina" );
+		dina.setBreed( collie );
+		em.persist( dina );
+		Long dinaId = dina.getId();
+		em.flush();
+		em.close();
+		tm.commit();
+
+		final JpaGraph graph = new JpaGraph(emf);
+		graph.begin();
+		final Vertex dinaVertex = graph.getVertex(dinaId);
+		Assert.assertEquals("Dina", dinaVertex.getProperty("name"));
+		graph.commit();
+
+		emf.close();
+	}
 }
-- 
GitLab