use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class LookupByPrimaryIndexTests method loadUsesPrimaryIndexWhenPresent.
@Test
public void loadUsesPrimaryIndexWhenPresent() {
User user1 = new User("login1", "Name 1", "password");
session.save(user1);
final Session session2 = sessionFactory.openSession();
final User retrievedUser1 = session2.load(User.class, "login1");
assertThat(retrievedUser1).isNotNull();
assertThat(retrievedUser1.getLogin()).isEqualTo(user1.getLogin());
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method shouldBeAbleToMapRelationshipEntities.
// DATAGRAPH-700
@Test
public void shouldBeAbleToMapRelationshipEntities() {
Iterator<Map<String, Object>> results = session.query("MATCH (u:User {name:$name})-[r:RATED]->(m) RETURN u,r,m", Collections.singletonMap("name", "Vince")).iterator();
assertThat(results).isNotNull();
Map<String, Object> result = results.next();
assertThat(result).isNotNull();
Movie movie = (Movie) result.get("m");
assertThat(movie).isNotNull();
assertThat(movie.getTitle()).isEqualTo("Top Gear");
User user = (User) result.get("u");
assertThat(user).isNotNull();
assertThat(user.getName()).isEqualTo("Vince");
Rating rating = (Rating) result.get("r");
assertThat(rating).isNotNull();
assertThat(rating.getStars()).isEqualTo(4);
assertThat(movie.getRatings().iterator().next().getId()).isEqualTo(rating.getId());
assertThat(user.getRatings().iterator().next().getId()).isEqualTo(rating.getId());
assertThat(results.hasNext()).isFalse();
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method shouldBeAbleToMapEntitiesAndScalars.
// DATAGRAPH-700
@Test
public void shouldBeAbleToMapEntitiesAndScalars() {
Iterator<Map<String, Object>> results = session.query("MATCH (u:User {name:$name})-[:RATED]->(m) RETURN u as user, count(m) as count", Collections.singletonMap("name", "Michal")).iterator();
assertThat(results).isNotNull();
Map<String, Object> result = results.next();
assertThat(result).isNotNull();
User user = (User) result.get("user");
assertThat(user).isNotNull();
assertThat(user.getName()).isEqualTo("Michal");
Number count = (Number) result.get("count");
assertThat(count.longValue()).isEqualTo(2L);
assertThat(results.hasNext()).isFalse();
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method shouldBeAbleToMapEntitiesAndRelationshipsOfDifferentTypes.
// DATAGRAPH-700
@Test
public void shouldBeAbleToMapEntitiesAndRelationshipsOfDifferentTypes() {
Iterator<Map<String, Object>> results = session.query("MATCH (u:User {name:$name})-[r:FRIENDS]->(friend)-[r2:RATED]->(m) RETURN u as user, friend as friend, r, r2, m as movie, r2.stars as stars", Collections.singletonMap("name", "Michal")).iterator();
assertThat(results).isNotNull();
Map<String, Object> result = results.next();
assertThat(result).isNotNull();
User user = (User) result.get("user");
assertThat(user).isNotNull();
assertThat(user.getName()).isEqualTo("Michal");
User friend = (User) result.get("friend");
assertThat(friend).isNotNull();
assertThat(friend.getName()).isEqualTo("Vince");
assertThat(user.getFriends().iterator().next().getName()).isEqualTo(friend.getName());
Movie topGear = (Movie) result.get("movie");
assertThat(topGear).isNotNull();
assertThat(topGear.getTitle()).isEqualTo("Top Gear");
assertThat(friend.getRatings()).hasSize(1);
assertThat(friend.getRatings().iterator().next().getMovie().getTitle()).isEqualTo(topGear.getTitle());
Number stars = (Number) result.get("stars");
assertThat(stars.longValue()).isEqualTo(4L);
assertThat(results.hasNext()).isFalse();
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method checkForMichal.
private static boolean checkForMichal(Map<String, Object> result) {
if (result.get("n") instanceof User) {
User u = (User) result.get("n");
if (u.getName().equals("Michal")) {
assertThat(u.getFriends()).hasSize(1);
assertThat(u.getFriends().iterator().next().getName()).isEqualTo("Vince");
return true;
}
}
return false;
}
Aggregations