Add Consumer methods to WebTestClient assertion classes

Issue: SPR-16574
This commit is contained in:
Rossen Stoyanchev
2018-07-20 22:28:40 -04:00
parent 20de5003ff
commit 91122ec0f5
9 changed files with 285 additions and 130 deletions

View File

@@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
@@ -98,6 +99,18 @@ public class ResponseEntityTests {
.expectBodyList(Person.class).isEqualTo(expected);
}
@Test
public void entityListWithConsumer() {
this.client.get()
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON_UTF8)
.expectBodyList(Person.class).value(people -> {
MatcherAssert.assertThat(people, hasItem(new Person("Jason")));
});
}
@Test
public void entityMap() {