use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.
the class FilterBuildsActivityTest method setUp.
@Before
public void setUp() {
TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
app.getRestApiInjector().sharedUserStorage().clearAll();
app.getRestApiInjector().sharedUserStorage().saveGuestUserAccountAndSetItAsActive(Mocks.URL);
when(mTeamCityService.listBuilds(anyString(), anyString())).thenReturn(Observable.just(new Builds(0, Collections.<Build>emptyList())));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.
the class FakeTeamCityServiceImpl method listQueueBuilds.
@Override
public Observable<Builds> listQueueBuilds(@Query("fields") String fields) {
List<Build> builds = new ArrayList<>();
builds.add(Mocks.queuedBuild1());
builds.add(Mocks.queuedBuild2());
builds.add(Mocks.queuedBuild3());
return Observable.just(new Builds(3, builds));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.
the class FakeTeamCityServiceImpl method listRunningBuilds.
@Override
public Observable<Builds> listRunningBuilds(@Query("locator") String locator, @Query("fields") String fields) {
List<Build> builds = new ArrayList<>();
builds.add(Mocks.runningBuild());
return Observable.just(new Builds(1, builds));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.
the class BuildListActivityTest method testUserCanSeeSnackBarIfBuildIsAddedToQueue.
@Test
public void testUserCanSeeSnackBarIfBuildIsAddedToQueue() 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());
// Check snack bar text
onView(withText(R.string.text_build_is_run)).check(matches(isDisplayed()));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Builds in project TeamCityApp by vase4kin.
the class BuildListActivityTest method testUserCanSeeErrorSnackbarWhenOpenRecentlyQueuedBuildIfThereAreErrors.
@Test
public void testUserCanSeeErrorSnackbarWhenOpenRecentlyQueuedBuildIfThereAreErrors() 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
when(mTeamCityService.build(anyString())).thenReturn(Observable.<Build>error(new RuntimeException()));
// Click on show button of queued build snack bar
onView(withText(R.string.text_show_build)).perform(click());
// Check error snack bar
onView(withText(R.string.error_opening_build)).check(matches(isDisplayed()));
// Click on retry button
onView(withText(R.string.download_artifact_retry_snack_bar_retry_button)).perform(click());
// Check error snack bar again
onView(withText(R.string.error_opening_build)).check(matches(isDisplayed()));
}
Aggregations