Search in sources :

Example 16 with Build

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;
}
Also used : Changes(com.github.vase4kin.teamcityapp.changes.api.Changes) Artifacts(com.github.vase4kin.teamcityapp.artifact.api.Artifacts) Agent(com.github.vase4kin.teamcityapp.agents.api.Agent) Triggered(com.github.vase4kin.teamcityapp.buildlist.api.Triggered) User(com.github.vase4kin.teamcityapp.buildlist.api.User) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) TestOccurrences(com.github.vase4kin.teamcityapp.tests.api.TestOccurrences) ArrayList(java.util.ArrayList) Properties(com.github.vase4kin.teamcityapp.properties.api.Properties)

Example 17 with 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()));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Bundle(android.os.Bundle) HttpException(retrofit2.adapter.rxjava.HttpException) Intent(android.content.Intent) Properties(com.github.vase4kin.teamcityapp.properties.api.Properties) Test(org.junit.Test)

Example 18 with Build

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));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Intent(android.content.Intent) Test(org.junit.Test)

Example 19 with Build

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));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Intent(android.content.Intent) Test(org.junit.Test)

Example 20 with Build

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()));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)27 Intent (android.content.Intent)14 Test (org.junit.Test)14 Builds (com.github.vase4kin.teamcityapp.buildlist.api.Builds)6 HttpException (retrofit2.adapter.rxjava.HttpException)6 Bundle (android.os.Bundle)5 ArrayList (java.util.ArrayList)5 Subscription (rx.Subscription)5 Properties (com.github.vase4kin.teamcityapp.properties.api.Properties)4 CompositeSubscription (rx.subscriptions.CompositeSubscription)3 Instrumentation (android.app.Instrumentation)2 Agent (com.github.vase4kin.teamcityapp.agents.api.Agent)2 BuildDetailsActivity (com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity)2 Triggered (com.github.vase4kin.teamcityapp.buildlist.api.Triggered)2 User (com.github.vase4kin.teamcityapp.buildlist.api.User)2 RunBuildActivity (com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity)2 Agents (com.github.vase4kin.teamcityapp.agents.api.Agents)1 Artifacts (com.github.vase4kin.teamcityapp.artifact.api.Artifacts)1 BuildCancelRequest (com.github.vase4kin.teamcityapp.build_details.api.BuildCancelRequest)1 Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)1