use of org.neo4j.ogm.session.event.PostSaveEvent in project neo4j-ogm by neo4j.
the class RelationshipEntityTest method shouldFireEventsWhenCreatingRelationshipEntity.
@Test
public void shouldFireEventsWhenCreatingRelationshipEntity() {
Knows knowsBS = new Knows();
knowsBS.setFirstActor(bruce);
knowsBS.setSecondActor(stan);
bruce.getKnows().add(knowsBS);
session.save(bruce);
assertThat(eventListener.captured(knowsBS, Event.TYPE.PRE_SAVE)).isTrue();
assertThat(((PreSaveEvent) eventListener.get(knowsBS, Event.TYPE.PRE_SAVE)).isNew()).isTrue();
assertThat(eventListener.captured(knowsBS, Event.TYPE.POST_SAVE)).isTrue();
assertThat(((PostSaveEvent) eventListener.get(knowsBS, Event.TYPE.POST_SAVE)).wasNew()).isTrue();
assertThat(eventListener.captured(bruce, Event.TYPE.PRE_SAVE)).isTrue();
assertThat(((PreSaveEvent) eventListener.get(bruce, Event.TYPE.PRE_SAVE)).isNew()).isFalse();
assertThat(eventListener.captured(bruce, Event.TYPE.POST_SAVE)).isTrue();
assertThat(((PostSaveEvent) eventListener.get(bruce, Event.TYPE.POST_SAVE)).wasNew()).isFalse();
assertThat(eventListener.captured(stan, Event.TYPE.PRE_SAVE)).isTrue();
assertThat(((PreSaveEvent) eventListener.get(stan, Event.TYPE.PRE_SAVE)).isNew()).isFalse();
assertThat(eventListener.captured(stan, Event.TYPE.POST_SAVE)).isTrue();
assertThat(((PostSaveEvent) eventListener.get(stan, Event.TYPE.POST_SAVE)).wasNew()).isFalse();
assertThat(eventListener.count()).isEqualTo(6);
}
use of org.neo4j.ogm.session.event.PostSaveEvent in project neo4j-ogm by neo4j.
the class NodeEntityTest method shouldFireEventsWhenCreatingNewEntity.
@Test
public void shouldFireEventsWhenCreatingNewEntity() {
Document e = new Document();
e.setName("e");
session.save(e);
assertThat(eventListener.count()).isEqualTo(2);
Event captured = eventListener.get(e, Event.TYPE.PRE_SAVE);
assertThat(captured).isNotNull();
assertThat(((PreSaveEvent) captured).isNew()).isTrue();
captured = eventListener.get(e, Event.TYPE.POST_SAVE);
assertThat(captured).isNotNull();
assertThat(((PostSaveEvent) captured).wasNew()).isTrue();
}
use of org.neo4j.ogm.session.event.PostSaveEvent in project neo4j-ogm by neo4j.
the class NodeEntityTest method shouldFireEventsWhenUpdatingExistingEntity.
@Test
public void shouldFireEventsWhenUpdatingExistingEntity() {
a.setName("newA");
session.save(a);
assertThat(eventListener.count()).isEqualTo(2);
Event captured = eventListener.get(a, Event.TYPE.PRE_SAVE);
assertThat(captured).isNotNull();
assertThat(((PreSaveEvent) captured).isNew()).isFalse();
captured = eventListener.get(a, Event.TYPE.POST_SAVE);
assertThat(captured).isNotNull();
assertThat(((PostSaveEvent) captured).wasNew()).isFalse();
}
Aggregations