use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineHistoryService method populatePreviousStageState.
private void populatePreviousStageState(PipelineInstanceModel activePipeline) {
if (activePipeline.isAnyStageActive()) {
StageInstanceModel activeStage = activePipeline.activeStage();
StageInstanceModel latestActive = null;
long id = activePipeline.getId();
do {
PipelineTimelineEntry timelineEntry = pipelineTimeline.runBefore(id, new CaseInsensitiveString(activePipeline.getName()));
if (timelineEntry == null) {
break;
}
id = timelineEntry.getId();
PipelineInstanceModel instanceModel = pipelineDao.loadHistory(id);
if (instanceModel != null && instanceModel.hasStageBeenRun(activeStage.getName())) {
latestActive = instanceModel.getStageHistory().byName(activeStage.getName());
}
} while (latestActive == null);
activeStage.setPreviousStage(latestActive);
}
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineMaterialModificationTest method shouldCompareModsWithMultipleMaterials.
@Test
public void shouldCompareModsWithMultipleMaterials() throws Exception {
List<String> materials = Arrays.asList("flyweight", "another");
DateTime base = new DateTime();
PipelineTimelineEntry modification = modification(1, materials, Arrays.asList(base.plusMinutes(1), base.plusMinutes(3)), 1, "123");
PipelineTimelineEntry that = modification(2, materials, Arrays.asList(base.plusMinutes(4), base.plusMinutes(2)), 1, "123");
assertThat(modification.compareTo(that), is(-1));
assertThat(that.compareTo(modification), is(1));
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineMaterialModificationTest method shouldIgnoreExtraMaterialForComparison.
@Test
public void shouldIgnoreExtraMaterialForComparison() throws Exception {
DateTime base = new DateTime();
// Ignore the extra material
PipelineTimelineEntry modification = modification(1, Arrays.asList("first", "second", "third"), Arrays.asList(base, base.plusMinutes(3), base.plusMinutes(2)), 1, "123", "pipeline");
PipelineTimelineEntry that = modification(2, Arrays.asList("first", "second"), Arrays.asList(base, base.plusMinutes(2)), 2, "123", "pipeline");
assertThat(modification.compareTo(that), is(1));
assertThat(that.compareTo(modification), is(-1));
// Now break the tie using counter and ignore the extra third material
modification = modification(1, Arrays.asList("first", "second", "third"), Arrays.asList(base, base.plusMinutes(3), base.plusMinutes(2)), 1, "123", "pipeline");
that = modification(2, Arrays.asList("first", "second"), Arrays.asList(base, base.plusMinutes(3)), 2, "123", "pipeline");
assertThat(modification.compareTo(that), is(-1));
assertThat(that.compareTo(modification), is(1));
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineMaterialModificationTest method shouldCompareModsWithMultipleMaterialsWithOneMaterialNotChanged.
@Test
public void shouldCompareModsWithMultipleMaterialsWithOneMaterialNotChanged() throws Exception {
List<String> materials = Arrays.asList("flyweight", "another");
DateTime base = new DateTime();
PipelineTimelineEntry modification = modification(1, materials, Arrays.asList(base, base.plusMinutes(3)), 1, "123");
PipelineTimelineEntry that = modification(2, materials, Arrays.asList(base, base.plusMinutes(2)), 1, "123");
assertThat(modification.compareTo(that), is(1));
assertThat(that.compareTo(modification), is(-1));
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineMaterialModificationTest method shouldCompareModsWithNoMaterialsChanged.
@Test
public void shouldCompareModsWithNoMaterialsChanged() throws Exception {
List<String> materials = Arrays.asList("flyweight", "another");
DateTime base = new DateTime();
PipelineTimelineEntry modification = modification(1, materials, Arrays.asList(base, base.plusMinutes(3)), 1, "123", "pipeline");
PipelineTimelineEntry that = modification(2, materials, Arrays.asList(base, base.plusMinutes(3)), 2, "123", "pipeline");
assertThat(modification.compareTo(that), is(-1));
assertThat(that.compareTo(modification), is(1));
}
Aggregations