BAEL-3285 - code reformatted
This commit is contained in:
parent
9f2a86c796
commit
fad7aa6a66
@ -1,4 +1,4 @@
|
||||
package com.baeldung.reactive.simultaneouswebclient;
|
||||
package com.baeldung.reactive.webclient.simultaneous;
|
||||
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
@ -16,24 +16,21 @@ public class Client {
|
||||
}
|
||||
|
||||
public Mono<User> getUser(int id) {
|
||||
return webClient
|
||||
.get()
|
||||
return webClient.get()
|
||||
.uri("/user/{id}", id)
|
||||
.retrieve()
|
||||
.bodyToMono(User.class);
|
||||
}
|
||||
|
||||
public Mono<Item> getItem(int id) {
|
||||
return webClient
|
||||
.get()
|
||||
return webClient.get()
|
||||
.uri("/item/{id}", id)
|
||||
.retrieve()
|
||||
.bodyToMono(Item.class);
|
||||
}
|
||||
|
||||
public Mono<User> getOtherUser(int id) {
|
||||
return webClient
|
||||
.get()
|
||||
return webClient.get()
|
||||
.uri("/otheruser/{id}", id)
|
||||
.retrieve()
|
||||
.bodyToMono(User.class);
|
||||
@ -45,7 +42,7 @@ public class Client {
|
||||
.runOn(Schedulers.elastic())
|
||||
.flatMap(this::getUser)
|
||||
.collectSortedList((u1, u2) -> u2.id() - u1.id())
|
||||
.block();
|
||||
.block();
|
||||
}
|
||||
|
||||
public List<User> fetchUserAndOtherUser(int id) {
|
||||
@ -61,6 +58,6 @@ public class Client {
|
||||
Mono<Item> item = getItem(itemId).subscribeOn(Schedulers.elastic());
|
||||
|
||||
return Mono.zip(user, item, UserWithItem::new)
|
||||
.block();
|
||||
.block();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.reactive.simultaneouswebclient;
|
||||
package com.baeldung.reactive.webclient.simultaneous;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.reactive.simultaneouswebclient;
|
||||
package com.baeldung.reactive.webclient.simultaneous;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.reactive.simultaneouswebclient;
|
||||
package com.baeldung.reactive.webclient.simultaneous;
|
||||
|
||||
public class UserWithItem {
|
||||
private User user;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.reactive.simultaneouswebclient;
|
||||
package com.baeldung.reactive.webclient.simultaneous;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
@ -8,7 +8,6 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
@ -43,17 +42,15 @@ public class ClientIntegrationTest {
|
||||
int singleRequestTime = 1000;
|
||||
|
||||
for (int i = 1; i <= requestsNumber; i++) {
|
||||
stubFor(
|
||||
get(urlEqualTo("/user/" + i)).willReturn(aResponse()
|
||||
.withFixedDelay(singleRequestTime)
|
||||
stubFor(get(urlEqualTo("/user/" + i)).willReturn(aResponse().withFixedDelay(singleRequestTime)
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(String.format("{ \"id\": %d }", i))));
|
||||
}
|
||||
|
||||
List<Integer> userIds = IntStream.rangeClosed(1, requestsNumber)
|
||||
.boxed()
|
||||
.collect(Collectors.toList());
|
||||
.boxed()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Client client = new Client("http://localhost:8089");
|
||||
|
Loading…
x
Reference in New Issue
Block a user