Search in sources :

Example 11 with Individual

use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.

the class SocialRelationshipsIntegrationTest method saveUnmarkedSavesOutgoingRelationship.

// DATAGRAPH-594
@Test
public void saveUnmarkedSavesOutgoingRelationship() {
    Individual individualA = new Individual();
    individualA.setName("A");
    Individual individualB = new Individual();
    individualB.setName("B");
    individualA.setFriends(Collections.singletonList(individualB));
    session.save(individualA);
    session.clear();
    assertThat(session.query("MATCH (a:Individual {name:'A', age: 0, code:0, bankBalance:0.0})," + "(b:Individual {name:'B', age:0, code:0, bankBalance:0.0}) WHERE (a)-[:FRIENDS]->(b) " + "return a,b", emptyMap()).queryResults()).hasSize(1);
}
Also used : Individual(org.neo4j.ogm.domain.social.Individual) Test(org.junit.Test)

Example 12 with Individual

use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.

the class EntityFactoryTest method shouldConstructObjectOfParticularTypeUsingItsDefaultZeroArgConstructor.

@Test
public void shouldConstructObjectOfParticularTypeUsingItsDefaultZeroArgConstructor() {
    NodeModel personNodeModel = new NodeModel(-1L);
    personNodeModel.setLabels(new String[] { "Individual" });
    Individual sheila = this.entityFactory.newObject(personNodeModel);
    assertThat(sheila).isNotNull();
}
Also used : NodeModel(org.neo4j.ogm.response.model.NodeModel) Individual(org.neo4j.ogm.domain.social.Individual) Test(org.junit.Test)

Example 13 with Individual

use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.

the class EntityFactoryTest method shouldConstructObjectIfExplicitlyGivenClassToInstantiate.

@Test
public void shouldConstructObjectIfExplicitlyGivenClassToInstantiate() {
    Individual instance = this.entityFactory.newObject(Individual.class, new HashMap<>());
    assertThat(instance).as("The resultant instance shouldn't be null").isNotNull();
}
Also used : Individual(org.neo4j.ogm.domain.social.Individual) Test(org.junit.Test)

Example 14 with Individual

use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.

the class EntityFactoryTest method shouldHandleMultipleLabelsSafely.

@Test
public void shouldHandleMultipleLabelsSafely() {
    NodeModel personNodeModel = new NodeModel(-1L);
    personNodeModel.setLabels(new String[] { "Female", "Individual", "Lass" });
    Individual ourLass = this.entityFactory.newObject(personNodeModel);
    assertThat(ourLass).isNotNull();
}
Also used : NodeModel(org.neo4j.ogm.response.model.NodeModel) Individual(org.neo4j.ogm.domain.social.Individual) Test(org.junit.Test)

Example 15 with Individual

use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.

the class ArraysMappingTest method shouldDeserializeByteArrays.

@Test
public void shouldDeserializeByteArrays() {
    long id = (long) session.query("CREATE (i:Individual {age:42, bankBalance: 23, code:6, primitiveByteArray:'AQIDBAU='}) return id(i) as id", Collections.emptyMap()).queryResults().iterator().next().get("id");
    session.clear();
    Session freshSession = sessionFactory.openSession();
    Individual loadedIndividual = freshSession.load(Individual.class, id);
    assertThat(loadedIndividual.getPrimitiveByteArray()).isEqualTo(new byte[] { 1, 2, 3, 4, 5 });
}
Also used : Individual(org.neo4j.ogm.domain.social.Individual) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 Individual (org.neo4j.ogm.domain.social.Individual)16 Map (java.util.Map)3 SessionFactory (org.neo4j.ogm.session.SessionFactory)3 HashMap (java.util.HashMap)2 NodeModel (org.neo4j.ogm.response.model.NodeModel)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Filter (org.neo4j.ogm.cypher.Filter)1 Statement (org.neo4j.ogm.request.Statement)1 Session (org.neo4j.ogm.session.Session)1