use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class BuildListActivityTest method testUserCanOpenRecentlyQueuedBuildFromSnackBarIfNoErrors.
@Test
public void testUserCanOpenRecentlyQueuedBuildFromSnackBarIfNoErrors() throws Exception {
when(mTeamCityService.listBuilds(anyString(), anyString())).thenReturn(Observable.just(new Builds(0, Collections.<Build>emptyList())));
// Preparing stubbing intent
Intent resultData = new Intent();
resultData.putExtra(RunBuildRouter.EXTRA_HREF, "href");
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);
mActivityRule.launchActivity(null);
// Open build type
onView(withText("build type")).perform(click());
// Set up result stubbing
intending(hasComponent(RunBuildActivity.class.getName())).respondWith(result);
// Pressing run build fab
onView(withId(R.id.floating_action_button)).perform(click());
// Mock build call
Build build = Mocks.runningBuild();
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(build));
// Click on show button of queued build snack bar
onView(withText(R.string.text_show_build)).perform(click());
// Check build is opened
intended(allOf(hasComponent(BuildDetailsActivity.class.getName()), hasExtras(hasEntry(equalTo(BundleExtractorValues.BUILD), equalTo(build)))));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class OverviewInteractorImpl method load.
/**
* {@inheritDoc}
*/
@Override
public void load(@NonNull String url, @NonNull final OnLoadingListener<BuildDetails> loadingListener, boolean update) {
mSubscriptions.clear();
Subscription subscription = mRepository.build(url, update).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Build>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
loadingListener.onFail(e.getMessage());
}
@Override
public void onNext(Build response) {
loadingListener.onSuccess(new BuildDetailsImpl(response));
}
});
mSubscriptions.add(subscription);
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class BuildDetailsInteractorImpl method cancelBuild.
/**
* {@inheritDoc}
*/
@Override
public void cancelBuild(final LoadingListenerWithForbiddenSupport<Build> loadingListener, boolean isReAddToTheQueue) {
mSubscription.clear();
Subscription queueBuildSubscription = mRepository.cancelBuild(mValueExtractor.getBuildDetails().getHref(), new BuildCancelRequest(isReAddToTheQueue)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Build>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
if (e instanceof HttpException) {
HttpException exception = (HttpException) e;
if (exception.code() == CODE_FORBIDDEN) {
loadingListener.onForbiddenError();
} else {
loadingListener.onFail(e.getMessage());
}
} else {
loadingListener.onFail(e.getMessage());
}
}
@Override
public void onNext(Build build) {
loadingListener.onSuccess(build);
}
});
mSubscription.add(queueBuildSubscription);
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class BuildInteractorImpl method loadBuild.
/**
* {@inheritDoc}
*/
@Override
public void loadBuild(@NonNull String href, @NonNull final OnLoadingListener<Build> loadingListener) {
mLoadBuildSubscription.clear();
Subscription loadBuildSubscriptions = mTeamCityService.build(href).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Build>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
loadingListener.onFail(e.getMessage());
}
@Override
public void onNext(Build build) {
loadingListener.onSuccess(build);
}
});
mLoadBuildSubscription.add(loadBuildSubscriptions);
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class FakeTeamCityServiceImpl method listBuilds.
@Override
public Observable<Builds> listBuilds(@Path("id") String id, @Query("locator") String locator) {
List<Build> builds = new ArrayList<>();
builds.add(Mocks.runningBuild());
builds.add(Mocks.successBuild());
builds.add(Mocks.failedBuild());
return Observable.just(new Builds(3, builds));
}
Aggregations