use of retrofit.client.Response in project Varis-Android by dkhmelenko.
the class TestBuildDetailsPresenter method testStartLoadingDataSingleJob.
@Test
public void testStartLoadingDataSingleJob() {
final long buildId = 1L;
final String slug = "test";
final Build build = new Build();
final Commit commit = new Commit();
final List<Job> jobs = new ArrayList<>();
final Job job = new Job();
jobs.add(job);
BuildDetails buildDetails = new BuildDetails();
buildDetails.setBuild(build);
buildDetails.setCommit(commit);
buildDetails.setJobs(jobs);
final String expectedUrl = "https://sample.org";
Response response = new Response(expectedUrl, 200, "", Collections.<Header>emptyList(), null);
final String accessToken = "test";
final String authToken = "token " + accessToken;
AppSettings.putAccessToken("test");
when(mRawClient.getApiService().getLog(authToken, String.valueOf(job.getId()))).thenReturn(response);
when(mTravisRestClient.getApiService().getBuild(slug, buildId)).thenReturn(buildDetails);
mBuildsDetailsPresenter.startLoadingData(null, slug, buildId);
verify(mTaskManager).getBuildDetails(slug, buildId);
verify(mBuildDetailsView).showProgress();
verify(mBuildDetailsView).hideProgress();
verify(mBuildDetailsView).updateBuildDetails(buildDetails);
verify(mBuildDetailsView).showBuildLogs();
verify(mBuildDetailsView).showAdditionalActionsForBuild(buildDetails);
}
use of retrofit.client.Response in project Varis-Android by dkhmelenko.
the class TestBuildDetailsPresenter method testStartLoadingLogWithToken.
@Test
public void testStartLoadingLogWithToken() {
final long jobId = 1L;
final String expectedUrl = "https://sample.org";
Response response = new Response(expectedUrl, 200, "", Collections.<Header>emptyList(), null);
final String accessToken = "test";
final String authToken = "token " + accessToken;
when(mRawClient.getApiService().getLog(authToken, String.valueOf(jobId))).thenReturn(response);
AppSettings.putAccessToken(accessToken);
mBuildsDetailsPresenter.startLoadingLog(jobId);
verify(mTaskManager).getLogUrl(authToken, jobId);
verify(mBuildDetailsView).setLogUrl(expectedUrl);
}
use of retrofit.client.Response in project glasquare by davidvavra.
the class CheckInActivity method checkIn.
private void checkIn() {
final String venueId = getIntent().getStringExtra(EXTRA_VENUE_ID);
final Location location = LocationUtils.getLastLocation();
final String ll = LocationUtils.getLatLon(location);
int accuracy = (int) location.getAccuracy();
int altitude = (int) location.getAltitude();
showProgress(R.string.checking_in);
showCheckInInfo();
String broadcast = getBroadcast();
Api.get().create(CheckIns.class).add(venueId, ll, mShout, broadcast, accuracy, altitude, new Callback<CheckIns.CheckInResponse>() {
@Override
public void success(final CheckIns.CheckInResponse checkInResponse, Response response) {
mCheckInResponse = checkInResponse;
if (mAddingPhoto) {
ImageUtils.processPictureWhenReady(CheckInActivity.this, mPhoto, new ImageUtils.OnPictureReadyListener() {
@Override
public void onPictureReady() {
new BaseAsyncTask() {
@Override
public void inBackground() {
ImageUtils.resize(mPhoto);
}
@Override
public void postExecute() {
addPhoto();
}
}.start();
}
});
} else {
showCheckInComplete();
}
}
@Override
public void failure(RetrofitError retrofitError) {
if (!Auth.handle(CheckInActivity.this, retrofitError)) {
showError(R.string.error_please_try_again);
}
}
});
}
use of retrofit.client.Response in project glasquare by davidvavra.
the class CheckInSearchActivity method loadData.
@Override
protected void loadData() {
showProgress(R.string.loading);
LocationUtils.getRecentLocation(new LocationUtils.LocationListener() {
@Override
public void onLocationAcquired(Location location) {
String ll = LocationUtils.getLatLon(location);
Api.get().create(SearchVenues.class).searchForCheckIn(ll, new Callback<SearchVenues.SearchResponse>() {
@Override
public void success(SearchVenues.SearchResponse venuesResponse, Response response) {
showContent(new CheckInSearchAdapter(venuesResponse.getVenues()), new CardSelectedListener() {
@Override
public void onCardSelected(Object item) {
SearchVenues.Venue venue = (SearchVenues.Venue) item;
CheckInActivity.call(CheckInSearchActivity.this, venue.id, venue.name);
}
});
}
@Override
public void failure(RetrofitError retrofitError) {
showError(R.string.error_please_try_again);
}
});
}
@Override
public void onLocationFailed() {
showError(R.string.no_location);
}
});
}
use of retrofit.client.Response in project retrofit-examples by kdubb1337.
the class AsynchronousClient method main.
public static void main(String[] args) {
// Build the Retrofit REST adaptor pointing to the URL specified
// with a ThrottlingInterceptor allowing only 1 request per second
RestAdapter restAdapter = new RestAdapter.Builder().setRequestInterceptor(new ThrottlingInterceptor(1000L)).setServer(API_URL).build();
// Create an instance of our InterestingApi interface.
InterestingApi synchronousApi = restAdapter.create(InterestingApi.class);
// Create an instance of our AsynchronousApi interface.
AsynchronousApi asyncApi = restAdapter.create(AsynchronousApi.class);
for (int i = 0; i < 10; i++) LOG.info("synchronousApi " + synchronousApi.getWithPath(Integer.toString(i)));
for (int i = 0; i < 10; i++) asyncApi.getWithPath(Integer.toString(i), new Callback<String>() {
@Override
public void success(String t, Response response) {
LOG.info("asynchronousApi (" + t + ")");
}
@Override
public void failure(RetrofitError error) {
LOG.info("Epic fail!");
}
});
}
Aggregations