Search in sources :

Example 16 with Document

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

the class DirtyObjectsTest method newObjectShouldBeDirty.

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

Example 17 with Document

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

the class DirtyObjectsTest method evictedObjectShouldBeDirty.

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

Example 18 with Document

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

the class DirtyObjectsTest method unmodifiedLoadedObjectShouldNotBeDirty.

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

Example 19 with Document

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

the class DirtyObjectsTest method evictedObjectThatIsIdenticalToTheLoadedObjectShouldNotBeDirty.

@Test
public void evictedObjectThatIsIdenticalToTheLoadedObjectShouldNotBeDirty() {
    Document d = new Document();
    session.save(d);
    session.clear();
    Document d2 = session.load(Document.class, d.getId());
    assertThat(session.context().isDirty(d)).isFalse();
    assertThat(session.context().isDirty(d2)).isFalse();
}
Also used : Document(org.neo4j.ogm.domain.filesystem.Document) Test(org.junit.Test)

Example 20 with Document

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

the class StaleObjectTest method init.

@Before
public void init() throws IOException {
    SessionFactory sessionFactory = new SessionFactory(getDriver(), "org.neo4j.ogm.domain.filesystem");
    session = sessionFactory.openSession();
    session.purgeDatabase();
    a = new Document();
    a.setName("a");
    b = new Document();
    b.setName("b");
    f = new Folder();
    f.setName("f");
    f.getDocuments().add(a);
    f.getDocuments().add(b);
    a.setFolder(f);
    b.setFolder(f);
    session.save(f);
    assertThat(a.toString()).isEqualTo("Document{folder=Folder{name='f', documents=2, archived=0}, name='a'}");
    assertThat(b.toString()).isEqualTo("Document{folder=Folder{name='f', documents=2, archived=0}, name='b'}");
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) Document(org.neo4j.ogm.domain.filesystem.Document) Folder(org.neo4j.ogm.domain.filesystem.Folder) Before(org.junit.Before)

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