Customer experience
Go
Python
Java
repost-client-test provides StubTransport, a recording, no-network transport. Install it with .transport(...), enqueue responses, send, and assert on the recorded request. The Authorization header is stripped from recordings; the idempotency key travels as the Idempotency-Key header:
StubTransport transport = new StubTransport().enqueueResponse(
202,
"{\"id\":\"msg_1\",\"type\":\"order.created\",\"customerId\":\"customer-123\","
+ "\"timestamp\":\"1970-01-01T00:00:00.000Z\"}");
ClientOptions options = ClientOptions.builder()
.apiKey("test-key")
.transport(transport)
.maxAttempts(1)
.build();
Order order = Order.builder().id("order-123").build();
try (RepostClient repost = RepostClient.create(options)) {
SendResult result = repost.webhooks().order().created("customer-123", order);
assertTrue("msg_1".equals(result.getId()));
}
String sent = new String(transport.getRequests().get(0).getBodyBytes(), StandardCharsets.UTF_8);
assertTrue(sent.contains("\"id\":\"order-123\""));Add repost-client-test in test scope. The module also ships enqueueFailure, enqueuePending for deferred completion, a RecordingObserver, a NoNetworkGuard, and deterministic clocks and generators for reproducible tests.
Continue#
On This Page
Continue