use of com.github.vase4kin.teamcityapp.properties.api.Properties in project TeamCityApp by vase4kin.
the class RunBuildPresenterImpl method onBuildQueue.
/**
* {@inheritDoc}
*/
@Override
public void onBuildQueue(boolean isPersonal, boolean queueToTheTop, boolean cleanAllFiles) {
String branchName = mBranchesComponentView.getBranchName();
mView.showQueuingBuildProgress();
mInteractor.queueBuild(branchName, mSelectedAgent, isPersonal, queueToTheTop, cleanAllFiles, new Properties(mProperties), new LoadingListenerWithForbiddenSupport<String>() {
@Override
public void onSuccess(String data) {
mView.hideQueuingBuildProgress();
if (mProperties.isEmpty()) {
mTracker.trackUserRunBuildSuccess();
} else {
mTracker.trackUserRunBuildWithCustomParamsSuccess();
}
mRouter.closeOnSuccess(data);
}
@Override
public void onFail(String errorMessage) {
mView.hideQueuingBuildProgress();
mView.showErrorSnackbar();
mTracker.trackUserRunBuildFailed();
}
@Override
public void onForbiddenError() {
mView.hideQueuingBuildProgress();
mView.showForbiddenErrorSnackbar();
mTracker.trackUserRunBuildFailedForbidden();
}
});
}
use of com.github.vase4kin.teamcityapp.properties.api.Properties 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")));
}
use of com.github.vase4kin.teamcityapp.properties.api.Properties in project TeamCityApp by vase4kin.
the class BuildDetailsPresenterImpl method onConfirmRestartBuild.
/**
* {@inheritDoc}
*/
@Override
public void onConfirmRestartBuild() {
Properties properties = mInteractor.getBuildDetails().getProperties();
String branchName = mInteractor.getBuildDetails().getBranchName();
mView.showRestartingBuildProgressDialog();
mRunBuildInteractor.queueBuild(branchName, properties, new LoadingListenerWithForbiddenSupport<String>() {
@Override
public void onForbiddenError() {
mTracker.trackUserGetsForbiddenErrorOnBuildRestart();
mView.hideRestartingBuildProgressDialog();
mView.showForbiddenToRestartBuildSnackBar();
}
@Override
public void onSuccess(String queuedBuildHref) {
mQueuedBuildHref = queuedBuildHref;
mTracker.trackUserRestartedBuildSuccessfully();
mView.hideRestartingBuildProgressDialog();
mView.showBuildRestartSuccessSnackBar();
}
@Override
public void onFail(String errorMessage) {
mTracker.trackUserGetsServerErrorOnBuildRestart();
mView.hideRestartingBuildProgressDialog();
mView.showBuildRestartErrorSnackBar();
}
});
}
use of com.github.vase4kin.teamcityapp.properties.api.Properties 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.properties.api.Properties in project TeamCityApp by vase4kin.
the class PropertiesFragmentTest method testUserCanSeeEmptyPropertiesMessageIfPropertiesAreEmpty.
@Test
public void testUserCanSeeEmptyPropertiesMessageIfPropertiesAreEmpty() {
// Prepare mocks
when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
// 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.successBuild(new Properties(Collections.<Properties.Property>emptyList())));
b.putString(BundleExtractorValues.NAME, NAME);
intent.putExtras(b);
// Start activity
mActivityRule.launchActivity(intent);
// Checking properties tab title
onView(withText("Parameters")).perform(scrollTo()).check(matches(isDisplayed())).perform(click());
// Checking empty message
onView(withText(R.string.empty_list_message_parameters)).check(matches(isDisplayed()));
}
Aggregations