use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RunBuildActivityTest method testUserCanStartTheBuild.
@Test
public void testUserCanStartTheBuild() throws Exception {
// Prepare intent
Intent intent = new Intent();
intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
// Starting the activity
mActivityRule.launchActivity(intent);
// Starting the build
onView(withId(R.id.fab_queue_build)).perform(click());
// Checking triggered build
verify(mTeamCityService).queueBuild(mBuildCaptor.capture());
Build capturedBuild = mBuildCaptor.getValue();
assertThat(capturedBuild.getBranchName(), is("master"));
assertThat(capturedBuild.getAgent(), is(nullValue()));
assertThat(capturedBuild.isPersonal(), is(equalTo(false)));
assertThat(capturedBuild.isQueueAtTop(), is(equalTo(false)));
assertThat(capturedBuild.isCleanSources(), is(equalTo(true)));
// Checking activity is finishing
assertThat(mActivityRule.getActivity().isFinishing(), is(true));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RunBuildActivityTest method testUserCanSeeErrorForbiddenSnackBarIfServerReturnsAnError.
@Test
public void testUserCanSeeErrorForbiddenSnackBarIfServerReturnsAnError() throws Exception {
// Prepare mocks
HttpException httpException = new HttpException(Response.<Build>error(CODE_FORBIDDEN, mResponseBody));
when(mTeamCityService.queueBuild(any(Build.class))).thenReturn(Observable.<Build>error(httpException));
// Prepare intent
Intent intent = new Intent();
intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
// Starting the activity
mActivityRule.launchActivity(intent);
// Starting the build
onView(withId(R.id.fab_queue_build)).perform(click());
// Checking the error snackbar text
onView(withText(R.string.error_forbidden_error)).check(matches(isDisplayed()));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RunBuildActivityTest method testUserCanSeeChooseAgentIfAgentsAvailable.
@Test
public void testUserCanSeeChooseAgentIfAgentsAvailable() throws Exception {
// Prepare mocks
List<Agent> agents = new ArrayList<>();
Agent agent = new Agent("agent 1");
agents.add(agent);
when(mTeamCityService.listAgents(false, null, null)).thenReturn(Observable.just(new Agents(1, agents)));
// Prepare intent
Intent intent = new Intent();
intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
// Starting the activity
mActivityRule.launchActivity(intent);
// Choose agent
onView(withId(R.id.chooser_agent)).perform(click());
onView(withText("agent 1")).perform(click());
// Starting the build
onView(withId(R.id.fab_queue_build)).perform(click());
// Checking that build was triggered with agent
verify(mTeamCityService).queueBuild(mBuildCaptor.capture());
Build capturedBuild = mBuildCaptor.getValue();
assertThat(capturedBuild.getAgent(), is(agent));
// Checking activity is finishing
assertThat(mActivityRule.getActivity().isFinishing(), is(true));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RunBuildActivityTest method testUserCanStartTheBuildWithCustomParams.
@Test
public void testUserCanStartTheBuildWithCustomParams() throws Exception {
// Prepare intent
Intent intent = new Intent();
intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
// Starting the activity
mActivityRule.launchActivity(intent);
// Scroll to
onView(withId(android.R.id.content)).perform(swipeUp());
// Add new param
onView(withId(R.id.button_add_parameter)).perform(click());
// Fill params
onView(withId(R.id.parameter_name)).perform(typeText(PARAMETER_NAME));
onView(withId(R.id.parameter_value)).perform(typeText(PARAMETER_VALUE), closeSoftKeyboard());
// Add param
onView(withText(R.string.text_add_parameter_button)).perform(click());
// Scroll to
onView(withId(android.R.id.content)).perform(swipeUp());
// Check params on view
onView(allOf(withId(R.id.parameter_name), isDisplayed())).check(matches(withText(PARAMETER_NAME)));
onView(allOf(withId(R.id.parameter_value), isDisplayed())).check(matches(withText(PARAMETER_VALUE)));
// Starting the build
onView(withId(R.id.fab_queue_build)).perform(click());
// Checking triggered build
verify(mTeamCityService).queueBuild(mBuildCaptor.capture());
Build capturedBuild = mBuildCaptor.getValue();
assertThat(capturedBuild.getProperties().getObjects().size(), is(equalTo(1)));
Properties.Property capturedProperty = capturedBuild.getProperties().getObjects().get(0);
assertThat(capturedProperty.getName(), is(equalTo(PARAMETER_NAME)));
assertThat(capturedProperty.getValue(), is(equalTo(PARAMETER_VALUE)));
// Checking activity is finishing
assertThat(mActivityRule.getActivity().isFinishing(), is(true));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build 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")));
}
Aggregations