use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateErrorWhenPipelineNameAndCounterAreMultiple.
@Test
public void shouldPopulateErrorWhenPipelineNameAndCounterAreMultiple() {
PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("MYPIPELINE", new MaterialConfigs(new GitMaterialConfig("sampleGit")));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(pipelineConfig));
when(pipelineService.findPipelineByCounterOrLabel("MYPIPELINE", "1")).thenThrow(Exception.class);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("MYPIPELINE", 1, user, result);
assertThat(graph, is(IsNull.nullValue()));
assertThat(result.isSuccessful(), is(false));
assertThat(ReflectionUtil.getField(result.localizable(), "key"), is("VSM_INTERNAL_SERVER_ERROR"));
}
use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceTest method currentPipelineShouldHaveWarningsIfBuiltFromIncompatibleRevisions.
@Test
public void currentPipelineShouldHaveWarningsIfBuiltFromIncompatibleRevisions() {
/*
/-> P1 -- \
git -> p3
\-> P2 -- /
*/
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
BuildCause p1buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(ModificationsMother.oneModifiedFile("rev1")));
BuildCause p2buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(ModificationsMother.oneModifiedFile("rev2")));
BuildCause p3buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1), dependencyMaterial("p2", 1)), new ArrayList<>(), new ArrayList<>());
when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
PipelineConfig p3Config = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
assertThat(graph.getCurrentPipeline().getViewType(), is(VSMViewType.WARNING));
}
use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateAllMaterialRevisionsThatCausedPipelineRun.
@Test
public void shouldPopulateAllMaterialRevisionsThatCausedPipelineRun() {
/*
* git---> p1 --->p2
* | ^
* +-------------+
* **/
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1)), asList(git), ModificationsMother.multipleModificationList(0));
BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
Modifications gitModifications = p1buildCause.getMaterialRevisions().getMaterialRevision(0).getModifications();
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config));
when(pipelineService.findPipelineByCounterOrLabel("p2", "1")).thenReturn(new Pipeline("p2", "LABEL-P2", p2buildCause));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p2", 1, user, result);
VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"));
VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-P2"));
VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, gitModifications));
verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateLabelForCurrentPipeline.
@Test
public void shouldPopulateLabelForCurrentPipeline() throws Exception {
/*
git --> p1
*/
GitMaterial git = new GitMaterial("git");
String pipelineName = "p1";
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(git.config()))));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
when(pipelineService.findPipelineByCounterOrLabel(pipelineName, "1")).thenReturn(new Pipeline("p1", "label-1", p1buildCause));
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(pipelineName, 1, user, result);
PipelineRevision revision = (PipelineRevision) graph.getCurrentPipeline().revisions().get(0);
assertThat(revision.getLabel(), is("label-1"));
}
use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateEditPermissionsForPipelineDependencyNode.
@Test
public void shouldPopulateEditPermissionsForPipelineDependencyNode() throws Exception {
/*
* g --> p1 --> p2
*/
GitMaterial git = new GitMaterial("git");
BuildCause p2buildCause = createBuildCause(asList("p1"), new ArrayList<>());
BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(new GitMaterialConfig("test")));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p2Config));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(goConfigService.hasPipelineNamed(any())).thenReturn(true);
when(goConfigService.canEditPipeline("p1", user)).thenReturn(true);
when(goConfigService.canEditPipeline("p2", user)).thenReturn(false);
when(pipelineService.findPipelineByCounterOrLabel("p2", "1")).thenReturn(new Pipeline("p2", "p2-label", p2buildCause));
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p2", 1, user, result);
PipelineDependencyNode p1 = (PipelineDependencyNode) graph.getNodesAtEachLevel().get(1).get(0);
PipelineDependencyNode p2 = (PipelineDependencyNode) graph.getNodesAtEachLevel().get(2).get(0);
assertTrue(p1.canEdit());
assertFalse(p2.canEdit());
}
Aggregations