use of org.neo4j.ogm.domain.friendships.Person in project neo4j-ogm by neo4j.
the class FriendshipsRelationshipEntityTest method shouldSaveAndReloadAllSetsAllObjectIdsAndReferencesCorrectly.
@Test
public void shouldSaveAndReloadAllSetsAllObjectIdsAndReferencesCorrectly() {
Person mike = new Person("Mike");
Person dave = new Person("Dave");
dave.getFriends().add(new Friendship(dave, mike, 5));
session.save(dave);
Collection<Person> personList = session.loadAll(Person.class);
int expected = 2;
assertThat(personList.size()).isEqualTo(expected);
for (Person person : personList) {
if (person.getName().equals("Dave")) {
expected--;
assertThat(person.getFriends().get(0).getFriend().getName()).isEqualTo("Mike");
} else if (person.getName().equals("Mike")) {
expected--;
assertThat(person.getFriends().get(0).getPerson().getName()).isEqualTo("Dave");
}
}
assertThat(expected).isEqualTo(0);
}
use of org.neo4j.ogm.domain.friendships.Person in project neo4j-ogm by neo4j.
the class FriendshipsRelationshipEntityTest method shouldSaveFromRelationshipEntitySetsAllObjectIds.
@Test
public void shouldSaveFromRelationshipEntitySetsAllObjectIds() {
Person mike = new Person("Mike");
Person dave = new Person("Dave");
Friendship friendship = new Friendship(dave, mike, 5);
dave.getFriends().add(friendship);
session.save(friendship);
assertThat(dave.getId()).isNotNull();
assertThat(mike.getId()).isNotNull();
assertThat(dave.getFriends().get(0).getId()).isNotNull();
}
use of org.neo4j.ogm.domain.friendships.Person in project neo4j-ogm by neo4j.
the class FriendshipsRelationshipEntityTest method shouldSaveFromStartObjectSetsAllObjectIds.
@Test
public void shouldSaveFromStartObjectSetsAllObjectIds() {
Person mike = new Person("Mike");
Person dave = new Person("Dave");
// could use addFriend(...) but hey
dave.getFriends().add(new Friendship(dave, mike, 5));
session.save(dave);
assertThat(dave.getId()).isNotNull();
assertThat(mike.getId()).isNotNull();
assertThat(dave.getFriends().get(0).getId()).isNotNull();
}
use of org.neo4j.ogm.domain.friendships.Person in project neo4j-ogm by neo4j.
the class FriendshipsRelationshipEntityTest method shouldLoadStartObjectHydratesProperly.
@Test
public void shouldLoadStartObjectHydratesProperly() {
Person mike = new Person("Mike");
Person dave = new Person("Dave");
Friendship friendship = new Friendship(dave, mike, 5);
dave.getFriends().add(friendship);
session.save(dave);
Person daveCopy = session.load(Person.class, dave.getId());
Friendship friendshipCopy = daveCopy.getFriends().get(0);
Person mikeCopy = friendshipCopy.getFriend();
assertThat(daveCopy.getId()).isNotNull();
assertThat(mikeCopy.getId()).isNotNull();
assertThat(friendshipCopy.getId()).isNotNull();
assertThat(daveCopy.getName()).isEqualTo("Dave");
assertThat(mikeCopy.getName()).isEqualTo("Mike");
assertThat(friendshipCopy.getStrength()).isEqualTo(5);
}
use of org.neo4j.ogm.domain.friendships.Person in project neo4j-ogm by neo4j.
the class FriendshipsRelationshipEntityTest method shouldLoadRelationshipEntityObjectHydratesProperly.
@Test
public void shouldLoadRelationshipEntityObjectHydratesProperly() {
Person mike = new Person("Mike");
Person dave = new Person("Dave");
Friendship friendship = new Friendship(dave, mike, 5);
dave.getFriends().add(friendship);
session.save(dave);
Friendship friendshipCopy = session.load(Friendship.class, friendship.getId());
Person daveCopy = friendshipCopy.getPerson();
Person mikeCopy = friendshipCopy.getFriend();
assertThat(daveCopy.getId()).isNotNull();
assertThat(mikeCopy.getId()).isNotNull();
assertThat(friendshipCopy.getId()).isNotNull();
assertThat(daveCopy.getName()).isEqualTo("Dave");
assertThat(mikeCopy.getName()).isEqualTo("Mike");
assertThat(friendshipCopy.getStrength()).isEqualTo(5);
}
Aggregations