use of org.neo4j.ogm.domain.social.Person in project neo4j-ogm by neo4j.
the class SocialIntegrationTest method shouldFetchOnlyPeopleILike.
/**
* @see DATAGRAPH-594
*/
@Test
public void shouldFetchOnlyPeopleILike() {
session.query("create (p1:Person {name:'A'}) create (p2:Person {name:'B'}) create (p3:Person {name:'C'})" + " create (p4:Person {name:'D'}) create (p1)-[:LIKES]->(p2) create (p1)-[:LIKES]->(p3) create (p4)-[:LIKES]->(p1)", Collections.EMPTY_MAP);
Person personA = session.loadAll(Person.class, new Filter("name", ComparisonOperator.EQUALS, "A")).iterator().next();
assertThat(personA).isNotNull();
assertThat(personA.getPeopleILike()).hasSize(2);
Person personD = session.loadAll(Person.class, new Filter("name", ComparisonOperator.EQUALS, "D")).iterator().next();
assertThat(personD).isNotNull();
assertThat(personD.getPeopleILike()).hasSize(1);
assertThat(personD.getPeopleILike().get(0)).isEqualTo(personA);
}
use of org.neo4j.ogm.domain.social.Person in project neo4j-ogm by neo4j.
the class SocialIntegrationTest method shouldSaveUndirectedFriendsInBothDirections.
/**
* @see DATAGRAPH-594
*/
@Test
public void shouldSaveUndirectedFriendsInBothDirections() {
Person userA = new Person("A");
Person userB = new Person("B");
userA.getPeopleILike().add(userB);
userB.getPeopleILike().add(userA);
session.save(userA);
session.clear();
userA = session.loadAll(Person.class, new Filter("name", ComparisonOperator.EQUALS, "A")).iterator().next();
assertThat(userA).isNotNull();
assertThat(userA.getPeopleILike()).hasSize(1);
session.clear();
userB = session.loadAll(Person.class, new Filter("name", ComparisonOperator.EQUALS, "B")).iterator().next();
assertThat(userB).isNotNull();
assertThat(userB.getPeopleILike()).hasSize(1);
}
use of org.neo4j.ogm.domain.social.Person in project neo4j-ogm by neo4j.
the class SocialIntegrationTest method shouldSaveAllDirectedRelationships.
@Test
public void shouldSaveAllDirectedRelationships() throws Exception {
Person a = new Person("A");
Person b = new Person("B");
Person c = new Person("C");
Person d = new Person("D");
Person e = new Person("E");
a.addPersonILike(b);
b.addPersonILike(c);
a.addPersonILike(d);
d.addPersonILike(e);
b.addPersonILike(d);
d.addPersonILike(b);
session.save(a);
session.clear();
Person loadedB = session.load(Person.class, b.getId());
assertThat(loadedB.getPeopleILike()).hasSize(2);
Person loadedD = session.load(Person.class, d.getId());
assertThat(loadedD.getPeopleILike()).hasSize(2);
}
use of org.neo4j.ogm.domain.social.Person in project neo4j-ogm by neo4j.
the class SocialRelationshipsIntegrationTest method updateOutgoingRelInListSavesOutgoingRelationshipInBothDirections.
// DATAGRAPH-594
@Test
public void updateOutgoingRelInListSavesOutgoingRelationshipInBothDirections() {
Person personA = new Person("A");
Person personB = new Person("B");
Person personC = new Person("C");
Person personD = new Person("D");
personA.getPeopleILike().add(personB);
personA.getPeopleILike().add(personC);
personB.getPeopleILike().add(personA);
personD.getPeopleILike().add(personA);
session.save(personA);
session.save(personB);
session.save(personC);
session.save(personD);
session.clear();
assertThat(session.query("MATCH (a:Person {name:'A'}), (b:Person {name:'B'}), " + "(c:Person {name:'C'}), (d:Person {name:'D'}) " + "WHERE (a)-[:LIKES]->(b) and (a)-[:LIKES]->(c) and (b)-[:LIKES]->(a) and (d)-[:LIKES]->(a) " + "return a, b, c, d", emptyMap()).queryResults()).hasSize(1);
}
use of org.neo4j.ogm.domain.social.Person in project neo4j-ogm by neo4j.
the class SocialRelationshipsIntegrationTest method saveOutgoingToExistingNodesSavesOutgoingRelationshipInBothDirections.
// DATAGRAPH-594
@Test
public void saveOutgoingToExistingNodesSavesOutgoingRelationshipInBothDirections() {
Person personA = new Person("A");
Person personB = new Person("B");
session.save(personA);
session.save(personB);
personA.getPeopleILike().add(personB);
personB.getPeopleILike().add(personA);
session.save(personA);
session.clear();
assertThat(session.query("MATCH (a:Person {name:'A'}), (b:Person {name:'B'}) " + "WHERE (a)-[:LIKES]->(b) and (b)-[:LIKES]->(a) return a,b", emptyMap()).queryResults()).hasSize(1);
}
Aggregations