Search in sources :

Example 21 with ValueStreamMapPresentationModel

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"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) Test(org.junit.Test)

Example 22 with ValueStreamMapPresentationModel

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 23 with ValueStreamMapPresentationModel

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) Test(org.junit.Test)

Example 24 with ValueStreamMapPresentationModel

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"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 25 with ValueStreamMapPresentationModel

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());
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Aggregations

ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)25 Test (org.junit.Test)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)20 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)16 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)9 Arrays.asList (java.util.Arrays.asList)8 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)6 List (java.util.List)5 Modification (com.thoughtworks.go.domain.materials.Modification)3 Modifications (com.thoughtworks.go.domain.materials.Modifications)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 Username (com.thoughtworks.go.server.domain.Username)2 RunIf (com.googlecode.junit.ext.RunIf)1 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)1 DefaultLocalizedOperationResult (com.thoughtworks.go.server.service.result.DefaultLocalizedOperationResult)1