Search in sources :

Example 26 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class GoPartialConfigTest method shouldRemovePartialWhenNoLongerInWatchList.

@Test
public void shouldRemovePartialWhenNoLongerInWatchList() throws Exception {
    ScmMaterialConfig material = setOneConfigRepo();
    PartialConfig part = new PartialConfig();
    when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
    repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
    assertThat(partialConfig.lastPartials().size(), is(1));
    assertThat(partialConfig.lastPartials().get(0), is(part));
    // we change current configuration
    ScmMaterialConfig othermaterial = new GitMaterialConfig("http://myother.git");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(othermaterial, "myplugin")));
    configWatchList.onConfigChange(cruiseConfig);
    assertThat(partialConfig.lastPartials().size(), is(0));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) File(java.io.File) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 27 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class GoPartialConfigTest method shouldNotifyListenersAfterUpdatingMapOfLatestValidConfig.

@Test
public void shouldNotifyListenersAfterUpdatingMapOfLatestValidConfig() {
    ScmMaterialConfig material = setOneConfigRepo();
    PartialConfig part = new PartialConfig();
    when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
    PartialConfigUpdateCompletedListener listener = mock(PartialConfigUpdateCompletedListener.class);
    repoConfigDataSource.registerListener(listener);
    repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
    verify(listener, times(1)).onSuccessPartialConfig(any(ConfigRepoConfig.class), any(PartialConfig.class));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) File(java.io.File) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 28 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldSetConfigOriginInCruiseConfig_AfterLoadingConfigFile.

@Test
public void shouldSetConfigOriginInCruiseConfig_AfterLoadingConfigFile() throws Exception {
    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(ConfigFileFixture.CONFIG, new MagicalGoConfigXmlLoader.Callback() {

        @Override
        public void call(CruiseConfig cruiseConfig) {
            cruiseConfig.setPartials(asList(new PartialConfig()));
        }
    });
    assertThat(goConfigHolder.config.getOrigin(), Is.<ConfigOrigin>is(new MergeConfigOrigin()));
    assertThat(goConfigHolder.configForEdit.getOrigin(), Is.<ConfigOrigin>is(new FileConfigOrigin()));
}
Also used : MergeConfigOrigin(com.thoughtworks.go.config.merge.MergeConfigOrigin) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) Test(org.junit.Test)

Example 29 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldLoadPartialConfigWithEnvironment.

@Test
public void shouldLoadPartialConfigWithEnvironment() throws Exception {
    String partialConfigWithPipeline = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>\n" + "<environments>" + "  <environment name='uat'>" + "    <agents>" + "      <physical uuid='1'/>" + "      <physical uuid='2'/>" + "    </agents>" + "  </environment>" + "  <environment name='prod'>" + "    <agents>" + "      <physical uuid='2'/>" + "    </agents>" + "  </environment>" + "</environments>" + "</cruise>\n";
    PartialConfig partialConfig = xmlLoader.fromXmlPartial(toInputStream(partialConfigWithPipeline), PartialConfig.class);
    EnvironmentsConfig environmentsConfig = partialConfig.getEnvironments();
    assertThat(environmentsConfig.size(), is(2));
    EnvironmentPipelineMatchers matchers = environmentsConfig.matchers();
    assertThat(matchers.size(), is(2));
    ArrayList<String> uat_uuids = new ArrayList<String>() {

        {
            add("1");
            add("2");
        }
    };
    ArrayList<String> prod_uuids = new ArrayList<String>() {

        {
            add("2");
        }
    };
    assertThat(matchers, hasItem(new EnvironmentPipelineMatcher(new CaseInsensitiveString("uat"), uat_uuids, new EnvironmentPipelinesConfig())));
    assertThat(matchers, hasItem(new EnvironmentPipelineMatcher(new CaseInsensitiveString("prod"), prod_uuids, new EnvironmentPipelinesConfig())));
}
Also used : ArrayList(java.util.ArrayList) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 30 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldLoadPartialConfigWithPipeline.

@Test
public void shouldLoadPartialConfigWithPipeline() throws Exception {
    String partialConfigWithPipeline = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>\n" + "<pipelines group=\"first\">\n" + "<pipeline name=\"pipeline\">\n" + "  <materials>\n" + "    <hg url=\"/hgrepo\"/>\n" + "  </materials>\n" + "  <stage name=\"mingle\">\n" + "    <jobs>\n" + "      <job name=\"functional\">\n" + "        <artifacts>\n" + "          <log src=\"artifact1.xml\" dest=\"cruise-output\" />\n" + "        </artifacts>\n" + "      </job>\n" + "    </jobs>\n" + "  </stage>\n" + "</pipeline>\n" + "</pipelines>\n" + "</cruise>\n";
    PartialConfig partialConfig = xmlLoader.fromXmlPartial(toInputStream(partialConfigWithPipeline), PartialConfig.class);
    assertThat(partialConfig.getGroups().size(), is(1));
    PipelineConfig pipeline = partialConfig.getGroups().get(0).getPipelines().get(0);
    assertThat(pipeline.name(), is(new CaseInsensitiveString("pipeline")));
    assertThat(pipeline.size(), is(1));
    assertThat(pipeline.findBy(new CaseInsensitiveString("mingle")).jobConfigByInstanceName("functional", true), is(notNullValue()));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)66 Test (org.junit.Test)40 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)28 File (java.io.File)15 StringContains.containsString (org.hamcrest.core.StringContains.containsString)12 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)11 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)10 IOException (java.io.IOException)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 ExpectedException (org.junit.rules.ExpectedException)8 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)7 Cloner (com.rits.cloning.Cloner)6 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)6 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)5 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)4 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)4 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)4 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)4 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 Arrays.asList (java.util.Arrays.asList)3