当前位置: 首页>>代码示例>>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;未经允许,请勿转载。