use of retrofit2.helpers.NullObjectConverterFactory in project retrofit by square.
the class RequestBuilderTest method fieldParamMapsConvertedToNullShouldError.
@Test
public void fieldParamMapsConvertedToNullShouldError() throws Exception {
class Example {
@FormUrlEncoded
@POST("/query")
Call<ResponseBody> queryPath(@FieldMap Map<String, String> a) {
return null;
}
}
Retrofit.Builder retrofitBuilder = new Retrofit.Builder().baseUrl("http://example.com").addConverterFactory(new NullObjectConverterFactory());
Map<String, String> queryMap = Collections.singletonMap("kit", "kat");
try {
buildRequest(Example.class, retrofitBuilder, queryMap);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessageContaining("Field map value 'kat' converted to null by retrofit2.helpers.NullObjectConverterFactory$1 for key 'kit'.");
}
}
use of retrofit2.helpers.NullObjectConverterFactory in project retrofit by square.
the class RequestBuilderTest method queryParamsSkippedIfConvertedToNull.
@Test
public void queryParamsSkippedIfConvertedToNull() throws Exception {
class Example {
@GET("/query")
Call<ResponseBody> queryPath(@Query("a") Object a) {
return null;
}
}
Retrofit.Builder retrofitBuilder = new Retrofit.Builder().baseUrl("http://example.com").addConverterFactory(new NullObjectConverterFactory());
Request request = buildRequest(Example.class, retrofitBuilder, "Ignored");
assertThat(request.url().toString()).doesNotContain("Ignored");
}
use of retrofit2.helpers.NullObjectConverterFactory in project retrofit by square.
the class RequestBuilderTest method fieldParamsSkippedIfConvertedToNull.
@Test
public void fieldParamsSkippedIfConvertedToNull() throws Exception {
class Example {
@FormUrlEncoded
@POST("/query")
Call<ResponseBody> queryPath(@Field("a") Object a) {
return null;
}
}
Retrofit.Builder retrofitBuilder = new Retrofit.Builder().baseUrl("http://example.com").addConverterFactory(new NullObjectConverterFactory());
Request request = buildRequest(Example.class, retrofitBuilder, "Ignored");
assertThat(request.url().toString()).doesNotContain("Ignored");
}
use of retrofit2.helpers.NullObjectConverterFactory in project retrofit by square.
the class RequestBuilderTest method queryParamMapsConvertedToNullShouldError.
@Test
public void queryParamMapsConvertedToNullShouldError() throws Exception {
class Example {
@GET("/query")
Call<ResponseBody> queryPath(@QueryMap Map<String, String> a) {
return null;
}
}
Retrofit.Builder retrofitBuilder = new Retrofit.Builder().baseUrl("http://example.com").addConverterFactory(new NullObjectConverterFactory());
Map<String, String> queryMap = Collections.singletonMap("kit", "kat");
try {
buildRequest(Example.class, retrofitBuilder, queryMap);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessageContaining("Query map value 'kat' converted to null by retrofit2.helpers.NullObjectConverterFactory$1 for key 'kit'.");
}
}
Aggregations