Search in sources :

Example 6 with Document

use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.

the class DegenerateEntityModelTests method init.

@Before
public void init() throws IOException {
    session = sessionFactory.openSession();
    session.purgeDatabase();
    Iterable<Map<String, Object>> executionResult = session.query("CREATE (f:Folder { name: 'f' } )" + "CREATE (a:Document { name: 'a' } ) " + "CREATE (b:Document { name: 'b' } ) " + "CREATE (f)-[:CONTAINS]->(a) " + "CREATE (f)-[:CONTAINS]->(b) " + "RETURN id(f) AS fid, id(a) AS aid, id(b) AS bid", emptyMap()).queryResults();
    Map<String, Object> resultSet = executionResult.iterator().next();
    session.clear();
    a = session.load(Document.class, (Long) resultSet.get("aid"));
    Document b = session.load(Document.class, (Long) resultSet.get("bid"));
    f = session.load(Folder.class, (Long) resultSet.get("fid"));
}
Also used : Document(org.neo4j.ogm.domain.filesystem.Document) Folder(org.neo4j.ogm.domain.filesystem.Folder) Map(java.util.Map) Before(org.junit.Before)

Example 7 with Document

use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.

the class DegenerateEntityModelTests method testSaveDegenerateDocumentClone.

@Test
public void testSaveDegenerateDocumentClone() {
    Document clone = new Document();
    clone.setId(a.getId());
    clone.setName(a.getName());
    clone.setFolder(null);
    session.save(clone);
    session.clear();
    assertThat(session.query("MATCH (f:Folder { name: 'f' } ), " + "(a:Document { name: 'a'} ), " + "(b:Document { name: 'b'} ) " + "WHERE (f)-[:CONTAINS]->(b) return f, a, b", emptyMap()).queryResults()).hasSize(1);
}
Also used : Document(org.neo4j.ogm.domain.filesystem.Document) Test(org.junit.Test)

Example 8 with Document

use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.

the class DirtyObjectsTest method modifiedLoadedObjectShouldBeDirty.

@Test
public void modifiedLoadedObjectShouldBeDirty() {
    Document d = new Document();
    session.save(d);
    d.setName("Document");
    assertThat(session.context().isDirty(d)).isTrue();
}
Also used : Document(org.neo4j.ogm.domain.filesystem.Document) Test(org.junit.Test)

Example 9 with Document

use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.

the class DirtyObjectsTest method reloadingAnObjectReturnsTheCachedInstance.

@Test
public void reloadingAnObjectReturnsTheCachedInstance() {
    Document d = new Document();
    session.save(d);
    assertThat(session.load(Document.class, d.getId())).isSameAs(d);
}
Also used : Document(org.neo4j.ogm.domain.filesystem.Document) Test(org.junit.Test)

Example 10 with Document

use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.

the class DirtyObjectsTest method savedObjectShouldNotBeDirty.

@Test
public void savedObjectShouldNotBeDirty() {
    Document d = new Document();
    session.save(d);
    assertThat(session.context().isDirty(d)).isFalse();
}
Also used : Document(org.neo4j.ogm.domain.filesystem.Document) Test(org.junit.Test)

Aggregations

Document (org.neo4j.ogm.domain.filesystem.Document)26 Test (org.junit.Test)23 Folder (org.neo4j.ogm.domain.filesystem.Folder)11 Compiler (org.neo4j.ogm.cypher.compiler.Compiler)7 RowStatementFactory (org.neo4j.ogm.session.request.RowStatementFactory)7 Statement (org.neo4j.ogm.request.Statement)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Before (org.junit.Before)3 MappedRelationship (org.neo4j.ogm.context.MappedRelationship)3 Date (java.util.Date)1 Map (java.util.Map)1 EntityGraphMapper (org.neo4j.ogm.context.EntityGraphMapper)1 Actor (org.neo4j.ogm.domain.cineasts.annotated.Actor)1 Knows (org.neo4j.ogm.domain.cineasts.annotated.Knows)1 SessionFactory (org.neo4j.ogm.session.SessionFactory)1 Event (org.neo4j.ogm.session.event.Event)1 PostSaveEvent (org.neo4j.ogm.session.event.PostSaveEvent)1 PreSaveEvent (org.neo4j.ogm.session.event.PreSaveEvent)1