use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class RelationshipEntityMappingTest method testThatRelationshipEntityNameIsUsedAsRelationshipTypeWhenTypeIsNotDefined.
@Test
public void testThatRelationshipEntityNameIsUsedAsRelationshipTypeWhenTypeIsNotDefined() {
Movie hp = new Movie("Goblet of Fire", 2005);
Actor daniel = new Actor("Daniel Radcliffe");
daniel.nominatedFor(hp, "Saturn Award", 2005);
session.save(daniel);
session.clear();
assertThat(session.query("MATCH (m:Movie {uuid:\"" + hp.getUuid().toString() + "\"}), " + "(a:Actor {uuid:\"" + daniel.getUuid().toString() + "\"}) " + " WHERE m.title = 'Goblet of Fire' and m.year = 2005 " + " and a.name='Daniel Radcliffe' and (a)-[:NOMINATIONS {name:'Saturn Award', year:2005}]->(m) " + " return m, a", emptyMap()).queryResults()).hasSize(1);
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method modifyingQueryShouldBePermittedWhenQueryingForObjects.
// DATAGRAPH-697
@Test
public void modifyingQueryShouldBePermittedWhenQueryingForObjects() {
session.save(new Actor("Jeff"));
session.save(new Actor("John"));
session.save(new Actor("Colin"));
Iterable<Actor> actors = session.query(Actor.class, "MATCH (a:Actor) set a.age=$age return a", Collections.singletonMap("age", 40));
assertThat(actors).isNotNull();
List<String> names = new ArrayList<>();
Iterator<Actor> actorIterator = actors.iterator();
while (actorIterator.hasNext()) {
names.add(actorIterator.next().getName());
}
assertThat(names).hasSize(3);
assertThat(names.contains("Jeff")).isTrue();
assertThat(names.contains("John")).isTrue();
assertThat(names.contains("Colin")).isTrue();
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method modifyingQueryShouldReturnStatistics.
// DATAGRAPH-697
@Test
public void modifyingQueryShouldReturnStatistics() {
session.save(new Actor("Jeff"));
session.save(new Actor("John"));
session.save(new Actor("Colin"));
Result result = session.query("MATCH (a:Actor) SET a.age=$age", Collections.singletonMap("age", 5), false);
assertThat(result).isNotNull();
assertThat(result.queryStatistics()).isNotNull();
assertThat(result.queryStatistics().getPropertiesSet()).isEqualTo(3);
result = session.query("MATCH (a:Actor) SET a.age=$age", Collections.singletonMap("age", 5));
assertThat(result).isNotNull();
assertThat(result.queryStatistics()).isNotNull();
assertThat(result.queryStatistics().getPropertiesSet()).isEqualTo(3);
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method shouldQueryForArbitraryDataUsingBespokeParameterisedCypherQuery.
// DATAGRAPH-697
@Test
public void shouldQueryForArbitraryDataUsingBespokeParameterisedCypherQuery() {
session.save(new Actor("Helen Mirren"));
Actor alec = new Actor("Alec Baldwin");
session.save(alec);
session.save(new Actor("Matt Damon"));
Iterable<Map<String, Object>> resultsIterable = session.query("MATCH (a:Actor) WHERE a.uuid=$param RETURN a.name as name", Collections.<String, Object>singletonMap("param", // make sure the change is backward compatible
alec.getUuid()));
assertThat(resultsIterable).as("Results are empty").isNotNull();
Map<String, Object> row = resultsIterable.iterator().next();
assertThat(row.get("name")).isEqualTo("Alec Baldwin");
Result results = session.query("MATCH (a:Actor) WHERE a.uuid=$param RETURN a.name as name", Collections.<String, Object>singletonMap("param", alec.getUuid()));
assertThat(results).as("Results are empty").isNotNull();
assertThat(results.iterator().next().get("name")).isEqualTo("Alec Baldwin");
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method modifyingQueryShouldReturnResultsWithStatistics.
// DATAGRAPH-697
@Test
public void modifyingQueryShouldReturnResultsWithStatistics() {
session.save(new Actor("Jeff"));
session.save(new Actor("John"));
session.save(new Actor("Colin"));
Result result = session.query("MATCH (a:Actor) SET a.age=$age RETURN a.name", Collections.singletonMap("age", 5), false);
assertThat(result).isNotNull();
assertThat(result.queryStatistics()).isNotNull();
assertThat(result.queryStatistics().getPropertiesSet()).isEqualTo(3);
List<String> names = new ArrayList<>();
Iterator<Map<String, Object>> namesIterator = result.queryResults().iterator();
while (namesIterator.hasNext()) {
names.add((String) namesIterator.next().get("a.name"));
}
assertThat(names).hasSize(3);
assertThat(names.contains("Jeff")).isTrue();
assertThat(names.contains("John")).isTrue();
assertThat(names.contains("Colin")).isTrue();
result = session.query("MATCH (a:Actor) SET a.age=$age RETURN a.name, a.age", Collections.singletonMap("age", 5));
assertThat(result).isNotNull();
assertThat(result.queryStatistics()).isNotNull();
assertThat(result.queryStatistics().getPropertiesSet()).isEqualTo(3);
names = new ArrayList<>();
namesIterator = result.queryResults().iterator();
while (namesIterator.hasNext()) {
Map<String, Object> row = namesIterator.next();
names.add((String) row.get("a.name"));
assertThat(((Number) row.get("a.age")).longValue()).isEqualTo(5L);
}
assertThat(names).hasSize(3);
assertThat(names.contains("Jeff")).isTrue();
assertThat(names.contains("John")).isTrue();
assertThat(names.contains("Colin")).isTrue();
}
Aggregations