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")));
}
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"));
}
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)))));
}
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);
}
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));
}
Aggregations