use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryGroupingUtilTest method shouldCreateTwoGroupsWithMultiplePipelineHistoryItems.
@Test
public void shouldCreateTwoGroupsWithMultiplePipelineHistoryItems() throws Exception {
PipelineInstanceModel pipelineHistoryItem1 = PipelineHistoryItemMother.custom("stage1", "stage2");
PipelineInstanceModel pipelineHistoryItem2 = PipelineHistoryItemMother.custom("stage1", "stage3");
PipelineInstanceModels history = PipelineInstanceModels.createPipelineInstanceModels(pipelineHistoryItem1, pipelineHistoryItem2);
PipelineHistoryGroups historyGroups = groupingUtil.createGroups(history);
assertThat(historyGroups.size(), is(2));
assertThat(historyGroups.first().hasSameStagesAs(pipelineHistoryItem1), is(true));
assertThat(historyGroups.get(1).hasSameStagesAs(pipelineHistoryItem2), is(true));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryGroupTest method shouldNotMatchSpecifiedItemIfNameNotMatched.
@Test
public void shouldNotMatchSpecifiedItemIfNameNotMatched() throws Exception {
PipelineInstanceGroupModel group = new PipelineInstanceGroupModel();
group.getStages().addAll(asList(new SimpleInfo("stage1", true), new SimpleInfo("stage2", false)));
PipelineInstanceModel pipelineInstanceModel = PipelineHistoryItemMother.custom(StageHistoryItemMother.custom("stage1", true), StageHistoryItemMother.custom("stage3", false));
assertThat(group.hasSameStagesAs(pipelineInstanceModel), is(false));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class EnvironmentServiceTest method stubPipelineHistoryServiceToReturnPipelines.
private PipelineInstanceModel stubPipelineHistoryServiceToReturnPipelines(final String pipelineName) {
PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createPipeline(pipelineName, -1, "1", BuildCause.createManualForced(), new StageInstanceModels());
PipelineModel pipelineModel = new PipelineModel(pipelineInstanceModel.getName(), true, true, PipelinePauseInfo.notPaused());
pipelineModel.addPipelineInstance(pipelineInstanceModel);
when(pipelineHistoryService.latestPipelineModel(new Username(new CaseInsensitiveString("Foo")), pipelineName)).thenReturn(pipelineModel);
return pipelineInstanceModel;
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class EnvironmentServiceTest method shouldReturnPipelineHistoryForPipelinesInAnEnvironment.
@Test
public void shouldReturnPipelineHistoryForPipelinesInAnEnvironment() throws Exception {
Username username = new Username(new CaseInsensitiveString("Foo"));
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(Arrays.asList(new CaseInsensitiveString("uat-pipeline"), new CaseInsensitiveString("staging-pipeline")));
PipelineInstanceModel uatInstance = stubPipelineHistoryServiceToReturnPipelines("uat-pipeline");
PipelineInstanceModel stagingInstance = stubPipelineHistoryServiceToReturnPipelines("staging-pipeline");
ArrayList<Environment> environments = new ArrayList<>();
environmentService.addEnvironmentFor(new CaseInsensitiveString("uat"), username, environments);
assertThat(environments.size(), is(1));
Environment environment = environments.get(0);
assertThat(environment.getName(), is("uat"));
List<PipelineModel> models = environment.getPipelineModels();
assertThat(models.size(), is(2));
PipelineModel model1 = new PipelineModel(uatInstance.getName(), true, true, PipelinePauseInfo.notPaused());
model1.addPipelineInstance(uatInstance);
assertThat(models, hasItem(model1));
PipelineModel model2 = new PipelineModel(stagingInstance.getName(), true, true, PipelinePauseInfo.notPaused());
model2.addPipelineInstance(stagingInstance);
assertThat(models, hasItem(model2));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class BuildCauseControllerDelegate method index.
public String index(Request req, Response res) throws IOException {
HttpOperationResult httpOperationResult = new HttpOperationResult();
int result;
try {
result = Integer.parseInt(req.params(":pipeline_counter"));
} catch (NumberFormatException nfe) {
throw new RecordNotFoundException();
}
String pipelineName = req.params("pipeline_name");
PipelineInstanceModel pipelineInstance = pipelineHistoryService.findPipelineInstance(pipelineName, result, currentUsername(), httpOperationResult);
if (httpOperationResult.isSuccess()) {
return writerForTopLevelObject(req, res, outputWriter -> BuildCauseRepresenter.toJSON(outputWriter, pipelineInstance.getBuildCause()));
} else {
return renderHTTPOperationResult(httpOperationResult, req, res);
}
}
Aggregations