本文整理汇总了Java中retrofit2.http.FieldMap类的典型用法代码示例。如果您正苦于以下问题:Java FieldMap类的具体用法?Java FieldMap怎么用?Java FieldMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldMap类属于retrofit2.http包,在下文中一共展示了FieldMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fieldMapRejectsNull
import retrofit2.http.FieldMap; //导入依赖的package包/类
@Test public void fieldMapRejectsNull() {
class Example {
@FormUrlEncoded //
@POST("/") //
Call<ResponseBody> method(@FieldMap Map<String, Object> a) {
return null;
}
}
try {
buildRequest(Example.class, new Object[] { null });
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Field map was null.");
}
}
示例2: fieldMapRejectsNullKeys
import retrofit2.http.FieldMap; //导入依赖的package包/类
@Test public void fieldMapRejectsNullKeys() {
class Example {
@FormUrlEncoded //
@POST("/") //
Call<ResponseBody> method(@FieldMap Map<String, Object> a) {
return null;
}
}
Map<String, Object> fieldMap = new LinkedHashMap<>();
fieldMap.put("kit", "kat");
fieldMap.put(null, "pong");
try {
buildRequest(Example.class, fieldMap);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Field map contained null key.");
}
}
示例3: fieldMapRejectsNullValues
import retrofit2.http.FieldMap; //导入依赖的package包/类
@Test public void fieldMapRejectsNullValues() {
class Example {
@FormUrlEncoded //
@POST("/") //
Call<ResponseBody> method(@FieldMap Map<String, Object> a) {
return null;
}
}
Map<String, Object> fieldMap = new LinkedHashMap<>();
fieldMap.put("kit", "kat");
fieldMap.put("foo", null);
try {
buildRequest(Example.class, fieldMap);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Field map contained null value for key 'foo'.");
}
}
示例4: fieldMapMustBeAMap
import retrofit2.http.FieldMap; //导入依赖的package包/类
@Test public void fieldMapMustBeAMap() {
class Example {
@FormUrlEncoded //
@POST("/") //
Call<ResponseBody> method(@FieldMap List<String> a) {
return null;
}
}
try {
buildRequest(Example.class);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage(
"@FieldMap parameter type must be Map. (parameter #1)\n for method Example.method");
}
}
示例5: fieldMapSupportsSubclasses
import retrofit2.http.FieldMap; //导入依赖的package包/类
@Test public void fieldMapSupportsSubclasses() throws IOException {
class Foo extends HashMap<String, String> {
}
class Example {
@FormUrlEncoded //
@POST("/") //
Call<ResponseBody> method(@FieldMap Foo a) {
return null;
}
}
Foo foo = new Foo();
foo.put("hello", "world");
Request request = buildRequest(Example.class, foo);
Buffer buffer = new Buffer();
request.body().writeTo(buffer);
assertThat(buffer.readUtf8()).isEqualTo("hello=world");
}
示例6: fieldParamMapsConvertedToNullShouldError
import retrofit2.http.FieldMap; //导入依赖的package包/类
@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'.");
}
}
示例7: implicitFormEncodingByFieldMapForbidden
import retrofit2.http.FieldMap; //导入依赖的package包/类
@Test public void implicitFormEncodingByFieldMapForbidden() {
class Example {
@POST("/") //
Call<ResponseBody> method(@FieldMap Map<String, String> a) {
return null;
}
}
try {
buildRequest(Example.class);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage(
"@FieldMap parameters can only be used with form encoding. (parameter #1)\n for method Example.method");
}
}
示例8: login
import retrofit2.http.FieldMap; //导入依赖的package包/类
@FormUrlEncoded
@POST(Constant.URL_LOGIN)
Observable<ResponseBody> login(@FieldMap Map<String, String> map);
示例9: getToken
import retrofit2.http.FieldMap; //导入依赖的package包/类
@FormUrlEncoded
Observable<ResponseBody> getToken(@Url String url, @FieldMap Map<String, String> map);
示例10: getUserInfo
import retrofit2.http.FieldMap; //导入依赖的package包/类
@FormUrlEncoded
Observable<ResponseBody> getUserInfo(@Url String url, @FieldMap Map<String, String> map);
示例11: post
import retrofit2.http.FieldMap; //导入依赖的package包/类
@FormUrlEncoded
@POST()
Observable<ResponseBody> post(@Url() String url, @FieldMap Map<String, String> maps);
示例12: login
import retrofit2.http.FieldMap; //导入依赖的package包/类
/**
* 登录
*/
@FormUrlEncoded
@POST(BaseApi.Url.URL_LOGIN)
Observable<JSONObject> login(@FieldMap Map<String, String> map);
示例13: logout
import retrofit2.http.FieldMap; //导入依赖的package包/类
/**
* 登出
*/
@FormUrlEncoded
@POST(BaseApi.Url.URL_API_LOGIN)
Observable<Model1<UserModel>> logout(@FieldMap Map<String, String> map);
示例14: register
import retrofit2.http.FieldMap; //导入依赖的package包/类
/**
* 注册
*/
@FormUrlEncoded
@POST(BaseApi.Url.URL_REGISTER)
Observable<JSONObject> register(@FieldMap Map<String, String> map);
示例15: getNickname
import retrofit2.http.FieldMap; //导入依赖的package包/类
/**
* 注册
*/
@FormUrlEncoded
@POST(BaseApi.Url.URL_GET_NICK_NAME)
Observable<UserModel> getNickname(@FieldMap Map<String, String> map);