use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV4.
/**
* @see DATAGRAPH-636
*/
@Test
public void testUserV4() {
ClassInfo classInfo = this.domainInfo.getClass(UserV4.class.getName());
UserV4 instance = new UserV4();
Set<UserV4> relatedObject = Collections.singleton(new UserV4());
assertThat(EntityAccessManager.getIterableField(classInfo, UserV4.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV4.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV4.class, KNOWS, Relationship.Direction.INCOMING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV4.class, KNOWS, Relationship.Direction.INCOMING);
relationalWriter.write(instance, relatedObject);
assertThat(instance.getFriend()).isEqualTo(relatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObject);
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV19.
/**
* @see DATAGRAPH-636
*/
@Test
public void testUserV19() {
ClassInfo classInfo = this.domainInfo.getClass(UserV19.class.getName());
UserV19 instance = new UserV19();
Set<UserV19> relatedObject = Collections.singleton(new UserV19());
assertThat(EntityAccessManager.getIterableField(classInfo, UserV19.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV19.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV19.class, KNOWS, Relationship.Direction.INCOMING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV19.class, KNOWS, Relationship.Direction.INCOMING);
relationalWriter.write(instance, relatedObject);
assertThat(instance.getKnows()).isEqualTo(relatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObject);
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV21.
/**
* @see issue #36
*/
@Test
public void testUserV21() {
ClassInfo classInfo = this.domainInfo.getClass(UserV21.class.getName());
UserV21 instance = new UserV21();
PlainUser relatedObject = new PlainUser();
List<UserV21> otherRelatedObject = Collections.singletonList(new UserV21());
assertThat(EntityAccessManager.getIterableField(classInfo, UserV21.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV21.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV21.class, KNOWS, Relationship.Direction.INCOMING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV21.class, KNOWS, Relationship.Direction.INCOMING);
relationalWriter.write(instance, otherRelatedObject);
assertThat(instance.user).isEqualTo(otherRelatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(otherRelatedObject);
instance = new UserV21();
relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.INCOMING, relatedObject);
relationalWriter.write(instance, relatedObject);
assertThat(instance.plainUsers).isEqualTo(relatedObject);
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class RelationalReaderWriterTest method testUserV12.
// DATAGRAPH-636
@Test
public void testUserV12() {
ClassInfo classInfo = this.domainInfo.getClass(UserV12.class.getName());
UserV12 instance = new UserV12();
UserV12 relatedObjectOut = new UserV12();
UserV12 relatedObjectIn = new UserV12();
FieldInfo relationalReader = EntityAccessManager.getRelationalReader(classInfo, LIKES, Relationship.Direction.OUTGOING);
FieldInfo relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, LIKES, Relationship.Direction.OUTGOING, relatedObjectOut);
relationalWriter.write(instance, relatedObjectOut);
assertThat(instance.getFriend()).isEqualTo(relatedObjectOut);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectOut);
relationalReader = EntityAccessManager.getRelationalReader(classInfo, LIKES, Relationship.Direction.INCOMING);
relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, LIKES, Relationship.Direction.INCOMING, relatedObjectIn);
relationalWriter.write(instance, relatedObjectIn);
assertThat(instance.getFriendOf()).isEqualTo(relatedObjectIn);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectIn);
}
use of org.neo4j.ogm.metadata.ClassInfo in project neo4j-ogm by neo4j.
the class RelationalReaderWriterTest method testUserV19.
// DATAGRAPH-636
@Test
public void testUserV19() {
ClassInfo classInfo = this.domainInfo.getClass(UserV19.class.getName());
UserV19 instance = new UserV19();
UserV19 relatedObject = new UserV19();
assertThat(EntityAccessManager.getRelationalReader(classInfo, KNOWS, Relationship.Direction.OUTGOING)).isNull();
assertThat(EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, relatedObject)).isNull();
FieldInfo relationalReader = EntityAccessManager.getRelationalReader(classInfo, KNOWS, Relationship.Direction.INCOMING);
FieldInfo relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.INCOMING, relatedObject);
relationalWriter.write(instance, relatedObject);
assertThat(instance.getKnows()).isEqualTo(relatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObject);
}
Aggregations