use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineRepositoryTest method shouldNotUpdateTimelineEntriesAndEntriesForRollbackUponFailureDuringRetrieval.
@Test
public void shouldNotUpdateTimelineEntriesAndEntriesForRollbackUponFailureDuringRetrieval() throws Exception {
Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
Object[] pipelineRow2 = { "p1", "cause-failure-during-retrieval", new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
try {
pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
fail("Should fail to retrieve pipeline.");
} catch (ClassCastException e) {
assertThat(tempEntries.size(), is(0));
assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(0));
}
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineRepositoryTest method shouldUpdateTimelineEntriesAndEntriesForRollback.
@Test
public void shouldUpdateTimelineEntriesAndEntriesForRollback() throws Exception {
Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
Object[] pipelineRow2 = { "p1", new BigInteger("2"), new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
PipelineTimelineEntry timelineEntry1 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 1);
PipelineTimelineEntry timelineEntry2 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 2);
assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(2));
assertNotNull(timelineEntry1);
assertNotNull(timelineEntry2);
assertThat(tempEntries.size(), is(2));
assertThat(tempEntries, containsInAnyOrder(timelineEntry1, timelineEntry2));
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class PipelineRepositoryTest method shouldUpdateTimelineEntriesAndEntriesForRollbackDuringFailureWhileUpdatingTheDb.
@Test
public void shouldUpdateTimelineEntriesAndEntriesForRollbackDuringFailureWhileUpdatingTheDb() throws Exception {
Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
Object[] pipelineRow2 = { "p1", new BigInteger("2"), new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
when(sqlQuery.executeUpdate()).thenThrow(new RuntimeException("Failure during update natural order in db"));
ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
try {
pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
} catch (RuntimeException e) {
PipelineTimelineEntry timelineEntry1 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 1);
PipelineTimelineEntry timelineEntry2 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 2);
assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(2));
assertNotNull(timelineEntry1);
assertNotNull(timelineEntry2);
assertThat(tempEntries.size(), is(2));
assertThat(tempEntries, containsInAnyOrder(timelineEntry1, timelineEntry2));
}
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class ReportingDependencyFanInNode method addToRevisionQueue.
private void addToRevisionQueue(PipelineTimelineEntry entry, Queue<PipelineTimelineEntry.Revision> revisionQueue, List<ReportingFaninScmMaterial> scmMaterials, ReportingFanInGraphContext context) {
printPipelineTimelineEntry(entry, context);
for (Map.Entry<String, List<PipelineTimelineEntry.Revision>> revisionList : entry.revisions().entrySet()) {
String fingerprint = revisionList.getKey();
PipelineTimelineEntry.Revision revision = revisionList.getValue().get(0);
if (isScmMaterial(fingerprint, context)) {
scmMaterials.add(new ReportingFaninScmMaterial(fingerprint, revision));
continue;
}
if (isDependencyMaterial(fingerprint, context)) {
revisionQueue.add(revision);
}
}
}
use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.
the class DependencyFanInNode method addToRevisionQueue.
private void addToRevisionQueue(PipelineTimelineEntry entry, Queue<PipelineTimelineEntry.Revision> revisionQueue, List<FaninScmMaterial> scmMaterials, FanInGraphContext context, Set<CaseInsensitiveString> visitedNodes) {
for (Map.Entry<String, List<PipelineTimelineEntry.Revision>> revisionList : entry.revisions().entrySet()) {
String fingerprint = revisionList.getKey();
PipelineTimelineEntry.Revision revision = revisionList.getValue().get(0);
if (isScmMaterial(fingerprint, context)) {
scmMaterials.add(new FaninScmMaterial(fingerprint, revision));
continue;
}
if (isDependencyMaterial(fingerprint, context) && !visitedNodes.contains(new CaseInsensitiveString(revision.revision))) {
revisionQueue.add(revision);
visitedNodes.add(new CaseInsensitiveString(revision.revision));
}
}
}
Aggregations