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()));
}
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);
}
});
}
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();
}
Aggregations