use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.
the class EntityGraphMapperTest method shouldGenerateCypherToPersistByteArray.
@Test
public void shouldGenerateCypherToPersistByteArray() {
sessionFactory = new SessionFactory(getDriver(), "org.neo4j.ogm.domain.social");
session = sessionFactory.openSession();
Individual individual = new Individual();
individual.setAge(41);
individual.setBankBalance(1000.50f);
individual.setPrimitiveByteArray(new byte[] { 1, 2, 3, 4, 5 });
session.save(individual);
session.query("CREATE (:Individual {age:41, bankBalance: 1000.50, code:0, primitiveByteArray:'AQIDBAU='})", emptyMap());
session.clear();
Iterable<Map<String, Object>> executionResult = session.query("MATCH (i:Individual) RETURN i.primitiveByteArray AS bytes", emptyMap()).queryResults();
Map<String, Object> result = executionResult.iterator().next();
assertThat(result.get("bytes")).as("The array wasn't persisted as the correct type").isEqualTo(// Byte arrays are converted to Base64 Strings
"AQIDBAU=");
}
use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.
the class EntityGraphMapperTest method shouldGenerateCypherToPersistCollectionOfBoxedPrimitivesToArrayOfPrimitives.
@Test
public void shouldGenerateCypherToPersistCollectionOfBoxedPrimitivesToArrayOfPrimitives() {
sessionFactory = new SessionFactory(getDriver(), "org.neo4j.ogm.domain.social");
session = sessionFactory.openSession();
Individual individual = new Individual();
individual.setName("Gary");
individual.setAge(36);
individual.setBankBalance(99.25f);
individual.setFavouriteRadioStations(new Vector<>(Arrays.asList(97.4, 105.4, 98.2)));
session.save(individual);
session.clear();
assertThat(session.query("MATCH (a:Individual " + "{name:'Gary', age:36, bankBalance:99.25, code:0, favouriteRadioStations:[97.4, 105.4, 98.2]}) " + "return a", emptyMap()).queryResults()).hasSize(1);
}
use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.
the class EntityGraphMapperTest method shouldGenerateCypherToPersistArraysOfPrimitives.
@Test
public void shouldGenerateCypherToPersistArraysOfPrimitives() {
sessionFactory = new SessionFactory(getDriver(), "org.neo4j.ogm.domain.social");
session = sessionFactory.openSession();
Individual individual = new Individual();
individual.setName("Jeff");
individual.setAge(41);
individual.setBankBalance(1000.50f);
individual.setPrimitiveIntArray(new int[] { 1, 6, 4, 7, 2 });
session.save(individual);
session.clear();
Individual loadedIndividual = session.load(Individual.class, individual.getId());
assertThat(loadedIndividual.getPrimitiveIntArray()).isEqualTo(individual.getPrimitiveIntArray());
}
use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.
the class SocialIntegrationTest method shouldFetchFriendsInBothDirections.
/**
* @see DATAGRAPH-594
*/
@Test
public void shouldFetchFriendsInBothDirections() {
session.query("create (p1:Individual {name:'A'}) create (p2:Individual {name:'B'}) create (p3:Individual {name:'C'})" + " create (p4:Individual {name:'D'}) create (p1)-[:FRIENDS]->(p2) create (p1)-[:FRIENDS]->(p3) create (p4)-[:FRIENDS]->(p1)", Collections.EMPTY_MAP);
Individual individualA = session.loadAll(Individual.class, new Filter("name", ComparisonOperator.EQUALS, "A")).iterator().next();
assertThat(individualA).isNotNull();
assertThat(individualA.getFriends()).hasSize(2);
}
use of org.neo4j.ogm.domain.social.Individual in project neo4j-ogm by neo4j.
the class ArraysMappingTest method shouldGenerateCypherToPersistArraysOfPrimitives.
@Test
public void shouldGenerateCypherToPersistArraysOfPrimitives() {
Individual individual = new Individual();
individual.setName("Jeff");
individual.setAge(41);
individual.setBankBalance(1000.50f);
individual.setPrimitiveIntArray(new int[] { 1, 6, 4, 7, 2 });
session.save(individual);
session.clear();
assertThat(session.query("MATCH (i:Individual {name:'Jeff', age:41, bankBalance: 1000.50, code:0, primitiveIntArray:[1,6,4,7,2]}) " + "return i", emptyMap()).queryResults()).hasSize(1);
session.clear();
Individual loadedIndividual = session.load(Individual.class, individual.getId());
assertThat(loadedIndividual.getPrimitiveIntArray()).isEqualTo(individual.getPrimitiveIntArray());
}
Aggregations