Search in sources :

Example 36 with StageIdentifier

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

the class FailedBuildHistoryCacheSweeperTest method shouldClearFbhForPipelinesAfterUpdatedPipeline.

@Test
public void shouldClearFbhForPipelinesAfterUpdatedPipeline() {
    PipelineIdentifier pipelineIdentifier = entryAfterNew.getPipelineLocator();
    Stage stage = StageMother.cancelledStage("dev", "rspec");
    stage.setIdentifier(new StageIdentifier(pipelineIdentifier, "dev", "2"));
    String pipelineKey = key.forFbhOfStagesUnderPipeline(pipelineIdentifier);
    String stageKey = key.forFailedBuildHistoryStage(stage, "html");
    goCache.put(pipelineKey, stageKey, "fragment");
    sweeper.added(newlyAddedEntry, timeline);
    assertThat(goCache.get(pipelineKey), is(nullValue()));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 37 with StageIdentifier

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

the class PipelineHistoryMother method pipelineHistoryItemWithOneStage.

public static PipelineInstanceModel pipelineHistoryItemWithOneStage(String pipelineName, String stageName, Date modifiedDate) {
    StageInstanceModels stageHistory = new StageInstanceModels();
    stageHistory.add(new StageInstanceModel(stageName, "1", StageResult.Passed, new StageIdentifier(pipelineName, 1, "1", stageName, "1")));
    return singlePipeline(pipelineName, stageHistory, modifiedDate);
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 38 with StageIdentifier

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

the class RestfulServiceTest method shouldTranslateLatestStageCounter.

@Test
public void shouldTranslateLatestStageCounter() {
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    StageIdentifier stageIdentifier = restfulService.translateStageCounter(pipeline.getIdentifier(), fixture.devStage, "latest");
    assertThat(stageIdentifier, is(new StageIdentifier(pipeline, pipeline.getStages().byName(fixture.devStage))));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 39 with StageIdentifier

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

the class StageSqlMapDaoTest method shouldLoadTheStageHistoryEntryNextInTimeFromAGivenStageHistoryEntry.

@Test
public void shouldLoadTheStageHistoryEntryNextInTimeFromAGivenStageHistoryEntry() throws Exception {
    StageIdentifier stageIdentifier = mock(StageIdentifier.class);
    String pipelineName = "some_pipeline_name";
    String stageName = "stage_name";
    long pipelineId = 41l;
    when(stageIdentifier.getPipelineName()).thenReturn(pipelineName);
    when(stageIdentifier.getStageName()).thenReturn(stageName);
    StageHistoryEntry topOfThisPage = mock(StageHistoryEntry.class);
    StageHistoryEntry bottomOfPreviousPage = mock(StageHistoryEntry.class);
    when(topOfThisPage.getId()).thenReturn(pipelineId);
    when(topOfThisPage.getIdentifier()).thenReturn(stageIdentifier);
    HashMap args = new HashMap();
    args.put("pipelineName", pipelineName);
    args.put("stageName", stageName);
    args.put("id", pipelineId);
    args.put("limit", 1);
    when(sqlMapClientTemplate.queryForObject("findStageHistoryEntryBefore", args)).thenReturn(bottomOfPreviousPage);
    StageHistoryEntry actual = stageSqlMapDao.findImmediateChronologicallyForwardStageHistoryEntry(topOfThisPage);
    assertThat(actual, is(bottomOfPreviousPage));
    verify(stageIdentifier).getPipelineName();
    verify(stageIdentifier).getStageName();
    verify(topOfThisPage).getId();
    verify(topOfThisPage).getIdentifier();
    verify(sqlMapClientTemplate).queryForObject("findStageHistoryEntryBefore", args);
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) HashMap(java.util.HashMap) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.Test)

Example 40 with StageIdentifier

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

the class PipelineInstanceModelTest method shouldReturnTrueIfThePipelineHasStage.

@Test
public void shouldReturnTrueIfThePipelineHasStage() {
    PipelineInstanceModel pim = PipelineHistoryMother.pipelineHistoryItemWithOneStage("pipeline", "stage", new Date());
    assertThat(pim.hasStage(pim.getStageHistory().first().getIdentifier()), is(true));
    assertThat(pim.hasStage(new StageIdentifier("pipeline", 1, "1", "stagex", "2")), is(false));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Date(java.util.Date) Test(org.junit.Test)

Aggregations

StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)58 Test (org.junit.Test)30 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 Pipeline (com.thoughtworks.go.domain.Pipeline)10 Stage (com.thoughtworks.go.domain.Stage)9 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)6 ArrayList (java.util.ArrayList)6 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)5 PipelineState (com.thoughtworks.go.domain.PipelineState)5 Modification (com.thoughtworks.go.domain.materials.Modification)5 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)5 Username (com.thoughtworks.go.server.domain.Username)4 Date (java.util.Date)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)3 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)3 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3