本文整理匯總了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);