Skip to content

Commit

Permalink
fix reactor#1529 StepVerifier CollectEvent blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
flooq committed Mar 26, 2019
1 parent 611658f commit 9da02e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ boolean onCollect(Signal<T> actualSignal) {
this.completeLatch.countDown();
return true;
}
return true;
return false;
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -1336,14 +1336,15 @@ final void onExpectation(Signal<T> actualSignal) {
}
//possibly re-evaluate the current onNext
event = this.script.peek();
}
if (event instanceof SignalCountEvent) {
if (onSignalCount(actualSignal, (SignalCountEvent<T>) event)) {
} else if (event instanceof CollectEvent) {
if (onCollect(actualSignal)) {
return;
}
//possibly re-evaluate the current onNext
event = this.script.peek();
}
else if (event instanceof CollectEvent) {
if (onCollect(actualSignal)) {
if (event instanceof SignalCountEvent) {
if (onSignalCount(actualSignal, (SignalCountEvent<T>) event)) {
return;
}
}
Expand Down
28 changes: 28 additions & 0 deletions reactor-test/src/test/java/reactor/test/StepVerifierTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,34 @@ public void testThenConsumeWhileFails() {
.withMessageContaining("expectNext(9)");
}

@Test
public void testExpectRecordedMatches() {
List<Integer> expected = Arrays.asList(1,2);

StepVerifier.create(Flux.just(1,2))
.recordWith(ArrayList::new)
.thenConsumeWhile(i -> i < 2)
.expectRecordedMatches(expected::equals)
.thenCancel()
.verify();
}

@Test
public void testExpectRecordedMatchesWithoutComplete() {
List<Integer> expected = Arrays.asList(1,2);

TestPublisher<Integer> publisher = TestPublisher.createCold();
publisher.next(1);
publisher.next(2);

StepVerifier.create(publisher)
.recordWith(ArrayList::new)
.thenConsumeWhile(i -> i < 2)
.expectRecordedMatches(expected::equals)
.thenCancel()
.verify();
}

@Test
public void testWithDescription() {
assertThatExceptionOfType(AssertionError.class)
Expand Down

0 comments on commit 9da02e7

Please sign in to comment.