Search in sources :

Example 6 with MetaData

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

the class SingleUseEntityMapperTest method shouldMapFromMap.

@Test
public void shouldMapFromMap() {
    MetaData metaData = new MetaData("org.neo4j.ogm.context");
    SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(metaData, new ReflectionEntityInstantiator(metaData));
    Collection<Object> toReturn = new ArrayList<>();
    Iterable<Map<String, Object>> results = getQueryResults();
    for (Map<String, Object> result : results) {
        toReturn.add(entityMapper.map(UserResult.class, result));
    }
    assertThat(toReturn).hasSize(1);
    assertThat(toReturn).first().isInstanceOf(UserResult.class);
    UserResult userResult = (UserResult) toReturn.iterator().next();
    assertThat(userResult.getProfile()).containsAllEntriesOf((Map<? extends String, ?>) results.iterator().next().get("profile"));
}
Also used : MetaData(org.neo4j.ogm.metadata.MetaData) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) ReflectionEntityInstantiator(org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator) Test(org.junit.Test)

Example 7 with MetaData

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

the class DirectRelationshipsTest method setUpTestDatabase.

@BeforeClass
public static void setUpTestDatabase() {
    mappingMetadata = new MetaData("org.neo4j.ogm.domain.filesystem");
    mappingContext = new MappingContext(mappingMetadata);
}
Also used : MappingContext(org.neo4j.ogm.context.MappingContext) MetaData(org.neo4j.ogm.metadata.MetaData) BeforeClass(org.junit.BeforeClass)

Example 8 with MetaData

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

the class CompilerTest method setUpTestDatabase.

@BeforeClass
public static void setUpTestDatabase() {
    mappingMetadata = new MetaData("org.neo4j.ogm.domain.education", "org.neo4j.ogm.domain.forum", "org.neo4j.ogm.domain.social", "org.neo4j.domain.policy", "org.neo4j.ogm.domain.music", "org.neo4j.ogm.domain.restaurant", "org.neo4j.ogm.domain.travel");
    mappingContext = new MappingContext(mappingMetadata);
}
Also used : MappingContext(org.neo4j.ogm.context.MappingContext) MetaData(org.neo4j.ogm.metadata.MetaData) BeforeClass(org.junit.BeforeClass)

Example 9 with MetaData

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

the class CyclicStructureTest method mapAndCompile.

private static Compiler mapAndCompile(Neo4jSession session, Object object, int depth) {
    final MetaData metaData = session.metaData();
    final MappingContext mappingContext = new MappingContext(metaData);
    EntityMapper mapper = new EntityGraphMapper(metaData, mappingContext);
    CompileContext context = mapper.map(object, depth);
    Compiler compiler = context.getCompiler();
    compiler.useStatementFactory(new RowStatementFactory());
    return compiler;
}
Also used : MappingContext(org.neo4j.ogm.context.MappingContext) EntityGraphMapper(org.neo4j.ogm.context.EntityGraphMapper) MetaData(org.neo4j.ogm.metadata.MetaData) RowStatementFactory(org.neo4j.ogm.session.request.RowStatementFactory) EntityMapper(org.neo4j.ogm.context.EntityMapper)

Example 10 with MetaData

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

the class InvalidMetadataAutoIndexManagerTest method shouldCheckPropertiesMatchFieldNames.

@Test(expected = MetadataException.class)
public void shouldCheckPropertiesMatchFieldNames() {
    MetaData metadata = new MetaData(WrongPropertyCompositeIndexEntity.class.getName());
    ClassInfo classInfo = metadata.classInfo(WrongPropertyCompositeIndexEntity.class.getName());
    classInfo.getCompositeIndexes();
}
Also used : WrongPropertyCompositeIndexEntity(org.neo4j.ogm.domain.autoindex.invalid.WrongPropertyCompositeIndexEntity) MetaData(org.neo4j.ogm.metadata.MetaData) ClassInfo(org.neo4j.ogm.metadata.ClassInfo) Test(org.junit.Test)

Aggregations

MetaData (org.neo4j.ogm.metadata.MetaData)21 Test (org.junit.Test)11 ClassInfo (org.neo4j.ogm.metadata.ClassInfo)6 MappingContext (org.neo4j.ogm.context.MappingContext)5 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 BeforeClass (org.junit.BeforeClass)3 RealNode (org.neo4j.ogm.domain.gh619.model.RealNode)3 Neo4jSession (org.neo4j.ogm.session.Neo4jSession)3 Map (java.util.Map)2 ReflectionEntityInstantiator (org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator)2 Serializable (java.io.Serializable)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1