Search in sources :

Example 41 with FieldInfo

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

Example 42 with FieldInfo

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

Example 43 with FieldInfo

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

Example 44 with FieldInfo

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

Example 45 with FieldInfo

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);
}
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