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));
}
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 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));
}
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));
}
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));
}
Aggregations