Search in sources :

Example 11 with Build

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)))));
}
Also used : RunBuildActivity(com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity) Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) BuildDetailsActivity(com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Instrumentation(android.app.Instrumentation) Intent(android.content.Intent) Test(org.junit.Test)

Example 12 with 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);
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Subscription(rx.Subscription)

Example 13 with Build

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);
}
Also used : BuildCancelRequest(com.github.vase4kin.teamcityapp.build_details.api.BuildCancelRequest) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) HttpException(retrofit2.adapter.rxjava.HttpException) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 14 with Build

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);
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 15 with Build

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));
}
Also used : Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) ArrayList(java.util.ArrayList)

Aggregations

Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)27 Intent (android.content.Intent)14 Test (org.junit.Test)14 Builds (com.github.vase4kin.teamcityapp.buildlist.api.Builds)6 HttpException (retrofit2.adapter.rxjava.HttpException)6 Bundle (android.os.Bundle)5 ArrayList (java.util.ArrayList)5 Subscription (rx.Subscription)5 Properties (com.github.vase4kin.teamcityapp.properties.api.Properties)4 CompositeSubscription (rx.subscriptions.CompositeSubscription)3 Instrumentation (android.app.Instrumentation)2 Agent (com.github.vase4kin.teamcityapp.agents.api.Agent)2 BuildDetailsActivity (com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity)2 Triggered (com.github.vase4kin.teamcityapp.buildlist.api.Triggered)2 User (com.github.vase4kin.teamcityapp.buildlist.api.User)2 RunBuildActivity (com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity)2 Agents (com.github.vase4kin.teamcityapp.agents.api.Agents)1 Artifacts (com.github.vase4kin.teamcityapp.artifact.api.Artifacts)1 BuildCancelRequest (com.github.vase4kin.teamcityapp.build_details.api.BuildCancelRequest)1 Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)1