use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel 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.PipelineModel 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.PipelineModel in project gocd by gocd.
the class EnvironmentService method addEnvironmentFor.
void addEnvironmentFor(CaseInsensitiveString environmentName, Username username, ArrayList<Environment> environments) throws NoSuchEnvironmentException {
List<CaseInsensitiveString> pipelines = environmentConfigService.pipelinesFor(environmentName);
if (pipelines.isEmpty()) {
environments.add(new Environment(CaseInsensitiveString.str(environmentName), new ArrayList<>()));
return;
}
List<PipelineModel> pipelineInstanceModels = getPipelinesInstanceForEnvironment(pipelines, username);
if (!pipelineInstanceModels.isEmpty()) {
environments.add(new Environment(CaseInsensitiveString.str(environmentName), pipelineInstanceModels));
}
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewIncludingUserAdminStatus.
@Test
public void shouldGenerateKeyForPipelineModelViewIncludingUserAdminStatus() {
PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).updateAdministrability(true);
StageInstanceModels stages = new StageInstanceModels();
stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
stages.add(new NullStageHistoryItem("stage2", true));
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), stages);
pipelineInstance.setId(12);
pipelineInstance.setCanUnlock(false);
pipelineInstance.setIsLockable(true);
pipelineInstance.setCurrentlyLocked(true);
model.addPipelineInstance(pipelineInstance);
assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{true|true|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true"));
model.updateAdministrability(false);
assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{true|true|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForEnvironmentPipelineFragment.
@Test
public void shouldGenerateKeyForEnvironmentPipelineFragment() {
MaterialRevisions materialRevisions = ModificationsMother.createHgMaterialRevisions();
Modification latestModification = materialRevisions.getMaterialRevision(0).getModifications().remove(0);
PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).updateAdministrability(true);
StageInstanceModels stages = new StageInstanceModels();
stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
stages.add(new NullStageHistoryItem("stage2", true));
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createWithModifications(materialRevisions, "someone"), stages);
pipelineInstance.setMaterialConfigs(materialRevisions.getMaterials().convertToConfigs());
pipelineInstance.setLatestRevisions(new MaterialRevisions(new MaterialRevision(materialRevisions.getMaterialRevision(0).getMaterial(), latestModification)));
pipelineInstance.setId(12);
model.addPipelineInstance(pipelineInstance);
assertThat(model.hasNewRevisions(), is(true));
assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true|true"));
model.updateAdministrability(false);
assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false|true"));
}
Aggregations