RequestBuilder { @SuppressWarnings("unchecked") public B addHeader(String key, String value) { assertFinishState(); httpContent.addHeader(key, value); return (B) this; } RequestBuilder(RequestQueue requestQueue, VolleyerConfiguration configuration, String url, HttpMethod method); @SuppressWarnings("unchecked") B addHeader(String key, String value); ResponseBuilder<T> withTargetClass(Class<T> clazz); ResponseBuilder<String> withListener(Listener<String> listener); ResponseBuilder<String> withErrorListener(ErrorListener errorListener); Request<Void> execute();  }
@Test(expected=NullPointerException.class) public void addHeaderMethodShouldThrowNpeWhenKeyIsNull() { String nullKey = null; String value = "test"; String url = "test"; HttpMethod method = HttpMethod.GET; VolleyerConfiguration configuration = DefaultVolleyerConfigurationFactory.create(); TestPurposeRequestBuilder builder = new TestPurposeRequestBuilder(requestQueue, configuration, url, method); builder.addHeader(nullKey, value); }
@Test(expected=NullPointerException.class) public void addHeaderMethodShouldThrowNpeWhenValueIsNull() { String key = "test"; String nullValue = null; String url = "test"; HttpMethod method = HttpMethod.GET; VolleyerConfiguration configuration = DefaultVolleyerConfigurationFactory.create(); TestPurposeRequestBuilder builder = new TestPurposeRequestBuilder(requestQueue, configuration, url, method); builder.addHeader(key, nullValue); }
@Test public void addHeaderMethodShouldReturnSameInstanceOfBuilder() { String key = "testKey"; String value = "testValue"; String url = "test"; HttpMethod method = HttpMethod.GET; VolleyerConfiguration configuration = DefaultVolleyerConfigurationFactory.create(); TestPurposeRequestBuilder builder = new TestPurposeRequestBuilder(requestQueue, configuration, url, method); TestPurposeRequestBuilder newBuilder = builder.addHeader(key, value); assertTrue(builder == newBuilder); }