private Response execute() throws IOException { return execute(server.url("/")); }
@Test public void getRecordedRequest() throws IOException, InterruptedException { server.enqueue(new MockResponse()); execute(); RecordedRequest recordedRequest = server.takeRequest(); assertThat(recordedRequest).isNotNull(); }
@Test public void interceptDispatch() throws InterruptedException, IOException { Dispatcher dispatcher = spy(new QueueDispatcher()); server.setDispatcher(dispatcher); server.enqueue(new MockResponse()); execute(); verify(dispatcher).dispatch(any(RecordedRequest.class)); }
@Test public void enqueueWithoutBody() throws Exception { server.enqueue(Fixtures.SIMPLE_NO_BODY); Response response = execute(); assertFixture(response).statusCode(200); }
@Test public void enqueueWithoutStatusCode() throws Exception { server.enqueue(Fixtures.SIMPLE_NO_STATUS_CODE); Response response = execute(); assertFixture(response) .body(JSON_RESPONSE) .statusCode(200); }
@Test public void enqueueWithoutHeaders() throws Exception { server.enqueue(Fixtures.SIMPLE_NO_HEADERS); Response response = execute(); assertFixture(response) .body(JSON_RESPONSE) .statusCode(200); }
@Test public void enqueueSingleResponse() throws Exception { server.enqueue(Fixtures.SIMPLE); Response response = execute(); assertFixture(response) .body(JSON_RESPONSE) .statusCode(200) .header("Auth", "auth") .header("key", "value"); }
@Test public void enqueueMultipleResponse() throws Exception { server.enqueue(Fixtures.SIMPLE, Fixtures.SIMPLE); Response response = execute(); assertFixture(response) .body(JSON_RESPONSE) .statusCode(200) .header("Auth", "auth") .header("key", "value"); Response response2 = execute(); assertFixture(response2) .body(JSON_RESPONSE) .statusCode(200) .header("Auth", "auth") .header("key", "value"); }