package uk.ac.ebi.eva.vcfdump.cellbasewsclient;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.integration.ClientAndProxy;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
import org.mockserver.model.JsonBody;
import org.mockserver.model.Parameter;
import org.springframework.http.HttpStatus;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import static org.junit.Assert.*;
import static org.mockserver.integration.ClientAndProxy.startClientAndProxy;
import static org.mockserver.integration.ClientAndServer.startClientAndServer;

public class ChromosomeWsClientTest {

    private MockServerClient mockServer;

    @Before
    public void setUp() {
        mockServer = startClientAndServer(1080);
        mockServer
                .when(
                        HttpRequest.request()
                                   .withMethod("GET")
                                   .withPath("/eva/webservices/rest/v1/segments")
                                   .withQueryStringParameter(
                                           new Parameter("species", "hsapiens_grch37")
                                   )
                )
                .respond(
                        HttpResponse.response()
                                    .withHeader("Content-Type", "application/json", "charset=UTF-8")
                                    .withStatusCode(HttpStatus.OK.value())
                                    .withBody( new JsonBody("{\"apiVersion\":\"v1\",\"warning\":\"\",\"error\":\"\",\"response\":[{\"id\":\"\",\"time\":0,\"dbTime\":-1,\"numResults\":25,\"numTotalResults\":25,\"warningMsg\":\"\",\"errorMsg\":\"\",\"resultType\":\"\",\"result\":[\"1\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\",\"2\",\"20\",\"21\",\"22\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"MT\",\"X\",\"Y\"]}]}"))
                );
    }

    @Test
    public void getChromosomes() throws Exception {
        String uri = UriComponentsBuilder.fromHttpUrl("http://localhost:1080/eva/webservices/rest/v1/segments")
                                         .queryParam("species", "hsapiens_grch37")
                                         .toUriString();

        RestTemplate restTemplate = new RestTemplate();
        ChromosomesWSOutput chromosomesWSOutput = restTemplate.getForObject(uri, ChromosomesWSOutput.class);
        System.out.println(chromosomesWSOutput.getAllChromosomeNames());
    }

}
@@ -63,60 +63,13 @@
 nit.
-After;%0Aimport org.junit.Before;%0Aimport org.junit.Rul
+Befor
 e;%0Ai
@@ -148,109 +148,8 @@
 nt;%0A
-import org.mockserver.integration.ClientAndProxy;%0Aimport org.mockserver.integration.ClientAndServer;%0A
 impo
@@ -470,110 +470,96 @@
 ort 
-static org.junit.Assert.*;%0Aimport static org.mockserver.integration.ClientAndProxy.startClientAndProxy
+java.util.Arrays;%0Aimport java.util.HashSet;%0A%0Aimport static org.junit.Assert.assertEquals
 ;%0Aim
@@ -2438,24 +2438,25 @@
 class);%0A
+%0A
         
 System.o
@@ -2451,27 +2451,264 @@
     
-System.out.println(
+assertEquals(%0A                new HashSet%3C%3E(Arrays.asList((new String%5B%5D %7B%221%22, %2210%22, %2211%22, %2212%22, %2213%22, %2214%22, %2215%22, %2216%22, %2217%22, %2218%22,%0A                        %2219%22, %222%22, %2220%22, %2221%22, %2222%22, %223%22, %224%22, %225%22, %226%22, %227%22, %228%22, %229%22, %22MT%22, %22X%22, %22Y%22%7D))),%0A                
 chro
@@ -2746,16 +2746,25 @@
 eNames()
+%0A        
 );%0A    %7D

Test working for querying mockserver