Search in sources :

Example 46 with ClassInfo

use of org.neo4j.ogm.metadata.ClassInfo 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 47 with ClassInfo

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

Example 48 with ClassInfo

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

the class IterableRelationalReaderWriterTest method testUserV2.

/**
 * @see DATAGRAPH-636
 */
@Test
public void testUserV2() {
    ClassInfo classInfo = this.domainInfo.getClass(UserV2.class.getName());
    UserV2 instance = new UserV2();
    Set<UserV2> relatedObject = Collections.singleton(new UserV2());
    assertThat(EntityAccessManager.getIterableField(classInfo, UserV2.class, KNOWS, Relationship.Direction.INCOMING)).isNull();
    FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV2.class, KNOWS, Relationship.Direction.OUTGOING);
    relationalWriter.write(instance, relatedObject);
    assertThat(instance.getKnows()).isEqualTo(relatedObject);
    assertThat(relationalWriter.read(instance)).isEqualTo(relatedObject);
}
Also used : FieldInfo(org.neo4j.ogm.metadata.FieldInfo) ClassInfo(org.neo4j.ogm.metadata.ClassInfo) Test(org.junit.Test)

Example 49 with ClassInfo

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

the class IterableRelationalReaderWriterTest method testUserV16.

/**
 * @see DATAGRAPH-636
 */
@Test
public void testUserV16() {
    ClassInfo classInfo = this.domainInfo.getClass(UserV16.class.getName());
    UserV16 instance = new UserV16();
    Set<UserV16> relatedObjectOut = Collections.singleton(new UserV16());
    Set<UserV16> relatedObjectIn = Collections.singleton(new UserV16());
    FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV16.class, KNOWS, Relationship.Direction.OUTGOING);
    FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV16.class, KNOWS, Relationship.Direction.OUTGOING);
    relationalWriter.write(instance, relatedObjectOut);
    assertThat(instance.getKnows()).isEqualTo(relatedObjectOut);
    assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectOut);
    instance = new UserV16();
    relationalReader = EntityAccessManager.getIterableField(classInfo, UserV16.class, KNOWS, Relationship.Direction.INCOMING);
    relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV16.class, KNOWS, Relationship.Direction.INCOMING);
    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 50 with ClassInfo

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

the class IterableRelationalReaderWriterTest method testUserV15.

/**
 * @see DATAGRAPH-636
 */
@Test
public void testUserV15() {
    ClassInfo classInfo = this.domainInfo.getClass(UserV15.class.getName());
    UserV15 instance = new UserV15();
    Set<UserV15> relatedObjectOut = Collections.singleton(new UserV15());
    Set<UserV15> relatedObjectIn = Collections.singleton(new UserV15());
    FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, UserV15.class, KNOWS, Relationship.Direction.OUTGOING);
    FieldInfo relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV15.class, KNOWS, Relationship.Direction.OUTGOING);
    relationalWriter.write(instance, relatedObjectOut);
    assertThat(instance.getKnows()).isEqualTo(relatedObjectOut);
    assertThat(relationalReader.read(instance)).isEqualTo(relatedObjectOut);
    instance = new UserV15();
    relationalReader = EntityAccessManager.getIterableField(classInfo, UserV15.class, KNOWS, Relationship.Direction.INCOMING);
    relationalWriter = EntityAccessManager.getIterableField(classInfo, UserV15.class, KNOWS, Relationship.Direction.INCOMING);
    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)

Aggregations

ClassInfo (org.neo4j.ogm.metadata.ClassInfo)145 FieldInfo (org.neo4j.ogm.metadata.FieldInfo)100 Test (org.junit.Test)76 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)8 MetaData (org.neo4j.ogm.metadata.MetaData)8 CompileContext (org.neo4j.ogm.cypher.compiler.CompileContext)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 NodeBuilder (org.neo4j.ogm.cypher.compiler.NodeBuilder)5 MappingException (org.neo4j.ogm.exception.core.MappingException)5 RowModel (org.neo4j.ogm.model.RowModel)5 Collection (java.util.Collection)4 LinkedHashSet (java.util.LinkedHashSet)4 List (java.util.List)4 Optional (java.util.Optional)4 CypherQuery (org.neo4j.ogm.cypher.query.CypherQuery)4 Member (org.neo4j.ogm.domain.forum.Member)4 Satellite (org.neo4j.ogm.domain.satellites.Satellite)4 Collections (java.util.Collections)3