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()).isEqualTo(2);
assertThat(stageInstanceModels.get(0).getResult()).isEqualTo(StageResult.Passed);
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName()).isEqualTo(pipelineName);
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter()).isEqualTo(3);
assertThat(stageInstanceModels.get(0).getIdentifier().getStageName()).isEqualTo(stageName);
assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter()).isEqualTo("1");
assertJobDetails(stageInstanceModels.get(0).getBuildHistory());
assertThat(stageInstanceModels.get(1).getResult()).isEqualTo(StageResult.Passed);
assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineName()).isEqualTo(pipelineName);
assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineCounter()).isEqualTo(2);
assertThat(stageInstanceModels.get(1).getIdentifier().getStageName()).isEqualTo(stageName);
assertThat(stageInstanceModels.get(1).getIdentifier().getStageCounter()).isEqualTo("1");
assertJobDetails(stageInstanceModels.get(1).getBuildHistory());
pagination = Pagination.pageStartingAt(2, 3, 2);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertThat(stageInstanceModels.size()).isEqualTo(1);
assertThat(stageInstanceModels.get(0).getResult()).isEqualTo(StageResult.Passed);
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName()).isEqualTo(pipelineName);
assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter()).isEqualTo(1);
assertThat(stageInstanceModels.get(0).getIdentifier().getStageName()).isEqualTo(stageName);
assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter()).isEqualTo("1");
assertJobDetails(stageInstanceModels.get(0).getBuildHistory());
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method stageHistoryViaCursor_shouldReturnListWithTheRecordsAfterTheSpecifiedCursor.
@Test
public void stageHistoryViaCursor_shouldReturnListWithTheRecordsAfterTheSpecifiedCursor() {
// older records
HgMaterial hg = new HgMaterial("url", null);
String[] hg_revs = { "h1", "h2", "h3" };
scheduleUtil.checkinInOrder(hg, hg_revs);
String pipelineName = PIPELINE_NAME + "-" + UUID.randomUUID();
ScheduleTestUtil.AddedPipeline p1 = scheduleUtil.saveConfigWith(pipelineName, STAGE_DEV, scheduleUtil.m(hg));
Date date = new Date();
Pipeline run1 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h1");
Pipeline run2 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h2");
Pipeline run3 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h3");
Pipeline run4 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h1", "h2");
Pipeline run5 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h2", "h3");
StageInstanceModels stageHistory = stageDao.findDetailedStageHistoryViaCursor(pipelineName, STAGE_DEV, FeedModifier.After, run4.getFirstStage().getId(), 3);
assertThat(stageHistory.size()).isEqualTo(3);
assertThat(stageHistory.get(0).getId()).isEqualTo(run3.getFirstStage().getId());
assertThat(stageHistory.get(1).getId()).isEqualTo(run2.getFirstStage().getId());
assertThat(stageHistory.get(2).getId()).isEqualTo(run1.getFirstStage().getId());
}
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(stageInstanceModels.size()).as("Expected no models. Found: " + stageInstanceModels).isEqualTo(0);
pagination = Pagination.pageStartingAt(20, 7, 3);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertThat(stageInstanceModels.size()).as("Expected no models. Found: " + stageInstanceModels).isEqualTo(0);
pagination = Pagination.pageStartingAt(1, 7, 4);
stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
assertStageModels(stageInstanceModels, run6, run5, run4, run3);
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldLoadPipelineHistories.
@Test
public void shouldLoadPipelineHistories() throws Exception {
String dev = "dev";
PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", dev);
Pipeline mingle = schedulePipelineWithStages(mingleConfig);
Stage firstStage = mingle.getFirstStage();
Pipeline mingle2 = schedulePipelineWithStages(mingleConfig);
JobInstance instance = firstStage.getJobInstances().first();
jobInstanceDao.ignore(instance);
PipelineInstanceModels pipelineHistories = pipelineDao.loadHistory(mingle.getName(), 10, 0);
assertThat(pipelineHistories.size(), is(2));
StageInstanceModels stageHistories = pipelineHistories.first().getStageHistory();
assertThat(stageHistories.size(), is(1));
StageInstanceModel history = stageHistories.first();
assertThat(history.getName(), is(dev));
assertThat(history.getApprovalType(), is(GoConstants.APPROVAL_SUCCESS));
assertThat(history.getBuildHistory().size(), is(2));
assertThat(pipelineHistories.get(1).getName(), is("mingle"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageServiceIntegrationTest method shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor.
@Test
public void shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor() {
StageHistoryEntry[] stages = createFiveStages();
StageInstanceModels history = stageService.findStageHistoryViaCursor(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName(), 0, stages[2].getId(), 10);
assertThat(history.size(), is(2));
assertThat(history.get(0).getId(), is(stages[4].getId()));
assertThat(history.get(1).getId(), is(stages[3].getId()));
}
Aggregations