Search in sources :

Example 1 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class GoConfigMaterialsTest method shouldHaveBothMaterialsIfTheTypeIsDifferent.

@Test
public void shouldHaveBothMaterialsIfTheTypeIsDifferent() {
    SvnMaterialConfig svn = MaterialConfigsMother.svnMaterialConfig("url", "folder1", true);
    HgMaterialConfig hg = MaterialConfigsMother.hgMaterialConfig("url", "folder2");
    PipelineConfig pipeline1 = new PipelineConfig(new CaseInsensitiveString("pipeline1"), new MaterialConfigs(svn));
    PipelineConfig pipeline2 = new PipelineConfig(new CaseInsensitiveString("pipeline2"), new MaterialConfigs(hg));
    CruiseConfig config = new BasicCruiseConfig(new BasicPipelineConfigs(pipeline1, pipeline2));
    assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines().size(), is(2));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 2 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class CachedGoConfigIntegrationTest method shouldLoadConfigForReadAndEditWhenNewXMLIsWritten.

@Test
public void shouldLoadConfigForReadAndEditWhenNewXMLIsWritten() throws Exception {
    String pipelineName = "mingle";
    cachedGoConfig.save(configXmlWithPipeline(pipelineName), false);
    PipelineConfig reloadedPipelineConfig = cachedGoConfig.currentConfig().pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) byFolder(reloadedPipelineConfig.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://hg-server/repo-name"));
    reloadedPipelineConfig = cachedGoConfig.loadForEditing().pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    hgMaterialConfig = (HgMaterialConfig) byFolder(reloadedPipelineConfig.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://#{foo}/#{bar}"));
    GoConfigHolder configHolder = cachedGoConfig.loadConfigHolder();
    reloadedPipelineConfig = configHolder.config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    hgMaterialConfig = (HgMaterialConfig) byFolder(reloadedPipelineConfig.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://hg-server/repo-name"));
    reloadedPipelineConfig = configHolder.configForEdit.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    hgMaterialConfig = (HgMaterialConfig) byFolder(reloadedPipelineConfig.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://#{foo}/#{bar}"));
}
Also used : HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) StringContains.containsString(org.hamcrest.core.StringContains.containsString)

Example 3 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class CachedGoConfigIntegrationTest method shouldLoadConfigForReadAndEditWhenConfigIsUpdatedThoughACommand.

@Test
public void shouldLoadConfigForReadAndEditWhenConfigIsUpdatedThoughACommand() throws Exception {
    cachedGoConfig.writeWithLock(new UpdateConfigCommand() {

        public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
            addPipelineWithParams(cruiseConfig);
            return cruiseConfig;
        }
    });
    PipelineConfig reloadedPipelineConfig = cachedGoConfig.currentConfig().pipelineConfigByName(new CaseInsensitiveString("mingle"));
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) byFolder(reloadedPipelineConfig.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://hg-server/repo-name"));
    reloadedPipelineConfig = cachedGoConfig.loadForEditing().pipelineConfigByName(new CaseInsensitiveString("mingle"));
    hgMaterialConfig = (HgMaterialConfig) byFolder(reloadedPipelineConfig.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://#{foo}/#{bar}"));
}
Also used : HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException)

Example 4 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class CachedGoConfigIntegrationTest method shouldGetConfigForEditAndRead.

@Test
public void shouldGetConfigForEditAndRead() throws Exception {
    CruiseConfig cruiseConfig = configHelper.load();
    addPipelineWithParams(cruiseConfig);
    configHelper.writeConfigFile(cruiseConfig);
    PipelineConfig config = cachedGoConfig.currentConfig().pipelineConfigByName(new CaseInsensitiveString("mingle"));
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) byFolder(config.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://hg-server/repo-name"));
    config = cachedGoConfig.loadForEditing().pipelineConfigByName(new CaseInsensitiveString("mingle"));
    hgMaterialConfig = (HgMaterialConfig) byFolder(config.materialConfigs(), "folder");
    Assert.assertThat(hgMaterialConfig.getUrl(), Matchers.is("http://#{foo}/#{bar}"));
}
Also used : HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)

Example 5 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class BuildCauseProducerServiceTest method shouldAllowTriggeringOfPipelineAfterMaterialUpdate.

@Test
public void shouldAllowTriggeringOfPipelineAfterMaterialUpdate() throws Exception {
    HgMaterial hgMaterial = new HgMaterial("url", null);
    HgMaterialConfig hgMaterialConfig = new HgMaterialConfig("url", null);
    pipelineConfig.addMaterialConfig(hgMaterialConfig);
    when(materialConfigConverter.toMaterial(hgMaterialConfig)).thenReturn(hgMaterial);
    when(specificMaterialRevisionFactory.create("pipeline", new HashMap<>())).thenReturn(new MaterialRevisions());
    when(pipelineScheduleQueue.mostRecentScheduled(CaseInsensitiveString.str(pipelineConfig.name()))).thenReturn(BuildCause.createNeverRun());
    when(materialRepository.findLatestModification(hgMaterial)).thenReturn(new MaterialRevisions(new MaterialRevision(hgMaterial, new ArrayList<>())));
    buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(), new ServerHealthStateOperationResult());
    assertThat(triggerMonitor.isAlreadyTriggered(CaseInsensitiveString.str(pipelineConfig.name())), is(true));
    sendMaterialUpdateCompleteMessage(extractMaterialListenerInstanceFromRegisterCall(), hgMaterial);
    assertThat(triggerMonitor.isAlreadyTriggered(CaseInsensitiveString.str(pipelineConfig.name())), is(false));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Aggregations

HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)71 Test (org.junit.Test)60 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)15 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)11 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)11 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)8 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)8 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)7 HashMap (java.util.HashMap)7 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)6 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)6 MaterialUpdateStatusListener (com.thoughtworks.go.server.materials.MaterialUpdateStatusListener)5 Filter (com.thoughtworks.go.config.materials.Filter)4 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)4 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)4