當前位置: 首頁>>代碼示例>>Java>>正文


Java FieldMap類代碼示例

本文整理匯總了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.");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:RequestBuilderTest.java

示例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.");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RequestBuilderTest.java

示例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'.");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RequestBuilderTest.java

示例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");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:RequestBuilderTest.java

示例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");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RequestBuilderTest.java

示例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'.");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:RequestBuilderTest.java

示例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");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RequestBuilderTest.java

示例8: login

import retrofit2.http.FieldMap; //導入依賴的package包/類
@FormUrlEncoded
@POST(Constant.URL_LOGIN)
Observable<ResponseBody> login(@FieldMap Map<String, String> map);
 
開發者ID:penghuanliang,項目名稱:Rxjava2.0Demo,代碼行數:4,代碼來源:LoginApi.java

示例9: getToken

import retrofit2.http.FieldMap; //導入依賴的package包/類
@FormUrlEncoded
Observable<ResponseBody> getToken(@Url String url, @FieldMap Map<String, String> map);
 
開發者ID:penghuanliang,項目名稱:Rxjava2.0Demo,代碼行數:3,代碼來源:LoginApi.java

示例10: getUserInfo

import retrofit2.http.FieldMap; //導入依賴的package包/類
@FormUrlEncoded
Observable<ResponseBody> getUserInfo(@Url String url, @FieldMap Map<String, String> map);
 
開發者ID:penghuanliang,項目名稱:Rxjava2.0Demo,代碼行數:3,代碼來源:LoginApi.java

示例11: post

import retrofit2.http.FieldMap; //導入依賴的package包/類
@FormUrlEncoded
@POST()
Observable<ResponseBody> post(@Url() String url, @FieldMap Map<String, String> maps);
 
開發者ID:qiaodashaoye,項目名稱:SuperHttp,代碼行數:4,代碼來源:ApiService.java

示例12: login

import retrofit2.http.FieldMap; //導入依賴的package包/類
/**
 * 登錄
 */
@FormUrlEncoded
@POST(BaseApi.Url.URL_LOGIN)
Observable<JSONObject> login(@FieldMap Map<String, String> map);
 
開發者ID:Jusenr,項目名稱:RX_Demo,代碼行數:7,代碼來源:GankApi.java

示例13: logout

import retrofit2.http.FieldMap; //導入依賴的package包/類
/**
 * 登出
 */
@FormUrlEncoded
@POST(BaseApi.Url.URL_API_LOGIN)
Observable<Model1<UserModel>> logout(@FieldMap Map<String, String> map);
 
開發者ID:Jusenr,項目名稱:RX_Demo,代碼行數:7,代碼來源:GankApi.java

示例14: register

import retrofit2.http.FieldMap; //導入依賴的package包/類
/**
 * 注冊
 */
@FormUrlEncoded
@POST(BaseApi.Url.URL_REGISTER)
Observable<JSONObject> register(@FieldMap Map<String, String> map);
 
開發者ID:Jusenr,項目名稱:RX_Demo,代碼行數:7,代碼來源:PassportApi.java

示例15: getNickname

import retrofit2.http.FieldMap; //導入依賴的package包/類
/**
 * 注冊
 */
@FormUrlEncoded
@POST(BaseApi.Url.URL_GET_NICK_NAME)
Observable<UserModel> getNickname(@FieldMap Map<String, String> map);
 
開發者ID:Jusenr,項目名稱:RX_Demo,代碼行數:7,代碼來源:PassportApi.java


注:本文中的retrofit2.http.FieldMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。