Skip to content

Commit

Permalink
Reproduce issue #407
Browse files Browse the repository at this point in the history
  • Loading branch information
frant-hartm committed Nov 14, 2017
1 parent 147431f commit b5278c2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
12 changes: 12 additions & 0 deletions test/src/test/java/org/neo4j/ogm/domain/social/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@ public String getName() {
public void setName(String name) {
this.name = name;
}

public void addPersonILike(Person person) {
peopleILike.add(person);
}

@Override
public String toString() {
return "Person{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

package org.neo4j.ogm.persistence.examples.social;

import static org.assertj.core.api.Assertions.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import org.neo4j.ogm.cypher.ComparisonOperator;
import org.neo4j.ogm.cypher.Filter;
import org.neo4j.ogm.domain.social.Individual;
Expand All @@ -34,6 +34,8 @@
import org.neo4j.ogm.session.SessionFactory;
import org.neo4j.ogm.testutil.MultiDriverTestClass;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author Luanne Misquitta
*/
Expand Down Expand Up @@ -274,4 +276,42 @@ public void shouldFetchFriendsUndirected() {
vince = session.load(User.class, vince.getId());
assertThat(vince.getFriends()).hasSize(1);
}

/**
* Issue #407
*
* Should create graph like this
*
* (a)-[:LIKES]->(b)-[:LIKES]->(c)
* (a)-[:LIKES]->(d)-[:LIKES]->(e)
* (b)-[:LIKES]->(d)
* (d)-[:LIKES]->(c)
*
* Issue was that the logic reaches either b (or d) with horizon 0 (2 steps from a)
* and doesn't continue to save c (or e)
*/
@Test
public void shouldSaveObjectsToCorrectDepth() 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, 2);

session.clear();
Collection<Person> people = session.loadAll(Person.class);
assertThat(people).hasSize(5);
}
}

0 comments on commit b5278c2

Please sign in to comment.