Search in sources :

Example 11 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ValueStreamMapServiceTest method currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision.

@Test
public void currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision() {
    /*
                            /-> P1 -- \
                        git            -> p3
                            \-> P2 -- /
         */
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    Modification rev1 = ModificationsMother.oneModifiedFile("rev1");
    Modification rev2 = ModificationsMother.oneModifiedFile("rev2");
    Modification rev3 = ModificationsMother.oneModifiedFile("rev3");
    BuildCause p1buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3, rev2, rev1));
    BuildCause p2buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3));
    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);
    assertNull(graph.getCurrentPipeline().getViewType());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) 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) Test(org.junit.Test)

Example 12 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel.

@Test
public void shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel() throws Exception {
    /*
        * +-------------+
        * |             v
        * g---->p1---->p2 ---> p3
        *        |             ^
        *        -------------+
        *
        * */
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    String p1 = "p1";
    String p2 = "p2";
    String p3 = "p3";
    BuildCause p3buildCause = createBuildCause(asList(p1, p2), new ArrayList<>());
    BuildCause p2buildCause = createBuildCause(asList(p1), asList(git));
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
    when(pipelineService.buildCauseFor(p3, 1)).thenReturn(p3buildCause);
    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, new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name())));
    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(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "p3-label", p3buildCause));
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(p3, 1, user, result);
    List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
    assertThat(graph.getCurrentPipeline().getName(), is(p3));
    assertThat(nodesAtEachLevel.size(), is(4));
    List<Node> firstLevel = nodesAtEachLevel.get(0);
    assertThat(firstLevel.size(), is(1));
    assertLayerHasNode(firstLevel, git.getDisplayName(), git.getFingerprint(), p1);
    List<Node> secondLevel = nodesAtEachLevel.get(1);
    assertThat(secondLevel.size(), is(2));
    assertLayerHasNode(secondLevel, p1, p1, p2);
    assertLayerHasDummyNodeWithDependents(secondLevel, p2);
    List<Node> thirdLevel = nodesAtEachLevel.get(2);
    assertThat(thirdLevel.size(), is(2));
    assertLayerHasNode(thirdLevel, p2, p2, p3);
    assertLayerHasDummyNodeWithDependents(thirdLevel, p3);
    List<Node> fourthLevel = nodesAtEachLevel.get(3);
    assertThat(fourthLevel.size(), is(1));
    assertLayerHasNode(fourthLevel, p3, p3);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Arrays.asList(java.util.Arrays.asList) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 13 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class GoConfigMigrationIntegrationTest method migration99_shouldMigrateHgMaterialsUnderConfigRepoAndRetainOnlyTheMinimalRequiredAttributes.

@Test
public void migration99_shouldMigrateHgMaterialsUnderConfigRepoAndRetainOnlyTheMinimalRequiredAttributes() throws Exception {
    String configXml = "<cruise schemaVersion='98'>" + "<config-repos>\n" + "   <config-repo pluginId=\"json.config.plugin\" id=\"config-repo-1\">\n" + "      <hg url=\"test-repo\" dest='dest' autoUpdate='true' invertFilter='true' materialName=\"foo\">\n" + "        <filter>\n" + "          <ignore pattern=\"asdsd\" />\n" + "        </filter>\n" + "      </hg>" + "   </config-repo>\n" + "</config-repos>" + "</cruise>";
    assertThat(configXml, containsString("<filter>"));
    assertThat(configXml, containsString("dest='dest'"));
    assertThat(configXml, containsString("autoUpdate='true'"));
    assertThat(configXml, containsString("invertFilter='true'"));
    String migratedContent = migrateXmlString(configXml, 98);
    CruiseConfig cruiseConfig = loader.deserializeConfig(migratedContent);
    MaterialConfig materialConfig = cruiseConfig.getConfigRepos().getConfigRepo("config-repo-1").getMaterialConfig();
    assertThat(migratedContent, not(containsString("<filter>")));
    assertThat(migratedContent, not(containsString("dest='dest'")));
    assertThat(migratedContent, not(containsString("invertFilter='true'")));
    assertThat(materialConfig.getFolder(), is(Matchers.isNull()));
    assertThat(materialConfig.filter().size(), is(0));
    assertThat(materialConfig.isAutoUpdate(), is(true));
    assertThat(materialConfig.isInvertFilter(), is(false));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 14 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method autoUpdateShouldUnderstandTrue.

@Test
public void autoUpdateShouldUnderstandTrue() throws Exception {
    MaterialConfig hgMaterial = xmlLoader.fromXmlPartial("<hg url=\"file:///tmp/testSvnRepo/project1/trunk\" autoUpdate=\"true\"/>", HgMaterialConfig.class);
    assertThat(hgMaterial.isAutoUpdate(), is(true));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) Test(org.junit.Test)

Example 15 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldLoadFromSvnPartial.

@Test
public void shouldLoadFromSvnPartial() throws Exception {
    String buildXmlPartial = "<svn url=\"http://foo.bar\" username=\"cruise\" password=\"password\" materialName=\"http___foo.bar\"/>";
    MaterialConfig materialConfig = xmlLoader.fromXmlPartial(toInputStream(buildXmlPartial), SvnMaterialConfig.class);
    MaterialConfig svnMaterial = MaterialConfigsMother.svnMaterialConfig("http://foo.bar", null, "cruise", "password", false, null);
    assertThat(materialConfig, is(svnMaterial));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) Test(org.junit.Test)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)133 Test (org.junit.Test)81 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)72 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)61 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)46 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)42 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)33 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)32 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)32 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)29 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)29 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)13 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)13 Filter (com.thoughtworks.go.config.materials.Filter)11 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)10 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)10 Material (com.thoughtworks.go.domain.materials.Material)9