Search in sources :

Example 26 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertSvmMaterialConfigWhenPlainPassword.

@Test
void shouldConvertSvmMaterialConfigWhenPlainPassword() {
    SvnMaterialConfig svnMaterialConfig = svn("url", true);
    svnMaterialConfig.setName(new CaseInsensitiveString("name"));
    svnMaterialConfig.setPassword("pass");
    svnMaterialConfig.setFolder("folder");
    svnMaterialConfig.setFilter(Filter.create("filter"));
    svnMaterialConfig.setUserName("username");
    CRSvnMaterial crSvnMaterial = (CRSvnMaterial) configConverter.materialToCRMaterial(svnMaterialConfig);
    assertThat(crSvnMaterial.getName()).isEqualTo("name");
    assertThat(crSvnMaterial.getDestination()).isEqualTo("folder");
    assertThat(crSvnMaterial.isAutoUpdate()).isTrue();
    assertThat(crSvnMaterial.getFilterList()).contains("filter");
    assertThat(crSvnMaterial.getUrl()).isEqualTo("url");
    assertThat(crSvnMaterial.getUsername()).isEqualTo("username");
    assertThat(crSvnMaterial.getPassword()).isNull();
    assertThat(crSvnMaterial.isCheckExternals()).isTrue();
}
Also used : SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 27 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class GoConfigServiceTest method shouldBeAbleToListAllSCMMaterialConfigs.

@Test
public void shouldBeAbleToListAllSCMMaterialConfigs() {
    BasicCruiseConfig config = mock(BasicCruiseConfig.class);
    DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
    SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig();
    HashSet<MaterialConfig> materialConfigs = new HashSet<>(Arrays.asList(dependencyMaterialConfig, svnMaterialConfig, pluggableSCMMaterialConfig));
    when(goConfigService.getCurrentConfig()).thenReturn(config);
    when(config.getAllUniqueMaterialsBelongingToAutoPipelinesAndConfigRepos()).thenReturn(materialConfigs);
    Set<MaterialConfig> schedulableDependencyMaterials = goConfigService.getSchedulableSCMMaterials();
    assertThat(schedulableDependencyMaterials.size(), is(2));
    assertTrue(schedulableDependencyMaterials.contains(svnMaterialConfig));
    assertTrue(schedulableDependencyMaterials.contains(pluggableSCMMaterialConfig));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 28 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class GoConfigServiceTest method shouldFindMaterialConfigBasedOnFingerprint.

@Test
public void shouldFindMaterialConfigBasedOnFingerprint() throws Exception {
    SvnMaterialConfig expected = svn("repo", null, null, false);
    cruiseConfig = configWith(GoConfigMother.createPipelineConfigWithMaterialConfig(expected));
    when(goConfigDao.load()).thenReturn(cruiseConfig);
    MaterialConfig actual = goConfigService.materialForPipelineWithFingerprint("pipeline", expected.getFingerprint());
    assertThat(actual, is(expected));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 29 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig 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 30 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class ServerHealthServiceTest method shouldRemoveErrorLogWhenCorrespondingMaterialIsMissing.

@Test
public void shouldRemoveErrorLogWhenCorrespondingMaterialIsMissing() throws Exception {
    serverHealthService.update(ServerHealthState.error("hg-message", "description", HealthStateType.general(forMaterial(MaterialsMother.hgMaterial()))));
    SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
    serverHealthService.update(ServerHealthState.error("svn-message", "description", HealthStateType.general(forMaterialConfig(svnMaterialConfig))));
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.addPipeline("defaultGroup", new PipelineConfig(new CaseInsensitiveString("dev"), new MaterialConfigs(svnMaterialConfig), new StageConfig(new CaseInsensitiveString("first"), new JobConfigs())));
    serverHealthService.purgeStaleHealthMessages(cruiseConfig);
    assertThat(serverHealthService.logs().size(), is(1));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)92 Test (org.junit.jupiter.api.Test)60 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)25 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)15 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)11 GoCipher (com.thoughtworks.go.security.GoCipher)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)9 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)8 Test (org.junit.Test)8 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)6 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)5 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 SvnCommand (com.thoughtworks.go.domain.materials.svn.SvnCommand)4 SCMs (com.thoughtworks.go.domain.scm.SCMs)3 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)3 SvnTestRepo (com.thoughtworks.go.helper.SvnTestRepo)3