Search in sources :

Example 11 with PipelineTimelineEntry

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);
    }
}
Also used : PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry)

Example 12 with PipelineTimelineEntry

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));
}
Also used : PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 13 with PipelineTimelineEntry

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));
}
Also used : PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 14 with PipelineTimelineEntry

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));
}
Also used : PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 15 with PipelineTimelineEntry

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));
}
Also used : PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

PipelineTimelineEntry (com.thoughtworks.go.domain.PipelineTimelineEntry)28 Test (org.junit.Test)15 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 DateTime (org.joda.time.DateTime)9 ArrayList (java.util.ArrayList)8 PipelineTimeline (com.thoughtworks.go.server.domain.PipelineTimeline)6 Date (java.util.Date)5 List (java.util.List)5 BigInteger (java.math.BigInteger)4 Map (java.util.Map)4 TimelineUpdateListener (com.thoughtworks.go.listener.TimelineUpdateListener)3 HashMap (java.util.HashMap)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)2 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)2 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)2 Pair (com.thoughtworks.go.util.Pair)2 LinkedHashMap (java.util.LinkedHashMap)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)1