当前位置: 首页>>代码示例>>Java>>正文


Java Calls.response方法代码示例

本文整理汇总了Java中retrofit2.mock.Calls.response方法的典型用法代码示例。如果您正苦于以下问题:Java Calls.response方法的具体用法?Java Calls.response怎么用?Java Calls.response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在retrofit2.mock.Calls的用法示例。


在下文中一共展示了Calls.response方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupStartMock

import retrofit2.mock.Calls; //导入方法依赖的package包/类
private static void setupStartMock(UploadService mockUploadService) {
  String jsonString = "{"
      + "'uri' : '/bucket/apikey/filename',"
      + "'region' : 'region',"
      + "'upload_id' : 'id',"
      + "'location_url' : 'url',"
      + "'upload_type' : 'intelligent_ingestion'"
      + "}";

  Gson gson = new Gson();
  StartResponse response = gson.fromJson(jsonString, StartResponse.class);
  Call call = Calls.response(response);
  Mockito
      .doReturn(call)
      .when(mockUploadService)
      .start(Mockito.<String, RequestBody>anyMap());
}
 
开发者ID:filestack,项目名称:filestack-java,代码行数:18,代码来源:TestClient.java

示例2: setupCompleteMock

import retrofit2.mock.Calls; //导入方法依赖的package包/类
private static void setupCompleteMock(UploadService mockUploadService) {
  String jsonString = "{"
      + "'handle' : 'handle',"
      + "'url' : 'url',"
      + "'filename' : 'filename',"
      + "'size' : '0',"
      + "'mimetype' : 'mimetype'"
      + "}";

  Gson gson = new Gson();
  CompleteResponse response = gson.fromJson(jsonString, CompleteResponse.class);
  Call call = Calls.response(response);
  Mockito
      .doReturn(call)
      .when(mockUploadService)
      .complete(Mockito.<String, RequestBody>anyMap());
}
 
开发者ID:filestack,项目名称:filestack-java,代码行数:18,代码来源:TestClient.java

示例3: testRequestEmail_withSuccess

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Test
public void testRequestEmail_withSuccess() {
    final User user = new UserBuilder().setEmail(TEST_EMAIL).build();
    final Call<User> call = Calls.response(user);
    setupMockAccountService(call);

    authClient.requestEmail(mock(TwitterSession.class), new Callback<String>() {
        @Override
        public void success(Result<String> result) {
            assertEquals(TEST_EMAIL, result.data);
        }

        @Override
        public void failure(TwitterException exception) {
            fail("Expected Callback#success to be called");
        }
    });
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:19,代码来源:TwitterAuthClientTest.java

示例4: invokesCallback

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Test public void invokesCallback() throws ExecutionException, InterruptedException {
  Message message = new TrackMessage.Builder().userId("userId").event("event").build();

  transporter.enqueue(message).get();
  verify(callback).success(Callback.Event.PERSIST, message);

  Call<Void> call = Calls.response(Response.success((Void) null));
  when(trackingAPI.batch(any(Batch.class))).thenReturn(call);
  transporter.flush().get();
  verify(callback).success(Callback.Event.UPLOAD, message);
}
 
开发者ID:f2prateek,项目名称:segment-android,代码行数:12,代码来源:TransporterTest.java

示例5: ignoresNullCallback

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Test public void ignoresNullCallback() throws ExecutionException, InterruptedException {
  transporter = new Transporter(queue, trackingAPI, null);

  Message message = new TrackMessage.Builder().userId("userId").event("event").build();

  transporter.enqueue(message).get();

  Call<Void> call = Calls.response(Response.success((Void) null));
  when(trackingAPI.batch(any(Batch.class))).thenReturn(call);
  transporter.flush().get();
}
 
开发者ID:f2prateek,项目名称:segment-android,代码行数:12,代码来源:TransporterTest.java

示例6: trimsBatches

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Test public void trimsBatches() throws Exception {
  for (int i = 0; i < 40; i++) {
    queue.add(new TrackMessage.Builder().userId("userId").event("event").build());
  }

  Call<Void> call = Calls.response(Response.success((Void) null));
  when(trackingAPI.batch(any(Batch.class))).thenReturn(call);

  transporter.flush().get();

  ArgumentCaptor<Batch> batchArgumentCaptor = ArgumentCaptor.forClass(Batch.class);
  verify(trackingAPI).batch(batchArgumentCaptor.capture());

  assertThat(batchArgumentCaptor.getValue().batch()).hasSize(33);
}
 
开发者ID:f2prateek,项目名称:segment-android,代码行数:16,代码来源:TransporterTest.java

示例7: createRawCall

import retrofit2.mock.Calls; //导入方法依赖的package包/类
/**
 * Helper method for creating raw ({@link ResponseBody}) {@link Call} objects.
 */
public static Call<ResponseBody> createRawCall(String contentType, String body) {
  MediaType mediaType = MediaType.parse(contentType);
  ResponseBody responseBody = ResponseBody.create(mediaType, body);
  return Calls.response(responseBody);
}
 
开发者ID:filestack,项目名称:filestack-java,代码行数:9,代码来源:Helpers.java

示例8: successResponse

import retrofit2.mock.Calls; //导入方法依赖的package包/类
private Call<ResponseBody> successResponse() {
    final ResponseBody body = ResponseBody.create(MediaType.parse("application/json"), "");
    return Calls.response(body);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:5,代码来源:ScribeFilesSenderTest.java

示例9: errorResponse

import retrofit2.mock.Calls; //导入方法依赖的package包/类
private Call<ResponseBody> errorResponse(int statusCode) {
    final ResponseBody body = ResponseBody.create(MediaType.parse("application/json"), "");
    return Calls.response(Response.<ResponseBody>error(statusCode, body));
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:5,代码来源:ScribeFilesSenderTest.java

示例10: getTempToken

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Override
public Call<ResponseBody> getTempToken(@Header(OAuthConstants.HEADER_AUTHORIZATION) String auth) {
    final ResponseBody responseBody = ResponseBody.create(MediaType.parse("application/json"), "");
    return Calls.response(Response.success(responseBody));
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:6,代码来源:OAuth1aServiceTest.java

示例11: getAccessToken

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Override
public Call<ResponseBody> getAccessToken(@Header(OAuthConstants.HEADER_AUTHORIZATION) String auth,
        @Query(OAuthConstants.PARAM_VERIFIER) String verifier) {
    final ResponseBody responseBody = ResponseBody.create(MediaType.parse("application/json"), "");
    return Calls.response(Response.success(responseBody));
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:7,代码来源:OAuth1aServiceTest.java

示例12: getGuestToken

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Override
public Call<GuestTokenResponse> getGuestToken(@Header(OAuthConstants.HEADER_AUTHORIZATION) String auth) {
    return Calls.response(Response.success(GUEST_RESPONSE));
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:5,代码来源:OAuth2ServiceTest.java

示例13: getAppAuthToken

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Override
public Call<OAuth2Token> getAppAuthToken(@Header(OAuthConstants.HEADER_AUTHORIZATION) String auth,
                                         @Field(OAuthConstants.PARAM_GRANT_TYPE) String grantType) {
    return Calls.response(Response.success(APP_TOKEN));
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:6,代码来源:OAuth2ServiceTest.java

示例14: notify

import retrofit2.mock.Calls; //导入方法依赖的package包/类
@Override public Call<NotifyResult> notify(Event event) {
  events.add(event);
  return Calls.response((NotifyResult) null);
}
 
开发者ID:square,项目名称:pagerduty-incidents,代码行数:5,代码来源:RecordingEventService.java


注:本文中的retrofit2.mock.Calls.response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。