Search in sources :

Example 51 with FieldInfo

use of org.neo4j.ogm.metadata.FieldInfo 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);
}
Also used : FieldInfo(org.neo4j.ogm.metadata.FieldInfo) ClassInfo(org.neo4j.ogm.metadata.ClassInfo) Test(org.junit.Test)

Example 52 with FieldInfo

use of org.neo4j.ogm.metadata.FieldInfo 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);
}
Also used : FieldInfo(org.neo4j.ogm.metadata.FieldInfo) ClassInfo(org.neo4j.ogm.metadata.ClassInfo) Test(org.junit.Test)

Example 53 with FieldInfo

use of org.neo4j.ogm.metadata.FieldInfo 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);
}
Also used : FieldInfo(org.neo4j.ogm.metadata.FieldInfo) ClassInfo(org.neo4j.ogm.metadata.ClassInfo) Test(org.junit.Test)

Example 54 with FieldInfo

use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.

the class RelationalReaderWriterTest method testUserV15.

// DATAGRAPH-636
@Test
public void testUserV15() {
    ClassInfo classInfo = this.domainInfo.getClass(UserV15.class.getName());
    UserV15 instance = new UserV15();
    UserV15 relatedObjectOut = new UserV15();
    UserV15 relatedObjectIn = new UserV15();
    FieldInfo relationalReader = EntityAccessManager.getRelationalReader(classInfo, KNOWS, Relationship.Direction.OUTGOING);
    FieldInfo relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, relatedObjectOut);
    relationalWriter.write(instance, relatedObjectOut);
    assertThat(instance.getKnows()).isEqualTo(relatedObjectOut);
    assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectOut);
    instance = new UserV15();
    relationalReader = EntityAccessManager.getRelationalReader(classInfo, KNOWS, Relationship.Direction.INCOMING);
    relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.INCOMING, relatedObjectIn);
    relationalWriter.write(instance, relatedObjectIn);
    assertThat(instance.getKnows()).isEqualTo(relatedObjectIn);
    assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectIn);
}
Also used : FieldInfo(org.neo4j.ogm.metadata.FieldInfo) ClassInfo(org.neo4j.ogm.metadata.ClassInfo) Test(org.junit.Test)

Example 55 with FieldInfo

use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.

the class RelationalReaderWriterTest method testUserV20.

// GH-36
@Test
public void testUserV20() {
    ClassInfo classInfo = this.domainInfo.getClass(UserV20.class.getName());
    UserV20 instance = new UserV20();
    UserV20 relatedObject = new UserV20();
    PlainUser otherRelatedObject = new PlainUser();
    assertThat(EntityAccessManager.getRelationalReader(classInfo, KNOWS, Relationship.Direction.OUTGOING)).isNull();
    assertThat(EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, relatedObject)).isNull();
    FieldInfo relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.INCOMING, relatedObject);
    relationalWriter.write(instance, relatedObject);
    assertThat(instance.getUser()).isEqualTo(relatedObject);
    assertThat(EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.OUTGOING, otherRelatedObject)).isNull();
    relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWS, Relationship.Direction.INCOMING, otherRelatedObject);
    relationalWriter.write(instance, otherRelatedObject);
    assertThat(instance.getPlainUser()).isEqualTo(otherRelatedObject);
}
Also used : FieldInfo(org.neo4j.ogm.metadata.FieldInfo) ClassInfo(org.neo4j.ogm.metadata.ClassInfo) Test(org.junit.Test)

Aggregations

FieldInfo (org.neo4j.ogm.metadata.FieldInfo)142 Test (org.junit.Test)102 ClassInfo (org.neo4j.ogm.metadata.ClassInfo)100 ArrayList (java.util.ArrayList)12 Date (java.util.Date)7 HashSet (java.util.HashSet)6 HashMap (java.util.HashMap)5 Collection (java.util.Collection)4 Satellite (org.neo4j.ogm.domain.satellites.Satellite)4 MappingException (org.neo4j.ogm.exception.core.MappingException)4 CompileContext (org.neo4j.ogm.cypher.compiler.CompileContext)3 Person (org.neo4j.ogm.domain.convertible.enums.Person)3 Member (org.neo4j.ogm.domain.forum.Member)3 Topic (org.neo4j.ogm.domain.forum.Topic)3 Post (org.neo4j.ogm.domain.forum.activity.Post)3 MetaData (org.neo4j.ogm.metadata.MetaData)3 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2