use of org.neo4j.ogm.domain.forum.activity.Activity in project neo4j-ogm by neo4j.
the class HierarchyRelsTest method shouldLoadRelationByAbstractParent.
// GH-404
@Test
public void shouldLoadRelationByAbstractParent() {
Post post = new Post();
post.setPost("sample post");
Activity comment = new Comment();
Date now = new Date();
comment.setDate(now);
Member member = new Member();
member.setUserName("sample member");
member.setActivityList(Arrays.asList(post, comment));
session.save(member);
session.clear();
Member reloaded = session.load(Member.class, member.getId());
assertThat(reloaded).isNotNull();
assertThat(reloaded.getUserName()).isEqualTo("sample member");
assertThat(reloaded.getActivityList()).hasSize(2);
Post p = (Post) StreamSupport.stream(reloaded.getActivityList().spliterator(), false).filter(elt -> elt.getClass().equals(Post.class)).findFirst().get();
assertThat(p.getPost()).isEqualTo("sample post");
Comment c = (Comment) StreamSupport.stream(reloaded.getActivityList().spliterator(), false).filter(elt -> elt.getClass().equals(Comment.class)).findFirst().get();
assertThat(c.getDate()).isEqualTo(now);
}
Aggregations