use of retrofit2.HttpException in project TeamCityApp by vase4kin.
the class RestartBuildTest method testUserCanRestartBuildWithTheSameParametersButFailedToOpenItThen.
@Test
public void testUserCanRestartBuildWithTheSameParametersButFailedToOpenItThen() {
// Prepare mocks
HttpException httpException = new HttpException(Response.<Build>error(500, mResponseBody));
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild)).thenReturn(Observable.<Build>error(httpException)).thenReturn(Observable.<Build>error(httpException));
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());
// 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()));
// 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
onView(withText(R.string.error_opening_build)).check(matches(isDisplayed()));
}
use of retrofit2.HttpException in project TeamCityApp by vase4kin.
the class CancelBuildTest method testUserCanSeeForbiddenErrorWhenStoppingBuild.
@Test
public void testUserCanSeeForbiddenErrorWhenStoppingBuild() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(Mocks.runningBuild()));
HttpException httpException = new HttpException(Response.<Build>error(CODE_FORBIDDEN, mResponseBody));
when(mTeamCityService.cancelBuild(anyString(), Matchers.any(BuildCancelRequest.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.runningBuild());
b.putString(BundleExtractorValues.NAME, NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Opening context menu
openContextualActionModeOverflowMenu();
// Click on context menu option
onView(withText(R.string.text_menu_stop_build)).perform(click());
// Click on cancel build
onView(withText(R.string.text_stop_button)).perform(click());
// Check snack bar is displayed
onView(withText(R.string.error_stop_build_forbidden_error)).check(matches(isDisplayed()));
}
use of retrofit2.HttpException in project TeamCityApp by vase4kin.
the class CancelBuildTest method testUserCanSeeServerErrorWhenRemovingBuildFromQueue.
@Test
public void testUserCanSeeServerErrorWhenRemovingBuildFromQueue() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
HttpException httpException = new HttpException(Response.<Build>error(500, mResponseBody));
when(mTeamCityService.cancelBuild(anyString(), Matchers.any(BuildCancelRequest.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.queuedBuild1());
b.putString(BundleExtractorValues.NAME, NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Opening context menu
openContextualActionModeOverflowMenu();
// Click on context menu option
onView(withText(R.string.text_menu_remove_build_from_queue)).perform(click());
// Click on cancel build
onView(withText(R.string.text_remove_from_queue_button)).perform(click());
// Check snack bar is displayed
onView(withText(R.string.error_base_remove_build_from_queue_error)).check(matches(isDisplayed()));
}
use of retrofit2.HttpException in project TeamCityApp by vase4kin.
the class CancelBuildTest method testUserCanSeeForbiddenErrorWhenRemovingBuildFromQueue.
@Test
public void testUserCanSeeForbiddenErrorWhenRemovingBuildFromQueue() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
HttpException httpException = new HttpException(Response.<Build>error(CODE_FORBIDDEN, mResponseBody));
when(mTeamCityService.cancelBuild(anyString(), Matchers.any(BuildCancelRequest.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.queuedBuild1());
b.putString(BundleExtractorValues.NAME, NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Opening context menu
openContextualActionModeOverflowMenu();
// Click on context menu option
onView(withText(R.string.text_menu_remove_build_from_queue)).perform(click());
// Click on cancel build
onView(withText(R.string.text_remove_from_queue_button)).perform(click());
// Check snack bar is displayed
onView(withText(R.string.error_remove_build_from_queue_forbidden_error)).check(matches(isDisplayed()));
}
use of retrofit2.HttpException in project TeamCityApp by vase4kin.
the class CancelBuildTest method testUserCanSeeServerErrorWhenStoppingBuild.
@Test
public void testUserCanSeeServerErrorWhenStoppingBuild() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(Mocks.runningBuild()));
HttpException httpException = new HttpException(Response.<Build>error(500, mResponseBody));
when(mTeamCityService.cancelBuild(anyString(), Matchers.any(BuildCancelRequest.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.runningBuild());
b.putString(BundleExtractorValues.NAME, NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Opening context menu
openContextualActionModeOverflowMenu();
// Click on context menu option
onView(withText(R.string.text_menu_stop_build)).perform(click());
// Click on cancel build
onView(withText(R.string.text_stop_button)).perform(click());
// Check snack bar is displayed
onView(withText(R.string.error_base_stop_build_error)).check(matches(isDisplayed()));
}
Aggregations