Java 类retrofit2.http.PartMap 实例源码

项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNonStringKeys() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<Object, RequestBody> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap keys must be of type String: class java.lang.Object (parameter #1)\n"
            + "    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsOkHttpPartValues() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, MultipartBody.Part> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap values cannot be MultipartBody.Part. Use @Part List<Part> or a different value type instead. (parameter #1)\n"
            + "    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNull() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Part map was null.");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNullKeys() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put(null, RequestBody.create(null, "kat"));

  try {
    buildRequest(Example.class, params);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Part map contained null key.");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNullValues() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put("kit", null);

  try {
    buildRequest(Example.class, params);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Part map contained null value for key 'kit'.");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapMustBeMap() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap List<Object> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, Collections.emptyList());
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap parameter type must be Map. (parameter #1)\n    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapSupportsSubclasses() throws IOException {
  class Foo extends HashMap<String, String> {
  }

  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Foo parts) {
      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())
      .contains("name=\"hello\"")
      .contains("\r\n\r\nworld\r\n--");
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNonStringKeys() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<Object, RequestBody> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap keys must be of type String: class java.lang.Object (parameter #1)\n"
            + "    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsOkHttpPartValues() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, MultipartBody.Part> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap values cannot be MultipartBody.Part. Use @Part List<Part> or a different value type instead. (parameter #1)\n"
            + "    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNull() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Part map was null.");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNullKeys() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put(null, RequestBody.create(null, "kat"));

  try {
    buildRequest(Example.class, params);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Part map contained null key.");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapRejectsNullValues() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put("kit", null);

  try {
    buildRequest(Example.class, params);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Part map contained null value for key 'kit'.");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapMustBeMap() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap List<Object> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, Collections.emptyList());
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap parameter type must be Map. (parameter #1)\n    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapSupportsSubclasses() throws IOException {
  class Foo extends HashMap<String, String> {
  }

  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Foo parts) {
      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())
      .contains("name=\"hello\"")
      .contains("\r\n\r\nworld\r\n--");
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void implicitMultipartWithPartMapForbidden() {
  class Example {
    @POST("/") //
    Call<ResponseBody> method(@PartMap Map<String, String> params) {
      return null;
    }
  }
  try {
    buildRequest(Example.class);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap parameters can only be used with multipart encoding. (parameter #1)\n    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMap() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put("kit", RequestBody.create(null, "kat"));

  Request request = buildRequest(Example.class, params);
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("\r\nkat\r\n--");
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapWithEncoding() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap(encoding = "8-bit") Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put("kit", RequestBody.create(null, "kat"));

  Request request = buildRequest(Example.class, params);
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("Content-Transfer-Encoding: 8-bit")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("Content-Transfer-Encoding: 8-bit")
      .contains("\r\nkat\r\n--");
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void implicitMultipartWithPartMapForbidden() {
  class Example {
    @POST("/") //
    Call<ResponseBody> method(@PartMap Map<String, String> params) {
      return null;
    }
  }
  try {
    buildRequest(Example.class);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap parameters can only be used with multipart encoding. (parameter #1)\n    for method Example.method");
  }
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMap() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put("kit", RequestBody.create(null, "kat"));

  Request request = buildRequest(Example.class, params);
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("\r\nkat\r\n--");
}
项目:GitHub    文件:RequestBuilderTest.java   
@Test public void multipartPartMapWithEncoding() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap(encoding = "8-bit") Map<String, RequestBody> parts) {
      return null;
    }
  }

  Map<String, RequestBody> params = new LinkedHashMap<>();
  params.put("ping", RequestBody.create(null, "pong"));
  params.put("kit", RequestBody.create(null, "kat"));

  Request request = buildRequest(Example.class, params);
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("Content-Transfer-Encoding: 8-bit")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("Content-Transfer-Encoding: 8-bit")
      .contains("\r\nkat\r\n--");
}
项目:Renrentou    文件:RegService.java   
@POST("user/regist/person")
@Multipart
Flowable<ResponseDto<User>> regPerson(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part front,
        @Part MultipartBody.Part back
);
项目:Renrentou    文件:AdService.java   
@POST("ad/new")
@Multipart
Flowable<ResponseDto<User>> add(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part adFile,
        @Part MultipartBody.Part coverFile
);
项目:Every-Sample    文件:HttpServiceSamples.java   
@Multipart
@POST("user")
Observable<BaseBean<String>> array_post(
        /**
         * key: String
         * value:把value用RequestBody包装放到Map中
         */
        @PartMap Map<String, RequestBody> map
);
项目:Renrentou    文件:FileUploadService.java   
@POST("file//upload/v1")
@Multipart
Flowable<ResponseDto> add(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part file
);
项目:Renrentou    文件:RegService.java   
@POST("user/regist/company")
@Multipart
Flowable<ResponseDto<User>> regCompany(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part front
);
项目:Renrentou    文件:AdService.java   
@POST("ad/new")
@Multipart
Flowable<ResponseDto<User>> add(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part adFile
);
项目:Renrentou    文件:AdService.java   
@POST("ad/delete")
@Multipart
Flowable<ResponseDto> delete(
        @PartMap Map<String, RequestBody> param
);
项目:filestack-java    文件:UploadService.java   
@Multipart
@POST("/multipart/start")
Call<StartResponse> start(@PartMap Map<String, RequestBody> parameters);
项目:filestack-java    文件:UploadService.java   
@Multipart
@POST("/multipart/upload")
Call<UploadResponse> upload(@PartMap Map<String, RequestBody> parameters);
项目:filestack-java    文件:UploadService.java   
@Multipart
@POST("/multipart/commit")
Call<ResponseBody> commit(@PartMap Map<String, RequestBody> parameters);
项目:filestack-java    文件:UploadService.java   
@Multipart
@POST("/multipart/complete")
Call<CompleteResponse> complete(@PartMap Map<String, RequestBody> parameters);
项目:AndroidBasicLibs    文件:ApiService.java   
@Multipart
@POST()
Observable<ResponseBody> uploadFiles(@Url() String url, @PartMap() Map<String, RequestBody>
        maps);
项目:JD-Test    文件:BaseApiService.java   
@Multipart
@POST
Flowable<ResponseBody> uploadFileWithPartMap(
        @Url() String url,
        @PartMap() Map<String, RequestBody> partMap,
        @Part("file") MultipartBody.Part file);
项目:RxEasyHttp    文件:ApiService.java   
@Multipart
@POST()
Observable<ResponseBody> uploadFiles(@Url String url, @PartMap() Map<String, RequestBody> maps);
项目:xifan    文件:ApiFactory.java   
@POST(Constants.FanFou.DESTROY_STATUSES_URL)
@Multipart
Observable<HttpResponseData<StatusRes>> destroyStatus(
        @PartMap Map<String, RequestBody> bodyMap);
项目:xifan    文件:ApiFactory.java   
@Multipart
@POST(Constants.FanFou.UPDATE_STATUSES_URL)
Observable<HttpResponseData<StatusRes>> updateStatus(@PartMap Map<String, RequestBody> bodyMap);
项目:xifan    文件:ApiFactory.java   
@POST(Constants.FanFou.PHOTOS_UPLOAD_URL)
@Multipart
Observable<HttpResponseData<StatusRes>> uploadPhoto(@PartMap Map<String, RequestBody> bodyMap);
项目:xifan    文件:ApiFactory.java   
@POST(Constants.FanFou.SEND_DIRECT_MESSAGE_URL)
@Multipart
Observable<HttpResponseData<DirectMessagesRes>> sendDirectMessage(
        @PartMap Map<String, RequestBody> bodyMap);
项目:xifan    文件:ApiFactory.java   
@POST(Constants.FanFou.CREATE_FRIENDSHIP_URL)
@Multipart
Observable<HttpResponseData<UserRes>> createFriendship(
        @PartMap Map<String, RequestBody> bodyMap);
项目:xifan    文件:ApiFactory.java   
@POST(Constants.FanFou.DESTROY_FRIENDSHIP_URL)
@Multipart
Observable<HttpResponseData<UserRes>> destoryFriendship(
        @PartMap Map<String, RequestBody> bodyMap);