Java Code Examples for retrofit2.mock.Calls#response()

The following examples show how to use retrofit2.mock.Calls#response() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TwitterAuthClientTest.java    From twitter-kit-android with Apache License 2.0 6 votes vote down vote up
@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");
        }
    });
}
 
Example 2
Source File: OAuth1aServiceTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@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));
}
 
Example 3
Source File: OAuth1aServiceTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@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));
}
 
Example 4
Source File: OAuth2ServiceTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@Override
public Call<GuestTokenResponse> getGuestToken(@Header(OAuthConstants.HEADER_AUTHORIZATION) String auth) {
    return Calls.response(Response.success(GUEST_RESPONSE));
}
 
Example 5
Source File: OAuth2ServiceTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@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));
}
 
Example 6
Source File: RecordingEventService.java    From pagerduty-incidents with Apache License 2.0 4 votes vote down vote up
@Override public Call<NotifyResult> notify(Event event) {
  events.add(event);
  return Calls.response((NotifyResult) null);
}