MockWebServerPlus implements TestRule { public List<MockResponse> enqueue(String... paths) { if (paths == null) { return null; } List<MockResponse> mockResponseList = new ArrayList<>(); for (String path : paths) { Fixture fixture = Fixture.parseFrom(path, parser); MockResponse mockResponse = fixture.toMockResponse(); mockWebServer.enqueue(mockResponse); mockResponseList.add(mockResponse); } return mockResponseList; } MockWebServerPlus();  MockWebServerPlus(MockWebServer mockWebServer); @Override Statement apply(final Statement base, final Description description); List<MockResponse> enqueue(String... paths); MockResponse enqueue(SocketPolicy socketPolicy); void enqueue(MockResponse response); String url(String path); RecordedRequest takeRequest(); void setDispatcher(Dispatcher dispatcher); MockWebServer server();  }
@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"); }
@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 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); }