// Path: clients/java/src/org/httpmock/StubRequest.java
// public class StubRequest {
//     private final JSONObject data;
// 
//     public StubRequest(JSONObject data) {
//         this.data = data;
//     }
// 
//     public String getRequestMethod() {
//         return data.getString("method");
//     }
//     
//     public String getPath() {
//         return data.getString("path");
//     }
// 
//     public Map<String, String> getHeaders() {
//         Map<String, String> result = new HashMap<String, String>();
//         JSONObject headers = data.getJSONObject("headers");
//         Iterator iterator = headers.keys();
//         while (iterator.hasNext()) {
//             String header = (String) iterator.next();
//             result.put(header, headers.getString(header));
//         }
//         return result;
//     }
// 
//     public String getBody() {
//         return data.getString("body");
//     }
// }
// 
// Path: clients/java/src/org/httpmock/StubServer.java
// public class StubServer {
//     private final HttpMock httpMock;
//     final String serverURL;
//     final String requestsURL;
//     final String stubURL;
// 
//     StubServer(HttpMock httpMock, String serverURL, String requestsURL, String stubURL) {
//         this.httpMock = httpMock;
//         this.serverURL = serverURL;
//         this.requestsURL = requestsURL;
//         this.stubURL = stubURL;
//     }
// 
//     public List<StubRequest> getRequests() {
//         HttpResponse response = httpMock.get(requestsURL);
//         response.assertStatusIs(200);
//         return collectRequests(response.getBodyAsJSONArray());
//     }
// 
//     public Stubber on(String method, String url) {
//         Stubber stubber = new Stubber(httpMock, stubURL, url);
//         stubber.setRequestMethod(method);
//         return stubber;
//     }
// 
//     public void close() {
//         HttpResponse response = httpMock.delete(serverURL);
//         response.assertStatusIs(204);
//     }
// 
//     private List<StubRequest> collectRequests(JSONArray requests) {
//         List<StubRequest> result = new ArrayList<StubRequest>();
//         for (Object request : requests) {
//             result.add(new StubRequest((JSONObject)request));
//         }
//         return result;
//     }
// }
// 
// Path: clients/java/test/org/httpmock/matchers/TestStubRequest.java
// public static TestStubRequest request(String requestMethod, String path) {
//     return new TestStubRequest(requestMethod, path);
// }


import org.hamcrest.StringDescription;
import org.httpmock.StubRequest;
import org.httpmock.StubServer;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static junit.framework.Assert.*;
import static org.httpmock.matchers.TestStubRequest.request;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package org.httpmock.matchers;




public class WasCalledTest {
    private final StubServer stub = mock(StubServer.class);

    @Test
    public void shouldNotMatchIfNoRequests() {
        when(stub.getRequests()).thenReturn(new ArrayList<StubRequest>());

        WasCalled matcher = new WasCalled("GET", "/");

        assertFalse(matcher.matchesSafely(stub));
    }

    @Test
    public void shouldMatchWithMatchingRequest() {
// Path: clients/java/src/org/httpmock/StubRequest.java
// public class StubRequest {
//     private final JSONObject data;
// 
//     public StubRequest(JSONObject data) {
//         this.data = data;
//     }
// 
//     public String getRequestMethod() {
//         return data.getString("method");
//     }
//     
//     public String getPath() {
//         return data.getString("path");
//     }
// 
//     public Map<String, String> getHeaders() {
//         Map<String, String> result = new HashMap<String, String>();
//         JSONObject headers = data.getJSONObject("headers");
//         Iterator iterator = headers.keys();
//         while (iterator.hasNext()) {
//             String header = (String) iterator.next();
//             result.put(header, headers.getString(header));
//         }
//         return result;
//     }
// 
//     public String getBody() {
//         return data.getString("body");
//     }
// }
// 
// Path: clients/java/src/org/httpmock/StubServer.java
// public class StubServer {
//     private final HttpMock httpMock;
//     final String serverURL;
//     final String requestsURL;
//     final String stubURL;
// 
//     StubServer(HttpMock httpMock, String serverURL, String requestsURL, String stubURL) {
//         this.httpMock = httpMock;
//         this.serverURL = serverURL;
//         this.requestsURL = requestsURL;
//         this.stubURL = stubURL;
//     }
// 
//     public List<StubRequest> getRequests() {
//         HttpResponse response = httpMock.get(requestsURL);
//         response.assertStatusIs(200);
//         return collectRequests(response.getBodyAsJSONArray());
//     }
// 
//     public Stubber on(String method, String url) {
//         Stubber stubber = new Stubber(httpMock, stubURL, url);
//         stubber.setRequestMethod(method);
//         return stubber;
//     }
// 
//     public void close() {
//         HttpResponse response = httpMock.delete(serverURL);
//         response.assertStatusIs(204);
//     }
// 
//     private List<StubRequest> collectRequests(JSONArray requests) {
//         List<StubRequest> result = new ArrayList<StubRequest>();
//         for (Object request : requests) {
//             result.add(new StubRequest((JSONObject)request));
//         }
//         return result;
//     }
// }
// 
// Path: clients/java/test/org/httpmock/matchers/TestStubRequest.java
// public static TestStubRequest request(String requestMethod, String path) {
//     return new TestStubRequest(requestMethod, path);
// }


// Path: clients/java/test/org/httpmock/matchers/WasCalledTest.java
import org.hamcrest.StringDescription;
import org.httpmock.StubRequest;
import org.httpmock.StubServer;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static junit.framework.Assert.*;
import static org.httpmock.matchers.TestStubRequest.request;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

package org.httpmock.matchers;




public class WasCalledTest {
    private final StubServer stub = mock(StubServer.class);

    @Test
    public void shouldNotMatchIfNoRequests() {
        when(stub.getRequests()).thenReturn(new ArrayList<StubRequest>());

        WasCalled matcher = new WasCalled("GET", "/");

        assertFalse(matcher.matchesSafely(stub));
    }

    @Test
    public void shouldMatchWithMatchingRequest() {
        when(stub.getRequests()).thenReturn(listOf(request("GET", "/test")));