gt:         Response<Currency[]> result = bittrexExchange.getCurrencies();
context: /*
   * *
   *  This file is part of the bittrex4j project.
   *
   *  @author CCob
   *
   *  For the full copyright and license information, please view the LICENSE
   *  file that was distributed with this source code.
   * /
   */
  
  package com.github.ccob.bittrex4j;
  
  import com.github.ccob.bittrex4j.dao.*;
  import com.github.ccob.bittrex4j.dao.OrderBook.TYPE;
  import com.github.signalr4j.client.hubs.*;
  import com.google.gson.Gson;
  import com.google.gson.internal.LinkedTreeMap;
  
  import org.apache.http.HttpResponse;
  import org.apache.http.HttpStatus;
  import org.apache.http.ProtocolVersion;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.CloseableHttpResponse;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.client.protocol.HttpClientContext;
  import org.apache.http.entity.BasicHttpEntity;
  import org.apache.http.impl.client.BasicCookieStore;
  import org.apache.http.message.BasicStatusLine;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.mockito.*;
  import org.mockito.runners.MockitoJUnitRunner;
  
  import java.io.ByteArrayInputStream;
  import java.io.IOException;
  import java.math.BigDecimal;
  import java.util.Scanner;
  
  import static org.hamcrest.CoreMatchers.equalTo;
  import static org.hamcrest.CoreMatchers.is;
  import static org.hamcrest.CoreMatchers.notNullValue;
  import static org.hamcrest.MatcherAssert.assertThat;
  import static org.junit.Assert.assertEquals;
  import static org.mockito.Matchers.*;
  import static org.mockito.Mockito.verify;
  import static org.mockito.Mockito.when;
  
  @RunWith(MockitoJUnitRunner.class)
  public class BittrexExchangeTest {
  
      @Mock
      private
      HttpClient mockHttpClient;
  
      @Mock
      private
      HttpClientContext mockHttpClientContext;
  
      @Mock
      private HubConnection mockHubConnection;
  
      @Mock
      private HubProxy mockHubProxy;
  
      @Mock
      private HttpFactory mockHttpFactory;
  
      @Captor
      private ArgumentCaptor<SubscriptionHandler1<Object>> subscriptionHandlerArgumentCaptor;
  
      @Captor
      private ArgumentCaptor<SubscriptionHandler1<String>> subscriptionHandlerArgumentCaptorString;
  
      private static final String NOT_FOUND = "Not Found";
      private static final String IO_ERROR = "IO Error";
      private static final String STATUS_OK_TEXT = "OK";
      private BittrexExchange bittrexExchange;
      private boolean lambdaCalled;
  
      private HttpResponse createResponse(int httpStatus, String statusText, String responseText){
  
          CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
  
          BasicHttpEntity httpEntity = new BasicHttpEntity();
          httpEntity.setContent(new ByteArrayInputStream(responseText.getBytes()));
  
          when(response.getStatusLine()).thenReturn(new BasicStatusLine(
                  new ProtocolVersion("HTTP", 1, 1), httpStatus, statusText));
  
          when(response.getEntity()).thenReturn(httpEntity);
  
          when(response.toString()).thenReturn("MockClosableHttpResponse");
  
          return response;
      }
  
      private String loadTestResourceAsString(String resourceName){
          return new Scanner(getClass().getResourceAsStream(resourceName), "UTF-8")
                  .useDelimiter("\\A")
                  .next();
      }
  
      @Before
      public void setUp() throws IOException {
  
          when(mockHubConnection.createHubProxy("c2")).thenReturn(mockHubProxy);
  
          HttpResponse mockResponse = createResponse(HttpStatus.SC_OK,STATUS_OK_TEXT,"Bittrex");
  
          when(mockHttpClientContext.getCookieStore()).thenReturn(new BasicCookieStore());
          when(mockHttpClient.execute(argThat(UrlMatcher.matchesUrl("https://bittrex.com")),eq(mockHttpClientContext)))
                  .thenReturn(mockResponse);
  
          when(mockHttpFactory.createClient()).thenReturn(mockHttpClient);
          when(mockHttpFactory.createClientContext()).thenReturn(mockHttpClientContext);
          when(mockHttpFactory.createHubConnection(any(),any(),anyBoolean(),any())).thenReturn(mockHubConnection);
  
          bittrexExchange = new BittrexExchange(0,"apikey","secret", mockHttpFactory);
          lambdaCalled = false;
      }
  
      private void setExpectationForHubConnectionSuccess(){
          ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
          verify(mockHubConnection).connected(runnableArgumentCaptor.capture());
          runnableArgumentCaptor.getValue().run();
      }
  
      private void setExpectationForNon2xxErrorOnWebAPICall() throws IOException {
          HttpResponse mockResponse = createResponse(HttpStatus.SC_NOT_FOUND,NOT_FOUND,NOT_FOUND);
          when(mockHttpClient.execute(any(HttpGet.class),eq(mockHttpClientContext)))
                  .thenReturn(mockResponse);
      }
  
      private void setExpectationForExceptionOnWebAPICall() throws IOException {
          when(mockHttpClient.execute(any(HttpGet.class),eq(mockHttpClientContext)))
                  .thenThrow(new IOException(IO_ERROR));
      }
  
      private void setExpectationForJsonResultOnWebAPICall(String jsonResult) throws IOException {
          HttpResponse mockResponse = createResponse(HttpStatus.SC_OK,STATUS_OK_TEXT,jsonResult);
          when(mockHttpClient.execute(any(HttpGet.class),eq(mockHttpClientContext)))
                  .thenReturn(mockResponse);
      }
  
      @Test
      public void shouldConstructAndSetupCookies(){
      }
  
      @Test
      public void shouldReturnErrorResultOnNon2xxCode() throws IOException {
          setExpectationForNon2xxErrorOnWebAPICall();
          Response<MarketSummaryResult[]> result = bittrexExchange.getMarketSummaries();
  
          assertThat(result.isSuccess(), is(false));
          assertThat(result.getMessage(), equalTo(NOT_FOUND));
      }
  
      @Test
      public void shouldReturnErrorResultOnException() throws IOException {
          setExpectationForExceptionOnWebAPICall();
          Response<MarketSummaryResult[]> result = bittrexExchange.getMarketSummaries();
  
          assertThat(result.isSuccess(), is(false));
          assertThat(result.getMessage(), equalTo(IO_ERROR));
      }
  
      @Test
      public void shouldReturnTicks() throws IOException {
          setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/GetTicks.json"));
          Response<Tick[]> result = bittrexExchange.getTicks("ANY", BittrexExchange.Interval.fiveMin);
  
          assertThat(result.isSuccess(), is(true));
          assertThat(result.getResult().length, equalTo(5));
      }
  
      @Test
      public void shouldReturnLatestTick() throws IOException {
          setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/GetLatestTick.json"));
          Response<Tick[]> result = bittrexExchange.getLatestTick("ANY", BittrexExchange.Interval.fiveMin);
  
          assertThat(result.isSuccess(), is(true));
          assertThat(result.getResult().length, equalTo(1));
      }
  
      @Test
      public void shouldReturnMarketHistory() throws IOException {
          setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/MarketHistory.json"));
          Response<CompletedOrder[]> result = bittrexExchange.getMarketHistory("ANY");
  
          assertThat(result.isSuccess(), is(true));
          assertThat(result.getResult().length, equalTo(4));
      }
  
      @Test
      public void shouldReturnMarkets() throws IOException{
          setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/Markets.json"));
          Response<Market[]> result = bittrexExchange.getMarkets();
  
          assertThat(result.isSuccess(), is(true));
          assertThat(result.getResult().length,equalTo(2));
      }
  
      @Test
      public void shouldReturnCurrencies() throws IOException{
          setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/Currencies.json"));
  