// Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ImposterBuilder.java
// public class ImposterBuilder {
//     private int port;
//     private List<StubBuilder> stubBuilders = newArrayList();
// 
//     public static ImposterBuilder anImposter() {
//         return new ImposterBuilder();
//     }
// 
//     public ImposterBuilder onPort(int port) {
//         this.port = port;
//         return this;
//     }
// 
//     public StubBuilder stub() {
//         StubBuilder child = new StubBuilder(this);
//         stubBuilders.add(child);
//         return child;
//     }
// 
//     public Imposter build() {
//         Imposter imposter = new Imposter().onPort(port);
//         for (StubBuilder stubBuilder : stubBuilders) {
//             imposter.addStub(stubBuilder.build());
//         }
//         return imposter;
//     }
// }
// 
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java
// public class Imposter extends HashMap {
//     private static final String PORT = "port";
//     private static final String PROTOCOL = "protocol";
//     private static final String STUBS = "stubs";
// 
//     public Imposter() {
//         this.put(PROTOCOL, "http");
//         this.put(STUBS, newArrayList());
//     }
// 
//     public static Imposter fromJSON(JSONObject json) {
//         Imposter imposter = new Imposter();
//         imposter.putAll(json);
// 
//         return imposter;
//     }
// 
//     public static Imposter anImposter() {
//         return new Imposter();
//     }
// 
//     public Imposter onPort(int port) {
//         this.put(PORT, port);
//         return this;
//     }
// 
//     public Imposter addStub(Stub stub) {
//         getStubs().add(stub);
//         return this;
//     }
// 
//     public Imposter withStub(Stub stub) {
//         this.remove(STUBS);
//         this.put(STUBS, newArrayList());
//         addStub(stub);
//         return this;
//     }
// 
//     public List<Stub> getStubs() {
//         return ((List) get(STUBS));
//     }
// 
//     public Stub getStub(int index) {
//         return getStubs().get(index);
//     }
// 
//     public JSONObject toJSON() {
//         return new JSONObject(this);
//     }
// 
//     public String toString() {
//         return toJSON().toJSONString();
//     }
// 
//     public int getPort() {
//         return Integer.valueOf(String.valueOf(get(PORT)));
//     }
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.imposters.Imposter;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import com.mashape.unirest.request.body.RequestBodyEntity;
    }

    @Test
    public void shouldCountTheNumberOfImposters() throws UnirestException {
        JsonNode jsonNode = mock(JsonNode.class);
        JSONObject jsonObject = mock(JSONObject.class);
        JSONArray jsonArray = mock(JSONArray.class);
        when(Unirest.get(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(getRequest);
        when(getRequest.asJson()).thenReturn(httpResponse);
        when(httpResponse.getBody()).thenReturn(jsonNode);
        when(jsonNode.getObject()).thenReturn(jsonObject);
        when(jsonObject.get("imposters")).thenReturn(jsonArray);
        when(jsonArray.length()).thenReturn(Integer.valueOf(3));

        assertThat(client.getImposterCount()).isEqualTo(3);
    }

    @Test
    public void shouldDeleteAllImposters() throws UnirestException {
        when(Unirest.delete(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(requestWithBody);
        when(requestWithBody.asJson()).thenReturn(httpResponse);
        when(httpResponse.getStatus()).thenReturn(Integer.valueOf(200));

        assertThat(client.deleteAllImposters()).isEqualTo(200);
    }

    @Test
    public void shouldGetAnImposter() throws ParseException, UnirestException {
        int port = 5757;
        String jsonString = "test string";
// Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ImposterBuilder.java
// public class ImposterBuilder {
//     private int port;
//     private List<StubBuilder> stubBuilders = newArrayList();
// 
//     public static ImposterBuilder anImposter() {
//         return new ImposterBuilder();
//     }
// 
//     public ImposterBuilder onPort(int port) {
//         this.port = port;
//         return this;
//     }
// 
//     public StubBuilder stub() {
//         StubBuilder child = new StubBuilder(this);
//         stubBuilders.add(child);
//         return child;
//     }
// 
//     public Imposter build() {
//         Imposter imposter = new Imposter().onPort(port);
//         for (StubBuilder stubBuilder : stubBuilders) {
//             imposter.addStub(stubBuilder.build());
//         }
//         return imposter;
//     }
// }
// 
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java
// public class Imposter extends HashMap {
//     private static final String PORT = "port";
//     private static final String PROTOCOL = "protocol";
//     private static final String STUBS = "stubs";
// 
//     public Imposter() {
//         this.put(PROTOCOL, "http");
//         this.put(STUBS, newArrayList());
//     }
// 
//     public static Imposter fromJSON(JSONObject json) {
//         Imposter imposter = new Imposter();
//         imposter.putAll(json);
// 
//         return imposter;
//     }
// 
//     public static Imposter anImposter() {
//         return new Imposter();
//     }
// 
//     public Imposter onPort(int port) {
//         this.put(PORT, port);
//         return this;
//     }
// 
//     public Imposter addStub(Stub stub) {
//         getStubs().add(stub);
//         return this;
//     }
// 
//     public Imposter withStub(Stub stub) {
//         this.remove(STUBS);
//         this.put(STUBS, newArrayList());
//         addStub(stub);
//         return this;
//     }
// 
//     public List<Stub> getStubs() {
//         return ((List) get(STUBS));
//     }
// 
//     public Stub getStub(int index) {
//         return getStubs().get(index);
//     }
// 
//     public JSONObject toJSON() {
//         return new JSONObject(this);
//     }
// 
//     public String toString() {
//         return toJSON().toJSONString();
//     }
// 
//     public int getPort() {
//         return Integer.valueOf(String.valueOf(get(PORT)));
//     }
// }


// Path: javabank-client/src/test/java/org/mbtest/javabank/ClientTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.imposters.Imposter;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import com.mashape.unirest.request.body.RequestBodyEntity;

    }

    @Test
    public void shouldCountTheNumberOfImposters() throws UnirestException {
        JsonNode jsonNode = mock(JsonNode.class);
        JSONObject jsonObject = mock(JSONObject.class);
        JSONArray jsonArray = mock(JSONArray.class);
        when(Unirest.get(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(getRequest);
        when(getRequest.asJson()).thenReturn(httpResponse);
        when(httpResponse.getBody()).thenReturn(jsonNode);
        when(jsonNode.getObject()).thenReturn(jsonObject);
        when(jsonObject.get("imposters")).thenReturn(jsonArray);
        when(jsonArray.length()).thenReturn(Integer.valueOf(3));

        assertThat(client.getImposterCount()).isEqualTo(3);
    }

    @Test
    public void shouldDeleteAllImposters() throws UnirestException {
        when(Unirest.delete(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(requestWithBody);
        when(requestWithBody.asJson()).thenReturn(httpResponse);
        when(httpResponse.getStatus()).thenReturn(Integer.valueOf(200));

        assertThat(client.deleteAllImposters()).isEqualTo(200);
    }

    @Test
    public void shouldGetAnImposter() throws ParseException, UnirestException {
        int port = 5757;
        String jsonString = "test string";
        Imposter expectedImposter = new ImposterBuilder().onPort(5757).build();