Java-75 update intro to reactor core (#9953)
* Java-75 Update intro to Reactor Core * Java-75 Create package for introduction * Java-75 Update reactor version and align unit test with article Co-authored-by: mikr <michael.krimgen@ximedes.com>
This commit is contained in:
parent
25b1749308
commit
d237c52a1f
@ -34,7 +34,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<reactor.version>3.2.6.RELEASE</reactor.version>
|
<reactor.version>3.3.9.RELEASE</reactor.version>
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.reactor;
|
package com.baeldung.reactor.introduction;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.reactivestreams.Subscriber;
|
import org.reactivestreams.Subscriber;
|
||||||
@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
public class ReactorIntegrationTest {
|
public class ReactorIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenFlux_whenSubscribing_thenStream() throws InterruptedException {
|
public void givenFlux_whenSubscribing_thenStream() {
|
||||||
|
|
||||||
List<Integer> elements = new ArrayList<>();
|
List<Integer> elements = new ArrayList<>();
|
||||||
|
|
||||||
@ -48,14 +48,12 @@ public class ReactorIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenFlux_whenApplyingBackPressure_thenPushElementsInBatches() throws InterruptedException {
|
public void givenFlux_whenApplyingBackPressure_thenPushElementsInBatches() {
|
||||||
|
|
||||||
List<Integer> elements = new ArrayList<>();
|
List<Integer> elements = new ArrayList<>();
|
||||||
|
|
||||||
Flux.just(1, 2, 3, 4)
|
Flux.just(1, 2, 3, 4)
|
||||||
.log()
|
.log()
|
||||||
.map(i -> i * 2)
|
|
||||||
.onBackpressureBuffer()
|
|
||||||
.subscribe(new Subscriber<Integer>() {
|
.subscribe(new Subscriber<Integer>() {
|
||||||
private Subscription s;
|
private Subscription s;
|
||||||
int onNextAmount;
|
int onNextAmount;
|
||||||
@ -81,11 +79,10 @@ public class ReactorIntegrationTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
int ham = 2;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
assertThat(elements).containsExactly(2, 4, 6, 8);
|
assertThat(elements).containsExactly(1, 2, 3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
Loading…
x
Reference in New Issue
Block a user