use of org.neo4j.ogm.domain.social.SocialUser in project neo4j-ogm by neo4j.
the class SocialRelationshipsIntegrationTest method shouldUseOptimizedQueryToSaveExistingRelations.
// GH-61
@Test
public void shouldUseOptimizedQueryToSaveExistingRelations() {
SocialUser userA = new SocialUser("A");
SocialUser userB = new SocialUser("B");
SocialUser userE = new SocialUser("E");
session.save(userA);
session.save(userB);
session.save(userE);
Set<SocialUser> friends = new HashSet<>();
friends.add(userB);
friends.add(userE);
Set<SocialUser> following = new HashSet<>();
following.add(userB);
following.add(userE);
Set<SocialUser> followers = new HashSet<>();
followers.add(userB);
followers.add(userE);
userA.setFollowers(followers);
userA.setFriends(friends);
userA.setFollowing(following);
session.save(userA);
session.clear();
userA = session.load(SocialUser.class, userA.getId());
assertThat(userA.getFriends()).hasSize(2);
assertThat(userA.getFollowers()).hasSize(2);
assertThat(userA.getFollowing()).hasSize(2);
}
use of org.neo4j.ogm.domain.social.SocialUser in project neo4j-ogm by neo4j.
the class SocialRelationshipsIntegrationTest method shouldManageRelationshipsToTheSameNodeType.
// DATAGRAPH-636, DATAGRAPH-665 (equals() on SocialUser includes every field)
@Test
public void shouldManageRelationshipsToTheSameNodeType() {
SocialUser userA = new SocialUser("A");
SocialUser userB = new SocialUser("B");
SocialUser userC = new SocialUser("C");
SocialUser userD = new SocialUser("D");
SocialUser userE = new SocialUser("E");
SocialUser userF = new SocialUser("F");
SocialUser userG = new SocialUser("G");
Set<SocialUser> friends = new HashSet<>();
friends.add(userB);
friends.add(userE);
Set<SocialUser> following = new HashSet<>();
following.add(userB);
following.add(userE);
Set<SocialUser> followers = new HashSet<>();
followers.add(userB);
followers.add(userE);
userA.setFollowers(followers);
userA.setFriends(friends);
userA.setFollowing(following);
session.save(userA);
session.clear();
userA = session.load(SocialUser.class, userA.getId());
assertThat(userA.getFriends()).hasSize(2);
assertThat(userA.getFollowers()).hasSize(2);
assertThat(userA.getFollowing()).hasSize(2);
}
Aggregations