Search in sources :

Example 26 with PipelineTimelineEntry

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

the class PipelineMaterialModificationTest method shouldCompareWhenThisModificationOccuredBeforeTheOtherModification.

@Test
public void shouldCompareWhenThisModificationOccuredBeforeTheOtherModification() throws Exception {
    PipelineTimelineEntry modification = modification(Arrays.asList("flyweight"), 1, "123", new DateTime());
    PipelineTimelineEntry that = modification(2, Arrays.asList("flyweight"), Arrays.asList(new DateTime().plusMinutes(1)), 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 27 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 28 with PipelineTimelineEntry

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

the class PipelineMaterialModificationTest method shouldCompareModsWith4MaterialsWithOneMaterialNotChanged.

@Test
public void shouldCompareModsWith4MaterialsWithOneMaterialNotChanged() throws Exception {
    List<String> materials = Arrays.asList("first", "second", "third", "fourth");
    DateTime base = new DateTime();
    PipelineTimelineEntry modification = modification(1, materials, Arrays.asList(base, base.plusMinutes(3), base.plusMinutes(2), base.plusMinutes(4)), 1, "123", "pipeline");
    PipelineTimelineEntry that = modification(2, materials, Arrays.asList(base, base.plusMinutes(2), base.plusMinutes(3), base.plusMinutes(1)), 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 29 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)

Example 30 with PipelineTimelineEntry

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

the class PipelineTimelineTest method updateShouldIgnoreExceptionThrownByListenersDuringNotifications.

@Test
public void updateShouldIgnoreExceptionThrownByListenersDuringNotifications() throws Exception {
    stubTransactionSynchronization();
    setupTransactionTemplateStub(TransactionSynchronization.STATUS_COMMITTED, true);
    TimelineUpdateListener anotherListener = mock(TimelineUpdateListener.class);
    final PipelineTimeline timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager, new TimelineUpdateListener() {

        public void added(PipelineTimelineEntry newlyAddedEntry, TreeSet<PipelineTimelineEntry> timeline) {
            throw new RuntimeException();
        }
    }, anotherListener);
    stubPipelineRepository(timeline, true, new PipelineTimelineEntry[] { first, second });
    try {
        timeline.update();
    } catch (Exception e) {
        fail("should not have failed because of exception thrown by listener");
    }
    verify(anotherListener).added(eq(first), any(TreeSet.class));
}
Also used : TimelineUpdateListener(com.thoughtworks.go.listener.TimelineUpdateListener) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) Test(org.junit.Test)

Aggregations

PipelineTimelineEntry (com.thoughtworks.go.domain.PipelineTimelineEntry)31 Test (org.junit.Test)18 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 ArrayList (java.util.ArrayList)11 DateTime (org.joda.time.DateTime)11 PipelineTimeline (com.thoughtworks.go.server.domain.PipelineTimeline)9 List (java.util.List)6 Date (java.util.Date)5 BigInteger (java.math.BigInteger)4 Map (java.util.Map)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)3 TimelineUpdateListener (com.thoughtworks.go.listener.TimelineUpdateListener)3 HashMap (java.util.HashMap)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)2 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)2 PipelineConfigMother.createPipelineConfig (com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig)2