use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class RelationalReaderWriterTest method testUserV21.
// GH-36
@Test
public void testUserV21() {
ClassInfo classInfo = this.domainInfo.getClass(UserV21.class.getName());
UserV21 instance = new UserV21();
UserV21 relatedObject = new UserV21();
PlainUser otherRelatedObject = new PlainUser();
assertThat(EntityAccessManager.getRelationalReader(classInfo, KNOWS, Relationship.Direction.INCOMING)).isNull();
assertThat(EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.INCOMING, relatedObject)).isNull();
FieldInfo relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, relatedObject);
relationalWriter.write(instance, relatedObject);
assertThat(instance.getUser()).isEqualTo(relatedObject);
assertThat(EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.INCOMING, otherRelatedObject)).isNull();
relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, otherRelatedObject);
relationalWriter.write(instance, otherRelatedObject);
assertThat(instance.getPlainUser()).isEqualTo(otherRelatedObject);
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class RelationalReaderWriterTest method testUserV6.
// DATAGRAPH-636
@Test
public void testUserV6() {
ClassInfo classInfo = this.domainInfo.getClass(UserV6.class.getName());
UserV6 instance = new UserV6();
UserV6 relatedObject = new UserV6();
FieldInfo relationalReader = EntityAccessManager.getRelationalReader(classInfo, KNOWS, Relationship.Direction.OUTGOING);
FieldInfo relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, relatedObject);
relationalWriter.write(instance, relatedObject);
assertThat(instance.getKnowsPerson()).isEqualTo(relatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObject);
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class RelationshipWriterAnnotatedFieldsTest method shouldFindWriterForCollection.
@Test
public void shouldFindWriterForCollection() {
ClassInfo classInfo = this.domainInfo.getClass(S.class.getName());
FieldInfo objectAccess = EntityAccessManager.getRelationalWriter(classInfo, "LIST", Relationship.Direction.OUTGOING, new T());
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
assertThat(objectAccess instanceof FieldInfo).as("The access mechanism should be via the field").isTrue();
assertThat(objectAccess.relationship()).isEqualTo("LIST");
assertThat(objectAccess.type()).isEqualTo(List.class);
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class RelationshipWriterPlainFieldsTest method shouldFindWriterForCollection.
@Test
public void shouldFindWriterForCollection() {
ClassInfo classInfo = this.domainInfo.getClass(S.class.getName());
FieldInfo objectAccess = EntityAccessManager.getRelationalWriter(classInfo, "LIST", Relationship.Direction.OUTGOING, new T());
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
assertThat(objectAccess instanceof FieldInfo).as("The access mechanism should be via the field").isTrue();
assertThat(objectAccess.relationship()).isEqualTo("LIST");
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class AnnotatedFieldAndNoSetterTest method shouldPreferAnnotatedFieldInAbsenceOfSetterForRelationshipEntity.
@Test
public void shouldPreferAnnotatedFieldInAbsenceOfSetterForRelationshipEntity() {
ClassInfo classInfo = this.domainInfo.getClass(End.class.getName());
RelEntity relEntity = new RelEntity();
Set<RelEntity> parameter = new HashSet();
parameter.addAll(Arrays.asList(relEntity));
FieldInfo objectAccess = EntityAccessManager.getRelationalWriter(classInfo, "REL_ENTITY_TYPE", Relationship.Direction.INCOMING, relEntity);
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
assertThat(objectAccess instanceof FieldInfo).as("The access mechanism should be via the field").isTrue();
End end = new End();
objectAccess.write(end, parameter);
assertThat(parameter).isEqualTo(end.getRelEntities());
}
Aggregations