MASH-4748 fix Reader object and url with WebClient
This commit is contained in:
parent
70a0e0de96
commit
a0425afd1b
|
@ -0,0 +1,30 @@
|
|||
package com.baeldung.webclient.json.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Reader {
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final List<Book> favouriteBooks;
|
||||
|
||||
@JsonCreator
|
||||
public Reader(
|
||||
@JsonProperty("id") int id,
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("favouriteBooks") List<Book> favoriteBooks) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.favouriteBooks = favoriteBooks;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<Book> getFavouriteBooks() { return favouriteBooks; }
|
||||
}
|
|
@ -19,9 +19,9 @@ public class ReaderConsumerServiceImplUnitTest {
|
|||
"{\"id\":2,\"name\":\"reader2\",\"favouriteBooks\":[{\"author\":\"J.R.R. Tolkien\",\"title\":\"Lord of the Rings\"}, " +
|
||||
"{\"author\":\"Douglas Adams\",\"title\":\"The Hitchhiker\'s Guide to the Galaxy\"}]}]";
|
||||
|
||||
private static String BASE_URL = "http://localhost:8080";
|
||||
private static String BASE_URL = "http://localhost:8080/readers";
|
||||
|
||||
WebClient webClientMock = WebClient.builder()
|
||||
WebClient webClientMock = WebClient.builder().baseUrl(BASE_URL)
|
||||
.exchangeFunction(clientRequest -> Mono.just(ClientResponse.create(HttpStatus.OK)
|
||||
.header("content-type", "application/json")
|
||||
.body(READER_JSON)
|
||||
|
|
Loading…
Reference in New Issue