Search in sources :

Example 61 with FieldInfo

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

the class RelationalReaderWriterTest method testUserV8.

// DATAGRAPH-636
@Test
public void testUserV8() {
    ClassInfo classInfo = this.domainInfo.getClass(UserV8.class.getName());
    UserV8 instance = new UserV8();
    UserV8 relatedObject = new UserV8();
    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 62 with FieldInfo

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

the class RelationalReaderWriterTest method testUserV1.

// DATAGRAPH-636
@Test
public void testUserV1() {
    final String KNOWN_BY = "KNOWN_BY";
    ClassInfo classInfo = this.domainInfo.getClass(UserV1.class.getName());
    UserV1 instance = new UserV1();
    UserV1 relatedObject = new UserV1();
    assertThat(EntityAccessManager.getRelationalReader(classInfo, KNOWN_BY, Relationship.Direction.OUTGOING)).isNull();
    assertThat(EntityAccessManager.getRelationalWriter(classInfo, KNOWN_BY, Relationship.Direction.OUTGOING, relatedObject)).isNull();
    FieldInfo relationalReader = EntityAccessManager.getRelationalReader(classInfo, KNOWN_BY, Relationship.Direction.INCOMING);
    FieldInfo relationalWriter = EntityAccessManager.getRelationalWriter(classInfo, KNOWN_BY, Relationship.Direction.INCOMING, relatedObject);
    relationalWriter.write(instance, relatedObject);
    assertThat(instance.getKnownBy()).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 63 with FieldInfo

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

the class RelationalReaderWriterTest method testUserV11.

// DATAGRAPH-636
@Test
public void testUserV11() {
    ClassInfo classInfo = this.domainInfo.getClass(UserV11.class.getName());
    UserV11 instance = new UserV11();
    UserV11 relatedObjectOut = new UserV11();
    UserV11 relatedObjectIn = new UserV11();
    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 64 with FieldInfo

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

Example 65 with FieldInfo

use of org.neo4j.ogm.metadata.FieldInfo 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);
}
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