[BAEL-1449]-Combining Publishers (Project Reactor)

This commit is contained in:
felipeazv 2018-02-08 11:39:09 +01:00
parent 19ef04d07c
commit 5ce6ad7d8f
1 changed files with 76 additions and 1 deletions

View File

@ -103,5 +103,80 @@ public class CombiningPublishersTest {
.expectNext(5)
.verifyComplete();
}
@Test
public void testMergeSequential() {
Flux<Integer> fluxOfIntegers = Flux.mergeSequential(
evenNumbers,
oddNumbers);
StepVerifier.create(fluxOfIntegers)
.expectNext(2)
.expectNext(4)
.expectNext(1)
.expectNext(3)
.expectNext(5)
.expectComplete()
.verify();
}
@Test
public void testMergeDelayError() {
Flux<Integer> fluxOfIntegers = Flux.mergeDelayError(1,
evenNumbers.delayElements(Duration.ofMillis(500L)),
oddNumbers.delayElements(Duration.ofMillis(300L)));
StepVerifier.create(fluxOfIntegers)
.expectNext(1)
.expectNext(2)
.expectNext(3)
.expectNext(5)
.expectNext(4)
.expectComplete()
.verify();
}
@Test
public void testMergeWith() {
Flux<Integer> fluxOfIntegers = evenNumbers.mergeWith(oddNumbers);
StepVerifier.create(fluxOfIntegers)
.expectNext(2)
.expectNext(4)
.expectNext(1)
.expectNext(3)
.expectNext(5)
.expectComplete()
.verify();
}
@Test
public void testZip() {
Flux<Integer> fluxOfIntegers = Flux.zip(
evenNumbers,
oddNumbers,
(a, b) -> a + b);
StepVerifier.create(fluxOfIntegers)
.expectNext(3)
.expectNext(7)
.expectComplete()
.verify();
}
@Test
public void testZipWith() {
Flux<Integer> fluxOfIntegers = evenNumbers
.zipWith(oddNumbers,
(a, b) -> a * b);
StepVerifier.create(fluxOfIntegers)
.expectNext(2)
.expectNext(12)
.expectComplete()
.verify();
}
}