Skip to content

Commit 226ebd8

Browse files
committed
GH-2289 - Now also available in reactive flavour.
1 parent ed6973d commit 226ebd8

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java

+1
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ private <T> Mono<T> processNestedRelations(Neo4jPersistentEntity<?> sourceEntity
837837
targetPropertyAccessor.setProperty(targetEntity.getVersionProperty(), idAndVersion.getT2()[0]);
838838
}
839839
stateMachine.markValueAsProcessedAs(relatedObjectBeforeCallbacksApplied, targetPropertyAccessor.getBean());
840+
stateMachine.markRelationshipAsProcessed(relatedInternalId, relationshipDescription.getRelationshipObverse());
840841

841842
Object idValue = idProperty != null
842843
? relationshipContext

src/test/java/org/springframework/data/neo4j/integration/issues/gh2289/GH2289IT.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

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

20-
import org.assertj.core.api.Assertions;
2120
import org.junit.jupiter.api.BeforeAll;
2221
import org.junit.jupiter.api.RepeatedTest;
2322
import org.neo4j.driver.Driver;
@@ -71,25 +70,25 @@ void testNewRelation(@Autowired SkuRepository skuRepo) {
7170
a.rangeRelationTo(d, 1, 1, RelationType.MULTIPLICATIVE);
7271
a = skuRepo.save(a);
7372

74-
Assertions.assertThat(a.getRangeRelationsOut()).hasSize(3);
73+
assertThat(a.getRangeRelationsOut()).hasSize(3);
7574
b = skuRepo.findById(b.getId()).get();
76-
Assertions.assertThat(b.getRangeRelationsIn()).hasSize(1);
75+
assertThat(b.getRangeRelationsIn()).hasSize(1);
7776

78-
Assertions.assertThat(b.getRangeRelationsIn().stream().findFirst().get().getTargetSku().getRangeRelationsOut()).hasSize(3);
77+
assertThat(b.getRangeRelationsIn().stream().findFirst().get().getTargetSku().getRangeRelationsOut()).hasSize(3);
7978

8079
b.rangeRelationTo(c, 1, 1, RelationType.MULTIPLICATIVE);
8180
b = skuRepo.save(b);
82-
Assertions.assertThat(b.getRangeRelationsIn()).hasSize(1);
83-
Assertions.assertThat(b.getRangeRelationsOut()).hasSize(1);
81+
assertThat(b.getRangeRelationsIn()).hasSize(1);
82+
assertThat(b.getRangeRelationsOut()).hasSize(1);
8483

8584
a = skuRepo.findById(a.getId()).get();
86-
Assertions.assertThat(a.getRangeRelationsOut()).hasSize(3);
87-
Assertions.assertThat(a.getRangeRelationsOut()).allSatisfy(r -> {
85+
assertThat(a.getRangeRelationsOut()).hasSize(3);
86+
assertThat(a.getRangeRelationsOut()).allSatisfy(r -> {
8887
int expectedSize = 1;
8988
if ("C".equals(r.getTargetSku().getName())) {
9089
expectedSize = 2;
9190
}
92-
Assertions.assertThat(r.getTargetSku().getRangeRelationsIn()).hasSize(expectedSize);
91+
assertThat(r.getTargetSku().getRangeRelationsIn()).hasSize(expectedSize);
9392
});
9493
}
9594

src/test/java/org/springframework/data/neo4j/integration/issues/gh2289/ReactiveGH2289IT.java

+23-2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ protected static void setupData(@Autowired BookmarkCapture bookmarkCapture) {
6969
@RepeatedTest(23)
7070
void testNewRelation(@Autowired SkuRepository skuRepo) {
7171

72+
AtomicLong aId = new AtomicLong();
7273
AtomicLong bId = new AtomicLong();
7374
AtomicReference<Sku> cRef = new AtomicReference<>();
7475
skuRepo.save(new Sku(0L, "A"))
@@ -87,7 +88,10 @@ void testNewRelation(@Autowired SkuRepository skuRepo) {
8788
a.rangeRelationTo(d, 1, 1, RelationType.MULTIPLICATIVE);
8889
return skuRepo.save(a);
8990
}).as(StepVerifier::create)
90-
.expectNextMatches(a -> a.getRangeRelationsOut().size() == 3)
91+
.expectNextMatches(a -> {
92+
aId.set(a.getId()); // side-effects for the win
93+
return a.getRangeRelationsOut().size() == 3;
94+
})
9195
.verifyComplete();
9296

9397
skuRepo.findById(bId.get())
@@ -97,7 +101,24 @@ void testNewRelation(@Autowired SkuRepository skuRepo) {
97101
return skuRepo.save(b);
98102
})
99103
.as(StepVerifier::create)
100-
.expectNextMatches(a -> a.getRangeRelationsIn().size() == 1 && a.getRangeRelationsOut().size() == 1)
104+
.assertNext(b -> {
105+
assertThat(b.getRangeRelationsIn()).hasSize(1);
106+
assertThat(b.getRangeRelationsOut()).hasSize(1);
107+
})
108+
.verifyComplete();
109+
110+
skuRepo.findById(aId.get())
111+
.as(StepVerifier::create)
112+
.assertNext(a -> {
113+
assertThat(a.getRangeRelationsOut()).hasSize(3);
114+
assertThat(a.getRangeRelationsOut()).allSatisfy(r -> {
115+
int expectedSize = 1;
116+
if ("C".equals(r.getTargetSku().getName())) {
117+
expectedSize = 2;
118+
}
119+
assertThat(r.getTargetSku().getRangeRelationsIn()).hasSize(expectedSize);
120+
});
121+
})
101122
.verifyComplete();
102123
}
103124

0 commit comments

Comments
 (0)