// 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/core/Stub.java
// public class Stub extends HashMap {
// 
//     private static final String RESPONSES = "responses";
//     private static final String PREDICATES = "predicates";
// 
//     public Stub() {
//         this.put(RESPONSES, newArrayList());
//         this.put(PREDICATES, newArrayList());
//     }
// 
//     public Stub withResponse(Is response) {
//         getResponses().clear();
//         getResponses().add(response);
// 
//         return this;
//     }
// 
//     public Stub addResponse(Response response) {
//         getResponses().add(response);
// 
//         return this;
//     }
// 
//     public Stub addPredicates(List<Predicate> predicates) {
//         getPredicates().addAll(predicates);
//         return this;
//     }
// 
//     public List<Response> getResponses() {
//         return (List<Response>) this.get(RESPONSES);
//     }
// 
//     public List<Predicate> getPredicates() {
//         return (List<Predicate>) this.get(PREDICATES);
//     }
// 
//     public HashMap getResponse(int index) {
//         return getResponses().get(index);
//     }
// 
//     public Predicate getPredicate(int index) {
//         return getPredicates().get(index);
//     }
// }
// 
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Is.java
// public class Is extends Response {
//     private static final String IS = "is";
//     private static final String HEADERS = "headers";
//     private static final String BODY = "body";
//     private static final String STATUS_CODE = "statusCode";
//     public static final String MODE = "_mode";
// 
//     private final Map<String, Object> data;
//     private Map<String, String> headers;
// 
//     public Is() {
//         headers = newHashMap();
//         headers.put(HttpHeaders.CONNECTION, "close");
// 
//         this.data = newHashMap();
//         this.data.put(STATUS_CODE, 200);
//         this.data.put(HEADERS, headers);
// 
//         this.put(IS, data);
//         withStatusCode(HttpStatus.SC_OK);
//         withBody("");
//     }
// 
//     public Is withStatusCode(int statusCode) {
//         this.data.put("statusCode", statusCode);
//         return this;
//     }
// 
//     public Is withHeader(String name, String value) {
//         this.headers.clear();
//         addHeader(name, value);
//         return this;
//     }
// 
//     public Is addHeader(String name, String value) {
//         this.headers.put(name, value);
//         return this;
//     }
// 
//     public Is withBody(String body) {
//         this.data.put(BODY, body);
//         return this;
//     }
// 
//     public Is withMode(String mode){
//         if(!Objects.isNull(mode)) {
//             this.data.put(MODE, mode);
//         }
//         return this;
//     }
// 
//     public Is withHeaders(Map<String, String> headers) {
//         this.headers = headers;
//         this.data.put(HEADERS, headers);  // issue #5
//         return this;
//     }
// 
//     public int getStatusCode() {
//         return Integer.valueOf(String.valueOf(this.data.get(STATUS_CODE)));
//     }
// 
//     public Map<String, String> getHeaders() {
//         return headers;
//     }
// 
//     public String getBody() {
//         return (String) this.data.get(BODY);
//     }
// 
//     public String getMode() {
//         return (String) this.data.get(MODE);
//     }
// }


import org.apache.http.HttpHeaders;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.core.Stub;
import org.mbtest.javabank.http.responses.Is;
import static org.assertj.core.api.Assertions.assertThat;
                .withStub(new Stub());

        JSONObject expectedJson = new JSONObject();
        expectedJson.put("port", expectedPort);
        expectedJson.put("protocol", expectedProtocol);
        JSONArray stubs = new JSONArray();
        stubs.add(new Stub());
        expectedJson.put("stubs", stubs);

        assertThat(imposter.toJSON()).isEqualTo(expectedJson);
    }

    @Test
    public void shouldCreateAJsonObjectWithBuilder() {

        String expectedBody = "Hello World!";
        int expectedStatusCode = 201;
        String expectedContentType = "plain/text";

        Imposter imposter = ImposterBuilder.anImposter().onPort(expectedPort)
                .stub()
                  .response()
                    .is()
                      .body(expectedBody)
                      .statusCode(expectedStatusCode)
                      .header(com.google.common.net.HttpHeaders.CONTENT_TYPE, expectedContentType)
                    .end()
                  .end()
                .end().build();

// 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/core/Stub.java
// public class Stub extends HashMap {
// 
//     private static final String RESPONSES = "responses";
//     private static final String PREDICATES = "predicates";
// 
//     public Stub() {
//         this.put(RESPONSES, newArrayList());
//         this.put(PREDICATES, newArrayList());
//     }
// 
//     public Stub withResponse(Is response) {
//         getResponses().clear();
//         getResponses().add(response);
// 
//         return this;
//     }
// 
//     public Stub addResponse(Response response) {
//         getResponses().add(response);
// 
//         return this;
//     }
// 
//     public Stub addPredicates(List<Predicate> predicates) {
//         getPredicates().addAll(predicates);
//         return this;
//     }
// 
//     public List<Response> getResponses() {
//         return (List<Response>) this.get(RESPONSES);
//     }
// 
//     public List<Predicate> getPredicates() {
//         return (List<Predicate>) this.get(PREDICATES);
//     }
// 
//     public HashMap getResponse(int index) {
//         return getResponses().get(index);
//     }
// 
//     public Predicate getPredicate(int index) {
//         return getPredicates().get(index);
//     }
// }
// 
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Is.java
// public class Is extends Response {
//     private static final String IS = "is";
//     private static final String HEADERS = "headers";
//     private static final String BODY = "body";
//     private static final String STATUS_CODE = "statusCode";
//     public static final String MODE = "_mode";
// 
//     private final Map<String, Object> data;
//     private Map<String, String> headers;
// 
//     public Is() {
//         headers = newHashMap();
//         headers.put(HttpHeaders.CONNECTION, "close");
// 
//         this.data = newHashMap();
//         this.data.put(STATUS_CODE, 200);
//         this.data.put(HEADERS, headers);
// 
//         this.put(IS, data);
//         withStatusCode(HttpStatus.SC_OK);
//         withBody("");
//     }
// 
//     public Is withStatusCode(int statusCode) {
//         this.data.put("statusCode", statusCode);
//         return this;
//     }
// 
//     public Is withHeader(String name, String value) {
//         this.headers.clear();
//         addHeader(name, value);
//         return this;
//     }
// 
//     public Is addHeader(String name, String value) {
//         this.headers.put(name, value);
//         return this;
//     }
// 
//     public Is withBody(String body) {
//         this.data.put(BODY, body);
//         return this;
//     }
// 
//     public Is withMode(String mode){
//         if(!Objects.isNull(mode)) {
//             this.data.put(MODE, mode);
//         }
//         return this;
//     }
// 
//     public Is withHeaders(Map<String, String> headers) {
//         this.headers = headers;
//         this.data.put(HEADERS, headers);  // issue #5
//         return this;
//     }
// 
//     public int getStatusCode() {
//         return Integer.valueOf(String.valueOf(this.data.get(STATUS_CODE)));
//     }
// 
//     public Map<String, String> getHeaders() {
//         return headers;
//     }
// 
//     public String getBody() {
//         return (String) this.data.get(BODY);
//     }
// 
//     public String getMode() {
//         return (String) this.data.get(MODE);
//     }
// }


// Path: javabank-core/src/test/java/org/mbtest/javabank/http/imposters/ImposterTest.java
import org.apache.http.HttpHeaders;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.core.Stub;
import org.mbtest.javabank.http.responses.Is;
import static org.assertj.core.api.Assertions.assertThat;

                .withStub(new Stub());

        JSONObject expectedJson = new JSONObject();
        expectedJson.put("port", expectedPort);
        expectedJson.put("protocol", expectedProtocol);
        JSONArray stubs = new JSONArray();
        stubs.add(new Stub());
        expectedJson.put("stubs", stubs);

        assertThat(imposter.toJSON()).isEqualTo(expectedJson);
    }

    @Test
    public void shouldCreateAJsonObjectWithBuilder() {

        String expectedBody = "Hello World!";
        int expectedStatusCode = 201;
        String expectedContentType = "plain/text";

        Imposter imposter = ImposterBuilder.anImposter().onPort(expectedPort)
                .stub()
                  .response()
                    .is()
                      .body(expectedBody)
                      .statusCode(expectedStatusCode)
                      .header(com.google.common.net.HttpHeaders.CONTENT_TYPE, expectedContentType)
                    .end()
                  .end()
                .end().build();

        final Is response = new Is();