use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class Mocks method createBuildMock.
/**
* MOCK
*
* @return parametrized build
*/
public static Build createBuildMock(String href, String number, String buildTypeId, String status, String state, String statusText, String waitReason, String branchName, String startDate, String startEstimate, String queuedDate, String finishDate) {
Build build = new Build(href, number, buildTypeId, status, state, statusText, waitReason, branchName, startDate, startEstimate, queuedDate, finishDate, "http://www.google.com");
build.setChanges(new Changes("/guestAuth/app/rest/changes?locator=build:(id:826073)"));
build.setArtifacts(new Artifacts("/guestAuth/app/rest/builds/id:92912/artifacts/children/"));
build.setAgent(new Agent("agent-love"));
build.setTriggered(new Triggered("user", "details", new User("code-lover", null)));
List<Properties.Property> propertyList = new ArrayList<>();
propertyList.add(new Properties.Property("sdk", "24"));
propertyList.add(new Properties.Property("userName", "Murdock"));
build.setProperties(new Properties(propertyList));
build.setTestOccurrences(new TestOccurrences(10, 2, 4, "/guestAuth/app/rest/testOccurrences?locator=build:(id:835695)"));
return build;
}
use of com.github.vase4kin.teamcityapp.buildlist.api.Build 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 com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.
the class RunBuildActivityTest method testUserCanStartTheBuildWithDefaultParams.
@Test
public void testUserCanStartTheBuildWithDefaultParams() throws Exception {
// Prepare intent
Intent intent = new Intent();
intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
// Starting the activity
mActivityRule.launchActivity(intent);
// Check personal
onView(withId(R.id.switcher_is_personal)).perform(click());
// Check queue to the top
onView(withId(R.id.switcher_queueAtTop)).perform(click());
// Check clean all files
onView(withId(R.id.switcher_clean_all_files)).perform(click());
// 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(true)));
assertThat(capturedBuild.isQueueAtTop(), is(equalTo(true)));
assertThat(capturedBuild.isCleanSources(), is(equalTo(false)));
// 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 testUserCanStartTheBuildWithClearAllCustomParams.
@Test
public void testUserCanStartTheBuildWithClearAllCustomParams() 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)));
// Clear all params
onView(withId(R.id.button_clear_parameters)).perform(click());
// 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(), is(nullValue()));
// 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 testUserCanSeeErrorSnackBarIfServerReturnsAnError.
@Test
public void testUserCanSeeErrorSnackBarIfServerReturnsAnError() throws Exception {
// Prepare mocks
when(mTeamCityService.queueBuild(any(Build.class))).thenReturn(Observable.<Build>error(new RuntimeException()));
// 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_base_error)).check(matches(isDisplayed()));
}
Aggregations