MapzenSearchHttpHandler implements GenericHttpHandler { @NonNull SearchRequestHandler searchHandler() { return searchHandler; } MapzenSearchHttpHandler(@NonNull Context context);   }
@Test public void shouldPullApiKey() { assertThat(handler.searchHandler().getApiKey()).isEqualTo("test-api-key"); }
@Test public void shouldUpdateApiKeyAutomatically() { MapzenManager.instance(getMockContext()).setApiKey("updated-api-key"); assertThat(handler.searchHandler().getApiKey()).isEqualTo("updated-api-key"); }
@Test public void setApiKey_shouldSetKey() { handler.searchHandler().setApiKey("TEST_KEY"); assertThat(handler.searchHandler().getApiKey()).isEqualTo("TEST_KEY"); }
@Test public void queryParamsForRequest_shouldReturnApiKey() { handler.searchHandler().setApiKey("TEST_KEY"); Map expected = new HashMap(); expected.put(API_KEY_PARAM_NAME, "TEST_KEY"); assertThat(handler.searchHandler().queryParamsForRequest()).isEqualTo(expected); }
@Test public void headersForRequest_shouldIncludeUserAgent() { Map headers = handler.searchHandler().headersForRequest(); Map expected = new HashMap(); expected.put(HEADER_USER_AGENT, USER_AGENT); assertThat(headers).isEqualTo(expected); }
@Test public void queryParamsForRequest_shouldReturnAllParams() { testParams = TestVals.testParams(); handler.searchHandler().setApiKey("TEST_KEY"); Map expected = new HashMap(); expected.put(API_KEY_PARAM_NAME, "TEST_KEY"); expected.putAll(testParams); assertThat(handler.searchHandler().queryParamsForRequest()).isEqualTo(expected); }
@Test public void headersForRequest_shouldReturnAllHeaders() { testHeaders = TestVals.testHeaders(); Map headers = handler.searchHandler().headersForRequest(); Map expected = new HashMap(); expected.put(HEADER_USER_AGENT, USER_AGENT); expected.putAll(testHeaders); assertThat(headers).isEqualTo(expected); }