use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RunBuildInteractorImpl method queueBuild.
/**
* {@inheritDoc}
*/
@Override
public void queueBuild(String branchName, Properties properties, final LoadingListenerWithForbiddenSupport<String> loadingListener) {
Build build = new Build();
build.setBuildTypeId(mBuildTypeId);
build.setBranchName(branchName);
build.setProperties(properties);
queueBuild(build, loadingListener);
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class OverviewFragmentTest method testUserCanSeePersonalInfoIfBuildIsPersonal.
@Test
public void testUserCanSeePersonalInfoIfBuildIsPersonal() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
Triggered triggered = new Triggered(TRIGGER_TYPE_USER, null, new User(USER_NAME, null));
mBuild.setTriggered(triggered);
mBuild.setPersonal(true);
// Prepare intent
// <! ---------------------------------------------------------------------- !>
// Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
// <! ---------------------------------------------------------------------- !>
Intent intent = new Intent();
Bundle b = new Bundle();
Build successBuild = Mocks.successBuild();
successBuild.setPersonal(true);
b.putSerializable(BundleExtractorValues.BUILD, Mocks.successBuild());
b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Scrolling to last item to make it visible
onView(withId(R.id.overview_recycler_view)).perform(scrollToPosition(5));
// Checking Personal of
onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(5, R.id.itemHeader)).check(matches(withText(R.string.build_personal_text)));
onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(5, R.id.itemTitle)).check(matches(withText(USER_NAME)));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RestartBuildTest method testUserCanSeeForbiddenErrorWhenRestartingBuild.
@Test
public void testUserCanSeeForbiddenErrorWhenRestartingBuild() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
HttpException httpException = new HttpException(Response.<Build>error(CODE_FORBIDDEN, mResponseBody));
when(mTeamCityService.queueBuild(Matchers.any(Build.class))).thenReturn(Observable.<Build>error(httpException));
// Prepare intent
// <! ---------------------------------------------------------------------- !>
// Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
// <! ---------------------------------------------------------------------- !>
Intent intent = new Intent();
Bundle b = new Bundle();
b.putSerializable(BundleExtractorValues.BUILD, Mocks.failedBuild());
b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Opening context menu
openContextualActionModeOverflowMenu();
// Click on context menu option
onView(withText(R.string.text_menu_restart_build)).perform(click());
// Click on restart button
onView(withText(R.string.text_restart_button)).perform(click());
// Check snack bar is displayed
onView(withText(R.string.error_restart_build_forbidden_error)).check(matches(isDisplayed()));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RestartBuildTest method testUserCanRestartBuildWithTheSameParameters.
@Test
public void testUserCanRestartBuildWithTheSameParameters() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild)).thenReturn(Observable.just(mBuild2));
when(mTeamCityService.queueBuild(Matchers.any(Build.class))).thenReturn(Observable.just(Mocks.queuedBuild2()));
// Prepare intent
// <! ---------------------------------------------------------------------- !>
// Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
// <! ---------------------------------------------------------------------- !>
Intent intent = new Intent();
Bundle b = new Bundle();
Build buildToRestart = Mocks.failedBuild();
Properties.Property property = new Properties.Property(PROPERTY_NAME, PROPERTY_VALUE);
buildToRestart.setBranchName(BRANCH_NAME);
buildToRestart.setProperties(new Properties(Collections.singletonList(property)));
b.putSerializable(BundleExtractorValues.BUILD, buildToRestart);
b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Opening context menu
openContextualActionModeOverflowMenu();
// Click on context menu option
onView(withText(R.string.text_menu_restart_build)).perform(click());
// Check dialog text is displayed
onView(withText(R.string.text_restart_the_build)).check(matches(isDisplayed()));
// Click on restart button
onView(withText(R.string.text_restart_button)).perform(click());
// Check snack bar is displayed
onView(withText(R.string.text_build_is_restarted)).check(matches(isDisplayed()));
// Checking passed params
verify(mTeamCityService).queueBuild(mBuildArgumentCaptor.capture());
Build capturedBuild = mBuildArgumentCaptor.getValue();
assertThat(capturedBuild.getBranchName(), is(equalTo(BRANCH_NAME)));
assertThat(capturedBuild.getProperties().getObjects().size(), is(equalTo(1)));
Properties.Property capturedProperty = capturedBuild.getProperties().getObjects().get(0);
assertThat(capturedProperty.getName(), is(equalTo(PROPERTY_NAME)));
assertThat(capturedProperty.getValue(), is(equalTo(PROPERTY_VALUE)));
// 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(CoreMatchers.equalTo(BundleExtractorValues.BUILD), CoreMatchers.equalTo(mBuild2)))));
// Checking Result was changed
onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(0, R.id.itemTitle)).check(matches(withText("This build will not start because there are no compatible agents which can run it")));
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RestartBuildTest method testUserCanSeeServerErrorWhenRestartingBuild.
@Test
public void testUserCanSeeServerErrorWhenRestartingBuild() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
HttpException httpException = new HttpException(Response.<Build>error(500, mResponseBody));
when(mTeamCityService.queueBuild(Matchers.any(Build.class))).thenReturn(Observable.<Build>error(httpException));
// Prepare intent
// <! ---------------------------------------------------------------------- !>
// Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
// <! ---------------------------------------------------------------------- !>
Intent intent = new Intent();
Bundle b = new Bundle();
b.putSerializable(BundleExtractorValues.BUILD, Mocks.failedBuild());
b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Opening context menu
openContextualActionModeOverflowMenu();
// Click on context menu option
onView(withText(R.string.text_menu_restart_build)).perform(click());
// Click on restart button
onView(withText(R.string.text_restart_button)).perform(click());
// Check snack bar is displayed
onView(withText(R.string.error_base_restart_build_error)).check(matches(isDisplayed()));
}
Aggregations