use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV22.
/**
* @see issue #36
*/
@Test
public void testUserV22() {
ClassInfo classInfo = this.domainInfo.getClass(UserV22.class.getName());
UserV22 instance = new UserV22();
List<PlainUser> relatedObject = Collections.singletonList(new PlainUser());
UserV22 otherRelatedObject = new UserV22();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV22.class, KNOWS, Relationship.Direction.INCOMING)).isNull();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV22.class, KNOWS, Relationship.Direction.INCOMING)).isNull();
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, PlainUser.class, KNOWS, Relationship.Direction.OUTGOING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, PlainUser.class, KNOWS, Relationship.Direction.OUTGOING);
relationalWriter.write(instance, relatedObject);
assertThat(instance.plainUsers).isEqualTo(relatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObject);
instance = new UserV22();
relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, otherRelatedObject);
relationalWriter.write(instance, otherRelatedObject);
assertThat(instance.user).isEqualTo(otherRelatedObject);
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV3.
/**
* @see DATAGRAPH-636
*/
@Test
public void testUserV3() {
ClassInfo classInfo = this.domainInfo.getClass(UserV3.class.getName());
UserV3 instance = new UserV3();
Set<UserV3> relatedObject = Collections.singleton(new UserV3());
assertThat(EntityAccessManager.getIterableField(classInfo, UserV3.class, KNOWS, Relationship.Direction.INCOMING)).isNull();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV3.class, KNOWS, Relationship.Direction.INCOMING)).isNull();
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV3.class, KNOWS, Relationship.Direction.OUTGOING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV3.class, KNOWS, Relationship.Direction.OUTGOING);
relationalWriter.write(instance, relatedObject);
assertThat(instance.getFriend()).isEqualTo(relatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObject);
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV20.
/**
* @see issue #36
*/
@Test
public void testUserV20() {
ClassInfo classInfo = this.domainInfo.getClass(UserV20.class.getName());
UserV20 instance = new UserV20();
List<PlainUser> relatedObject = Collections.singletonList(new PlainUser());
UserV20 otherRelatedObject = new UserV20();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV20.class, KNOWS, Relationship.Direction.INCOMING)).isNull();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV20.class, KNOWS, Relationship.Direction.INCOMING)).isNull();
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, PlainUser.class, KNOWS, Relationship.Direction.OUTGOING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, PlainUser.class, KNOWS, Relationship.Direction.OUTGOING);
relationalWriter.write(instance, relatedObject);
assertThat(instance.plainUsers).isEqualTo(relatedObject);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObject);
instance = new UserV20();
relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, otherRelatedObject);
relationalWriter.write(instance, otherRelatedObject);
assertThat(instance.user).isEqualTo(otherRelatedObject);
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV8.
/**
* @see DATAGRAPH-636
*/
@Test
public void testUserV8() {
ClassInfo classInfo = this.domainInfo.getClass(UserV8.class.getName());
UserV8 instance = new UserV8();
Set<UserV8> relatedObject = Collections.singleton(new UserV8());
assertThat(EntityAccessManager.getIterableField(classInfo, UserV8.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
assertThat(EntityAccessManager.getIterableField(classInfo, UserV8.class, KNOWS, Relationship.Direction.OUTGOING)).isNull();
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV8.class, KNOWS, Relationship.Direction.INCOMING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV8.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.FieldInfo in project neo4j-ogm by neo4j.
the class IterableRelationalReaderWriterTest method testUserV12.
/**
* @see DATAGRAPH-636
*/
@Test
public void testUserV12() {
ClassInfo classInfo = this.domainInfo.getClass(UserV12.class.getName());
UserV12 instance = new UserV12();
Set<UserV12> relatedObjectOut = Collections.singleton(new UserV12());
Set<UserV12> relatedObjectIn = Collections.singleton(new UserV12());
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV12.class, LIKES, Relationship.Direction.OUTGOING);
FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV12.class, LIKES, Relationship.Direction.OUTGOING);
relationalWriter.write(instance, relatedObjectOut);
assertThat(instance.getFriend()).isEqualTo(relatedObjectOut);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectOut);
relationalReader = EntityAccessManager.getIterableField(classInfo, UserV12.class, LIKES, Relationship.Direction.INCOMING);
relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV12.class, LIKES, Relationship.Direction.INCOMING);
relationalWriter.write(instance, relatedObjectIn);
assertThat(instance.getFriendOf()).isEqualTo(relatedObjectIn);
assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectIn);
}
Aggregations