use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class PipelineHistoryItemMother method custom.
public static PipelineInstanceModel custom(StageInstanceModel... stages) {
PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createEmptyModel();
pipelineInstanceModel.setStageHistory(new StageInstanceModels());
for (StageInstanceModel stage : stages) {
pipelineInstanceModel.getStageHistory().add(stage);
}
return pipelineInstanceModel;
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageSqlMapDao method findDetailedStageHistory.
StageInstanceModels findDetailedStageHistory(String pipelineName, String stageName, Pagination pagination) {
Map<String, Object> args = arguments("pipelineName", pipelineName).and("stageName", stageName).and("limit", pagination.getPageSize()).and("offset", pagination.getOffset()).asMap();
List<StageInstanceModel> detailedStageHistory = (List<StageInstanceModel>) getSqlMapClientTemplate().queryForList("getDetailedStageHistory", args);
StageInstanceModels stageInstanceModels = new StageInstanceModels();
stageInstanceModels.addAll(detailedStageHistory);
return stageInstanceModels;
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageSqlMapDao method findDetailedStageHistoryByOffset.
public StageInstanceModels findDetailedStageHistoryByOffset(String pipelineName, String stageName, final Pagination pagination) {
String mutex = mutexForStageHistory(pipelineName, stageName);
readWriteLock.acquireReadLock(mutex);
try {
String subKey = String.format("%s-%s", pagination.getOffset(), pagination.getPageSize());
String key = cacheKeyForDetailedStageHistories(pipelineName, stageName);
StageInstanceModels stageInstanceModels = (StageInstanceModels) goCache.get(key, subKey);
if (stageInstanceModels == null) {
stageInstanceModels = findDetailedStageHistory(pipelineName, stageName, pagination);
goCache.put(key, subKey, stageInstanceModels);
}
return cloner.deepClone(stageInstanceModels);
} finally {
readWriteLock.releaseReadLock(mutex);
}
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method shouldGetDetailedStageHistory.
@Test
public void shouldGetDetailedStageHistory() throws Exception {
HgMaterial hg = new HgMaterial("url", null);
String[] hg_revs = { "h1", "h2", "h3" };
scheduleUtil.checkinInOrder(hg, hg_revs);
String pipelineName = "p1";
String stageName = "stage_name";
ScheduleTestUtil.AddedPipeline p1 = scheduleUtil.saveConfigWith(pipelineName, stageName, scheduleUtil.m(hg), new String[] { "job1", "job2" });
scheduleUtil.runAndPass(p1, "h1");
scheduleUtil.runAndPass(p1, "h2");
scheduleUtil.runAndPass(p1, "h3");
Pagination pagination = Pagination.pageStartingAt(0, 3, 2);
StageInstanceModels stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertThat(stageInstanceModels.size(), is(2));
assertThat(stageInstanceModels.get(0).getResult(), is(StageResult.Passed));
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName(), is(pipelineName));
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter(), is(3));
assertThat(stageInstanceModels.get(0).getIdentifier().getStageName(), is(stageName));
assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter(), is("1"));
assertJobDetails(stageInstanceModels.get(0).getBuildHistory());
assertThat(stageInstanceModels.get(1).getResult(), is(StageResult.Passed));
assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineName(), is(pipelineName));
assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineCounter(), is(2));
assertThat(stageInstanceModels.get(1).getIdentifier().getStageName(), is(stageName));
assertThat(stageInstanceModels.get(1).getIdentifier().getStageCounter(), is("1"));
assertJobDetails(stageInstanceModels.get(1).getBuildHistory());
pagination = Pagination.pageStartingAt(2, 3, 2);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertThat(stageInstanceModels.size(), is(1));
assertThat(stageInstanceModels.get(0).getResult(), is(StageResult.Passed));
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName(), is(pipelineName));
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter(), is(1));
assertThat(stageInstanceModels.get(0).getIdentifier().getStageName(), is(stageName));
assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter(), is("1"));
assertJobDetails(stageInstanceModels.get(0).getBuildHistory());
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method shouldPaginateBasedOnOffset.
@Test
public void shouldPaginateBasedOnOffset() throws Exception {
HgMaterial hg = new HgMaterial("url", null);
String[] hg_revs = { "h1", "h2", "h3" };
scheduleUtil.checkinInOrder(hg, hg_revs);
String pipelineName = "p1";
String stageName = "stage_name";
ScheduleTestUtil.AddedPipeline p1 = scheduleUtil.saveConfigWith(pipelineName, stageName, scheduleUtil.m(hg));
String run1 = scheduleUtil.runAndPass(p1, "h1");
String run2 = scheduleUtil.runAndPass(p1, "h2");
String run3 = scheduleUtil.runAndPass(p1, "h3");
String run4 = scheduleUtil.runAndPass(p1, "h1", "h2");
String run5 = scheduleUtil.runAndPass(p1, "h2", "h3");
String run6 = scheduleUtil.runAndPass(p1, "h3", "h1");
String run7 = scheduleUtil.runAndPass(p1, "h1", "h2", "h3");
Pagination pagination = Pagination.pageStartingAt(0, 7, 3);
StageInstanceModels stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run7, run6, run5);
pagination = Pagination.pageStartingAt(1, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run6, run5, run4);
pagination = Pagination.pageStartingAt(2, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run5, run4, run3);
pagination = Pagination.pageStartingAt(3, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run4, run3, run2);
pagination = Pagination.pageStartingAt(4, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run3, run2, run1);
pagination = Pagination.pageStartingAt(5, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run2, run1);
pagination = Pagination.pageStartingAt(6, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run1);
pagination = Pagination.pageStartingAt(7, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertThat("Expected no models. Found: " + stageInstanceModels, stageInstanceModels.size(), is(0));
pagination = Pagination.pageStartingAt(20, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertThat("Expected no models. Found: " + stageInstanceModels, stageInstanceModels.size(), is(0));
pagination = Pagination.pageStartingAt(1, 7, 4);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run6, run5, run4, run3);
}
Aggregations