Search in sources :

Example 1 with Builds

use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.

the class BuildListActivityTest method testUserCanSeeBuildListIsRefreshedIfBuildIsAddedToQueue.

@Test
public void testUserCanSeeBuildListIsRefreshedIfBuildIsAddedToQueue() throws Exception {
    when(mTeamCityService.listBuilds(anyString(), anyString())).thenReturn(Observable.just(new Builds(0, Collections.<Build>emptyList()))).thenCallRealMethod();
    // 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());
    // Check the list is empty
    onView(withId(android.R.id.empty)).check(matches(isDisplayed())).check(matches(withText(R.string.empty_list_message_builds)));
    // Set up result stubbing
    intending(hasComponent(RunBuildActivity.class.getName())).respondWith(result);
    // Pressing run build fab
    onView(withId(R.id.floating_action_button)).perform(click());
    // Check new items appeared
    onView(withRecyclerView(R.id.build_recycler_view).atPositionOnView(1, R.id.itemTitle)).check(matches(withText("Running tests")));
}
Also used : RunBuildActivity(com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity) Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Instrumentation(android.app.Instrumentation) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with Builds

use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.

the class BuildListActivityTest method testUserCanSeeSnackBarIfBuildFiltersHaveBeenApplied.

@Test
public void testUserCanSeeSnackBarIfBuildFiltersHaveBeenApplied() throws Exception {
    when(mTeamCityService.listBuilds(anyString(), anyString())).thenReturn(Observable.just(new Builds(0, Collections.<Build>emptyList())));
    // Preparing stubbing intent
    Intent resultData = new Intent();
    BuildListFilter filter = new BuildListFilterImpl();
    filter.setFilter(FilterBuildsView.FILTER_CANCELLED);
    filter.setBranch("branch");
    filter.setPersonal(true);
    filter.setPinned(true);
    resultData.putExtra(FilterBuildsRouter.EXTRA_FILTER, filter);
    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(FilterBuildsActivity.class.getName())).respondWith(result);
    // Pressing filter builds toolbar item
    onView(withId(R.id.filter_builds)).perform(click());
    // Check snack bar text
    onView(withText(R.string.text_filters_applied)).check(matches(isDisplayed()));
    // Check data was loaded with new filter
    verify(mTeamCityService).listBuilds(eq("build_type_id"), eq("canceled:true,branch:name:branch,personal:true,pinned:true,count:10"));
}
Also used : Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) BuildListFilterImpl(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilterImpl) Instrumentation(android.app.Instrumentation) FilterBuildsActivity(com.github.vase4kin.teamcityapp.filter_builds.view.FilterBuildsActivity) Intent(android.content.Intent) BuildListFilter(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter) Test(org.junit.Test)

Example 3 with Builds

use of com.github.vase4kin.teamcityapp.buildlist.api.Builds 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 4 with Builds

use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.

the class BuildListDataManagerImpl method loadCount.

/**
 * Load build count
 *
 * @param call            - Retrofit call
 * @param loadingListener - Listener to receive server callbacks
 */
public void loadCount(Observable<Builds> call, final OnLoadingListener<Integer> loadingListener) {
    mSubscriptions.clear();
    Subscription subscription = call.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Builds>() {

        @Override
        public void onCompleted() {
        }

        @Override
        public void onError(Throwable e) {
            loadingListener.onSuccess(0);
        }

        @Override
        public void onNext(Builds response) {
            loadingListener.onSuccess(response.getCount());
        }
    });
    mSubscriptions.add(subscription);
}
Also used : Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) Subscription(rx.Subscription)

Example 5 with Builds

use of com.github.vase4kin.teamcityapp.buildlist.api.Builds 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

Builds (com.github.vase4kin.teamcityapp.buildlist.api.Builds)11 Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)6 Instrumentation (android.app.Instrumentation)5 Intent (android.content.Intent)5 Test (org.junit.Test)5 RunBuildActivity (com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity)4 ArrayList (java.util.ArrayList)3 Subscription (rx.Subscription)2 TeamCityApplication (com.github.vase4kin.teamcityapp.TeamCityApplication)1 BuildDetailsActivity (com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity)1 BuildListFilter (com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter)1 BuildListFilterImpl (com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilterImpl)1 FilterBuildsActivity (com.github.vase4kin.teamcityapp.filter_builds.view.FilterBuildsActivity)1 BuildDetails (com.github.vase4kin.teamcityapp.overview.data.BuildDetails)1 BuildDetailsImpl (com.github.vase4kin.teamcityapp.overview.data.BuildDetailsImpl)1 List (java.util.List)1 Before (org.junit.Before)1 Observable (rx.Observable)1 Func1 (rx.functions.Func1)1 Func2 (rx.functions.Func2)1