Search in sources :

Example 31 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class StageControllerIntegrationTest method shouldNotRunStageIfPreviousStageHasNotBeenRun.

@Test
public void shouldNotRunStageIfPreviousStageHasNotBeenRun() throws Exception {
    Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    String thirdStage = fixture.stageName(3);
    ModelAndView mav = controller.rerunStage(fixture.pipelineName, pipeline.getLabel(), thirdStage, response, request);
    Pipeline newPipeline = pipelineService.fullPipelineById(pipeline.getId());
    assertThat("Should not run " + thirdStage, newPipeline.getStages().hasStage(thirdStage), is(false));
    assertThat(((ResponseCodeView) mav.getView()).getStatusCode(), is(HttpServletResponse.SC_BAD_REQUEST));
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 32 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class StageControllerIntegrationTest method shouldReturn404WhenReRunningNonExistantStage.

@Test
public void shouldReturn404WhenReRunningNonExistantStage() throws Exception {
    Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    ModelAndView mav = controller.rerunStage(fixture.pipelineName, pipeline.getLabel(), "doesNotExist", response, request);
    ResponseCodeView codeView = (ResponseCodeView) mav.getView();
    assertThat(codeView.getStatusCode(), is(HttpServletResponse.SC_NOT_FOUND));
    assertThat(codeView.getContent(), is("Stage 'doesNotExist' not found in pipeline '" + fixture.pipelineName + "'"));
}
Also used : ResponseCodeView(com.thoughtworks.go.server.web.ResponseCodeView) ModelAndView(org.springframework.web.servlet.ModelAndView) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 33 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldTellPipelineMaterialModificationsToUpdateItselfOnSave.

@Test
public void shouldTellPipelineMaterialModificationsToUpdateItselfOnSave() throws Exception {
    Pipeline pipeline = PipelineMother.pipeline("cruise");
    when(pipelineDao.save(pipeline)).thenReturn(pipeline);
    when(pipelineTimeline.pipelineBefore(anyLong())).thenReturn(9L);
    when(pipelineTimeline.pipelineAfter(pipeline.getId())).thenReturn(-1L);
    when(materialRepository.findMaterialRevisionsForPipeline(9L)).thenReturn(MaterialRevisions.EMPTY);
    service.save(pipeline);
    Mockito.verify(pipelineTimeline).update();
}
Also used : Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 34 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PropertiesServiceTest method shouldReturnEmptyListIfLimitCountIsNotPositive.

@Test
public void shouldReturnEmptyListIfLimitCountIsNotPositive() {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), -1);
    assertThat(propertiesList.size(), is(0));
    propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 0);
    assertThat(propertiesList.size(), is(0));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 35 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PropertiesServiceTest method shouldLoadHistoryUptoSpecifiedPipeline.

@Test
public void shouldLoadHistoryUptoSpecifiedPipeline() {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 1);
    assertThat(propertiesList.size(), is(1));
    assertThat(propertiesList.get(0).getValue("cruise_pipeline_counter"), is(String.valueOf(pipeline2.getCounter())));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (com.thoughtworks.go.domain.Pipeline)177 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)55 Stage (com.thoughtworks.go.domain.Stage)40 JobInstance (com.thoughtworks.go.domain.JobInstance)26 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 Username (com.thoughtworks.go.server.domain.Username)17 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)16 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)14 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)12 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)11 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)10 ModelAndView (org.springframework.web.servlet.ModelAndView)10 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)9 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)9 Modification (com.thoughtworks.go.domain.materials.Modification)9 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)7 PipelineState (com.thoughtworks.go.domain.PipelineState)6 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)6