Search in sources :

Example 1 with Build

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);
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build)

Example 2 with Build

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

Example 3 with Build

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

Example 4 with Build

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")));
}
Also used : BuildDetailsActivity(com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Bundle(android.os.Bundle) Intent(android.content.Intent) Properties(com.github.vase4kin.teamcityapp.properties.api.Properties) Test(org.junit.Test)

Example 5 with Build

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()));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Bundle(android.os.Bundle) HttpException(retrofit2.adapter.rxjava.HttpException) 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