Search in sources :

Example 16 with PipelineScheduleOptions

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());
}
Also used : MaterialForScheduling(com.thoughtworks.go.server.domain.MaterialForScheduling) PipelineScheduleOptions(com.thoughtworks.go.server.domain.PipelineScheduleOptions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialUpdateSuccessfulMessage(com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 17 with PipelineScheduleOptions

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));
}
Also used : MaterialForScheduling(com.thoughtworks.go.server.domain.MaterialForScheduling) PipelineScheduleOptions(com.thoughtworks.go.server.domain.PipelineScheduleOptions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 18 with PipelineScheduleOptions

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));
}
Also used : MaterialForScheduling(com.thoughtworks.go.server.domain.MaterialForScheduling) PipelineScheduleOptions(com.thoughtworks.go.server.domain.PipelineScheduleOptions) Test(org.junit.Test)

Aggregations

PipelineScheduleOptions (com.thoughtworks.go.server.domain.PipelineScheduleOptions)18 Test (org.junit.Test)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)6 GoCipher (com.thoughtworks.go.security.GoCipher)6 MaterialForScheduling (com.thoughtworks.go.server.domain.MaterialForScheduling)6 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 MaterialUpdateSuccessfulMessage (com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 JsonReader (com.thoughtworks.go.api.representers.JsonReader)2 EnvironmentVariable (com.thoughtworks.go.domain.EnvironmentVariable)2 Username (com.thoughtworks.go.server.domain.Username)2 ScheduleOptions (com.thoughtworks.go.server.scheduling.ScheduleOptions)2 Predicate (org.apache.commons.collections.Predicate)2 GsonTransformer (com.thoughtworks.go.api.util.GsonTransformer)1 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)1 ScheduleOptionsBuilder (com.thoughtworks.go.server.service.builders.ScheduleOptionsBuilder)1 HealthStateType (com.thoughtworks.go.serverhealth.HealthStateType)1 ArrayList (java.util.ArrayList)1