feat(testing): support reusable request customizers
This commit is contained in:
@@ -7,6 +7,7 @@ import java.net.http.HttpResponse;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request being built against a {@link FlashTest} server. The HTTP verb is terminal — it
|
* A request being built against a {@link FlashTest} server. The HTTP verb is terminal — it
|
||||||
@@ -41,6 +42,12 @@ public final class FlashRequest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Applies {@code customizer} — how an extension's test kit attaches a credential, for instance. */
|
||||||
|
public FlashRequest with(Consumer<FlashRequest> customizer) {
|
||||||
|
customizer.accept(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Sets a UTF-8 request body. */
|
/** Sets a UTF-8 request body. */
|
||||||
public FlashRequest body(String text) {
|
public FlashRequest body(String text) {
|
||||||
this.body = Objects.requireNonNull(text, "text").getBytes(StandardCharsets.UTF_8);
|
this.body = Objects.requireNonNull(text, "text").getBytes(StandardCharsets.UTF_8);
|
||||||
|
|||||||
Reference in New Issue
Block a user