Skip to content

Commit

Permalink
Fix setting a nested self reference object (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongahjo authored Oct 18, 2023
1 parent befd2a1 commit 94c8518
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -701,4 +701,43 @@ void fixedSelfRecursiveMapObject() {

then(actual).isNotNull();
}

@RepeatedTest(TEST_COUNT)
void setSelfRecursiveObjectList() {
List<SelfRecursiveListObject> expected = SUT.giveMeOne(
new TypeReference<List<SelfRecursiveListObject>>() {
});

List<SelfRecursiveListObject> actual = SUT.giveMeBuilder(new TypeReference<List<SelfRecursiveListObject>>() {
})
.size("$", 1)
.set("$[0].selfRecursiveListObjects", expected)
.sample()
.get(0)
.getSelfRecursiveListObjects();

then(actual).isEqualTo(expected);
}

@RepeatedTest(TEST_COUNT)
void setNestedSelfRecursiveObjectList() {
List<SelfRecursiveListObject> expected = SUT.giveMeBuilder(
new TypeReference<List<SelfRecursiveListObject>>() {
}
)
.size("$", 1)
.set("$[0].selfRecursiveListObjects", SUT.giveMeOne(new TypeReference<List<SelfRecursiveListObject>>() {
}))
.sample();

List<SelfRecursiveListObject> actual = SUT.giveMeBuilder(new TypeReference<List<SelfRecursiveListObject>>() {
})
.size("$", 1)
.set("$[0].selfRecursiveListObjects", expected)
.sample()
.get(0)
.getSelfRecursiveListObjects();

then(actual).isEqualTo(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public TraverseContext appendArbitraryProperty(
}

public boolean isTraversed(Property property) {
return property.equals(rootArbitraryProperty.getObjectProperty().getProperty())
|| arbitraryProperties.stream()
return arbitraryProperties.stream()
.filter(it -> it != rootArbitraryProperty)
.anyMatch(it -> isSameType(property, it.getObjectProperty().getProperty()));
}
Expand Down

0 comments on commit 94c8518

Please sign in to comment.