Search in sources :

Example 56 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class PipelineConfigDependencyGraphTest method shouldReturnTheSetOfFingerprintsOfAllMaterials.

@Test
public void shouldReturnTheSetOfFingerprintsOfAllMaterials() throws Exception {
    HgMaterialConfig common = MaterialConfigsMother.hgMaterialConfig();
    SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
    GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url", "submodule", "branch", false);
    P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
    DependencyMaterialConfig up1DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig up2DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig uppestDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first"));
    PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", common, up1DependencyMaterial, up2DependencyMaterial);
    PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", common, firstOrderGitMaterial, uppestDependencyMaterial);
    PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, common, uppestDependencyMaterial);
    PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", common, firstOrderP4Material);
    PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
    PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
    PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
    assertThat(dependencyGraph.allMaterialFingerprints().size(), is(7));
    assertThat(dependencyGraph.allMaterialFingerprints(), hasItems(common.getFingerprint(), firstOrderSVNMaterial.getFingerprint(), firstOrderGitMaterial.getFingerprint(), firstOrderP4Material.getFingerprint(), up1DependencyMaterial.getFingerprint(), up2DependencyMaterial.getFingerprint(), uppestDependencyMaterial.getFingerprint()));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialConfigsMother.filteredHgMaterialConfig(com.thoughtworks.go.helper.MaterialConfigsMother.filteredHgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 57 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class MaterialRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, MaterialConfig materialConfig) {
    if (!materialConfig.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            HashMap<String, String> errorMapping = new HashMap<>();
            errorMapping.put("materialName", "name");
            errorMapping.put("folder", "destination");
            errorMapping.put("autoUpdate", "auto_update");
            errorMapping.put("filterAsString", "filter");
            errorMapping.put("checkexternals", "check_externals");
            errorMapping.put("serverAndPort", "port");
            errorMapping.put("useTickets", "use_tickets");
            errorMapping.put("pipelineName", "pipeline");
            errorMapping.put("stageName", "stage");
            errorMapping.put("pipelineStageName", "pipeline");
            errorMapping.put("packageId", "ref");
            errorMapping.put("scmId", "ref");
            errorMapping.put("encryptedPassword", "encrypted_password");
            new ErrorGetter(errorMapping).toJSON(errorWriter, materialConfig);
        });
    }
    jsonWriter.add("type", classToTypeMap.get(materialConfig.getClass()));
    switch(classToTypeMap.get(materialConfig.getClass())) {
        case "git":
            jsonWriter.addChild("attributes", attributeWriter -> GitMaterialRepresenter.toJSON(attributeWriter, (GitMaterialConfig) materialConfig));
            break;
        case "hg":
            jsonWriter.addChild("attributes", attributeWriter -> HgMaterialRepresenter.toJSON(attributeWriter, (HgMaterialConfig) materialConfig));
            break;
        case "svn":
            jsonWriter.addChild("attributes", attributeWriter -> SvnMaterialRepresenter.toJSON(attributeWriter, (SvnMaterialConfig) materialConfig));
            break;
        case "p4":
            jsonWriter.addChild("attributes", attributeWriter -> PerforceMaterialRepresenter.toJSON(attributeWriter, (P4MaterialConfig) materialConfig));
            break;
        case "tfs":
            jsonWriter.addChild("attributes", attributeWriter -> TfsMaterialRepresenter.toJSON(attributeWriter, (TfsMaterialConfig) materialConfig));
            break;
        case "dependency":
            jsonWriter.addChild("attributes", attributeWriter -> DependencyMaterialRepresenter.toJSON(attributeWriter, (DependencyMaterialConfig) materialConfig));
            break;
        case "package":
            jsonWriter.addChild("attributes", attributeWriter -> PackageMaterialRepresenter.toJSON(attributeWriter, (PackageMaterialConfig) materialConfig));
            break;
        case "plugin":
            jsonWriter.addChild("attributes", attributeWriter -> PluggableScmMaterialRepresenter.toJSON(attributeWriter, (PluggableSCMMaterialConfig) materialConfig));
            break;
    }
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) HashMap(java.util.HashMap) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)

Example 58 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldLoadShallowFlagFromGitPartial.

@Test
void shouldLoadShallowFlagFromGitPartial() throws Exception {
    String gitPartial = "<git url='file:///tmp/testGitRepo/project1' shallowClone=\"true\" />";
    GitMaterialConfig gitMaterial = xmlLoader.fromXmlPartial(gitPartial, GitMaterialConfig.class);
    assertThat(gitMaterial.isShallowClone()).isTrue();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 59 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldLoadBranchFromGitPartial.

@Test
void shouldLoadBranchFromGitPartial() throws Exception {
    String gitPartial = "<git url='file:///tmp/testGitRepo/project1' branch='foo'/>";
    GitMaterialConfig gitMaterial = xmlLoader.fromXmlPartial(gitPartial, GitMaterialConfig.class);
    assertThat(gitMaterial.getBranch()).isEqualTo("foo");
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 60 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldWriteGitMaterialToXmlPartial.

@Test
public void shouldWriteGitMaterialToXmlPartial() throws Exception {
    GitMaterialConfig gitMaterial = git("gitUrl");
    assertThat(xmlWriter.toXmlPartial(gitMaterial), is("<git url=\"gitUrl\" />"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7