use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldScheduleAPipelineWithTheProvidedMaterialRevisions.
@Test
public void shouldScheduleAPipelineWithTheProvidedMaterialRevisions() throws IOException {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
String peggedRevision = "s2";
MaterialForScheduling material = new MaterialForScheduling(pipelineConfig.materialConfigs().first().getFingerprint(), peggedRevision);
pipelineScheduleOptions.getMaterials().add(material);
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline %s accepted", pipelineName)));
assertThat(result.httpCode(), is(202));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(true));
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 1));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
assertThat(buildCause.getApprover(), is(CaseInsensitiveString.str(admin.getUsername())));
assertThat(buildCause.getMaterialRevisions().findRevisionFor(pipelineConfig.materialConfigs().first()).getLatestRevisionString(), is("s2"));
assertThat(buildCause.getBuildCauseMessage(), is("Forced by admin1"));
assertTrue(buildCause.getVariables().isEmpty());
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldNotScheduleAPipelineIfTheProvidedMaterialRevisionIsNotKnownAndScheduleOptionSuggestsNoMDU.
@Test
public void shouldNotScheduleAPipelineIfTheProvidedMaterialRevisionIsNotKnownAndScheduleOptionSuggestsNoMDU() throws IOException {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineScheduleOptions.shouldPerformMDUBeforeScheduling(false);
String peggedRevision = "unseen-revision";
String fingerprint = pipelineConfig.materialConfigs().first().getFingerprint();
MaterialForScheduling material = new MaterialForScheduling(fingerprint, peggedRevision);
pipelineScheduleOptions.getMaterials().add(material);
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(false));
assertThat(result.fullMessage(), is(String.format("Error while scheduling pipeline: %s { Unable to find revision [%s] for material [%s] }", pipelineName, peggedRevision, new MaterialConfigConverter().toMaterial(pipelineConfig.materialConfigs().first()))));
assertThat(result.httpCode(), is(422));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldReturnErrorIfThePipelineBeingScheduledDoesNotContainTheMaterialsSetInRequest.
@Test
public void shouldReturnErrorIfThePipelineBeingScheduledDoesNotContainTheMaterialsSetInRequest() {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
MaterialForScheduling material = new MaterialForScheduling("non-existant-material", "r1");
pipelineScheduleOptions.getMaterials().add(material);
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(false));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline rejected { Pipeline '%s' does not contain the following material(s): [non-existant-material]. }", pipelineName)));
assertThat(result.httpCode(), is(422));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
}
Aggregations