Search in sources :

Example 6 with Properties

use of com.github.vase4kin.teamcityapp.properties.api.Properties 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 7 with Properties

use of com.github.vase4kin.teamcityapp.properties.api.Properties in project TeamCityApp by vase4kin.

the class PropertiesDataManagerImpl method load.

/**
 * {@inheritDoc}
 */
@Override
public void load(@NonNull final BuildDetails buildDetails, final OnLoadingListener<List<Properties.Property>> loadingListener) {
    // Getting properties from the build
    Properties properties = buildDetails.getProperties();
    Observable.just(properties).flatMap(new Func1<Properties, Observable<Properties>>() {

        @Override
        public Observable<Properties> call(Properties properties) {
            return properties == null ? Observable.<Properties>empty() : Observable.just(properties);
        }
    }).defaultIfEmpty(new Properties(Collections.<Properties.Property>emptyList())).flatMap(new Func1<Properties, Observable<List<Properties.Property>>>() {

        @Override
        public Observable<List<Properties.Property>> call(Properties properties) {
            return Observable.from(properties.getObjects()).toList();
        }
    }).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Properties.Property>>() {

        @Override
        public void call(List<Properties.Property> objects) {
            loadingListener.onSuccess(objects);
        }
    });
}
Also used : List(java.util.List) Properties(com.github.vase4kin.teamcityapp.properties.api.Properties) Observable(rx.Observable)

Example 8 with Properties

use of com.github.vase4kin.teamcityapp.properties.api.Properties in project TeamCityApp by vase4kin.

the class RunBuildPresenterImplTest method testOnBuildQueue.

@Test
public void testOnBuildQueue() throws Exception {
    mPresenter.mSelectedAgent = mAgent;
    mPresenter.mProperties.add(new Properties.Property(PROPERTY_NAME, PROPERTY_VALUE));
    when(mBranchesComponentView.getBranchName()).thenReturn("branch");
    mPresenter.onBuildQueue(true, true, true);
    verify(mBranchesComponentView).getBranchName();
    verify(mView).showQueuingBuildProgress();
    verify(mInteractor).queueBuild(eq("branch"), eq(mAgent), eq(true), eq(true), eq(true), mPropertiesArgumentCaptor.capture(), mQueueLoadingListenerCaptor.capture());
    Properties capturedProperties = mPropertiesArgumentCaptor.getValue();
    assertThat(capturedProperties.getObjects().size(), is(equalTo(1)));
    Properties.Property capturedProperty = capturedProperties.getObjects().get(0);
    assertThat(capturedProperty.getName(), is(equalTo(PROPERTY_NAME)));
    assertThat(capturedProperty.getValue(), is(equalTo(PROPERTY_VALUE)));
    LoadingListenerWithForbiddenSupport<String> loadingListener = mQueueLoadingListenerCaptor.getValue();
    loadingListener.onSuccess("href");
    verify(mView).hideQueuingBuildProgress();
    verify(mRouter).closeOnSuccess(eq("href"));
    verify(mTracker).trackUserRunBuildWithCustomParamsSuccess();
    mPresenter.mProperties.clear();
    loadingListener.onSuccess("href");
    verify(mView, times(2)).hideQueuingBuildProgress();
    verify(mRouter, times(2)).closeOnSuccess(eq("href"));
    verify(mTracker).trackUserRunBuildSuccess();
    loadingListener.onFail("");
    verify(mView, times(3)).hideQueuingBuildProgress();
    verify(mView).showErrorSnackbar();
    verify(mTracker).trackUserRunBuildFailed();
    loadingListener.onForbiddenError();
    verify(mView, times(4)).hideQueuingBuildProgress();
    verify(mView).showForbiddenErrorSnackbar();
    verify(mTracker).trackUserRunBuildFailedForbidden();
}
Also used : Properties(com.github.vase4kin.teamcityapp.properties.api.Properties) Test(org.junit.Test)

Aggregations

Properties (com.github.vase4kin.teamcityapp.properties.api.Properties)8 Test (org.junit.Test)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)3 Agent (com.github.vase4kin.teamcityapp.agents.api.Agent)1 Artifacts (com.github.vase4kin.teamcityapp.artifact.api.Artifacts)1 BuildDetailsActivity (com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity)1 Triggered (com.github.vase4kin.teamcityapp.buildlist.api.Triggered)1 User (com.github.vase4kin.teamcityapp.buildlist.api.User)1 Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)1 TestOccurrences (com.github.vase4kin.teamcityapp.tests.api.TestOccurrences)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 HttpException (retrofit2.adapter.rxjava.HttpException)1 Observable (rx.Observable)1