Skip to content
Snippets Groups Projects
Commit be78ef1c authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman :boom:
Browse files

Added a unit test for blueprints-jpa it isnt currently working though

parent 92a0facf
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......@@ -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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment