use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class AssociatedObjectsTest method shouldFireEventsWhenAddNewObjectInCollectionAndSaveCollection.
@Test
public void shouldFireEventsWhenAddNewObjectInCollectionAndSaveCollection() {
// add a new document to an existing folder and save the document
Document z = new Document();
z.setFolder(folder);
folder.getDocuments().add(z);
session.save(folder);
assertThat(eventListener.captured(z, Event.TYPE.PRE_SAVE)).isTrue();
assertThat(eventListener.captured(z, Event.TYPE.POST_SAVE)).isTrue();
assertThat(eventListener.captured(folder, Event.TYPE.PRE_SAVE)).isTrue();
assertThat(eventListener.captured(folder, Event.TYPE.POST_SAVE)).isTrue();
assertThat(eventListener.count()).isEqualTo(4);
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class AssociatedObjectsTest method shouldFireEventsWhenAddNewObjectToCollectionAndSaveNewObject.
@Test
public void shouldFireEventsWhenAddNewObjectToCollectionAndSaveNewObject() {
// add a new document to an existing folder and save the document
Document z = new Document();
z.setFolder(folder);
folder.getDocuments().add(z);
session.save(z);
assertThat(eventListener.captured(z, Event.TYPE.PRE_SAVE)).isTrue();
assertThat(eventListener.captured(z, Event.TYPE.POST_SAVE)).isTrue();
assertThat(eventListener.captured(folder, Event.TYPE.PRE_SAVE)).isTrue();
assertThat(eventListener.captured(folder, Event.TYPE.POST_SAVE)).isTrue();
assertThat(eventListener.count()).isEqualTo(4);
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class EventTestBaseClass method init.
@Before
public void init() throws IOException {
session = sessionFactory.openSession();
session.purgeDatabase();
a = new Document();
a.setName("a");
b = new Document();
b.setName("b");
c = new Document();
c.setName("c");
d = new Document();
d.setName("d");
e = new Document();
e.setName("e");
folder = new Folder();
folder.setName("folder");
folder.getDocuments().add(a);
folder.getDocuments().add(b);
folder.getDocuments().add(c);
a.setFolder(folder);
b.setFolder(folder);
c.setFolder(folder);
session.save(d);
session.save(e);
session.save(folder);
jim = new Actor("Jim");
bruce = new Actor("Bruce");
lee = new Actor("Lee");
stan = new Actor("Stan");
knowsJB = new Knows();
knowsJB.setFirstActor(jim);
knowsJB.setSecondActor(bruce);
knowsJB.setSince(new Date());
jim.getKnows().add(knowsJB);
knowsJL = new Knows();
knowsJL.setFirstActor(jim);
knowsJL.setSecondActor(lee);
knowsJL.setSince(new Date());
jim.getKnows().add(knowsJL);
knowsLS = new Knows();
knowsLS.setFirstActor(lee);
knowsLS.setSecondActor(stan);
knowsLS.setSince(new Date());
lee.getKnows().add(knowsLS);
session.save(jim);
eventListener.clear();
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class NodeEntityTest method shouldNotFireEventsWhenDeletingNonPersistedObject.
@Test
public void shouldNotFireEventsWhenDeletingNonPersistedObject() {
Document unpersistedDocument = new Document();
session.delete(unpersistedDocument);
assertThat(eventListener.count()).isEqualTo(0);
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class DegenerateEntityModelTests method testSaveChangedFolder.
@Test
public void testSaveChangedFolder() {
Document c = new Document();
c.setName("c");
f.getDocuments().add(c);
f.getDocuments().remove(a);
session.save(f);
session.clear();
assertThat(session.query("MATCH (f:Folder { name: 'f' }), " + "(a:Document { name: 'a' } ), " + "(b:Document { name: 'b' } ), " + "(c:Document { name: 'c' } ) " + "WHERE (f)-[:CONTAINS]->(b) and " + "(f)-[:CONTAINS]->(c) return f, a, b, c", emptyMap()).queryResults()).hasSize(1);
}
Aggregations