Search in sources :

Example 11 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldConvertKeysToLowercaseInGetConfigForDisplay.

@Test
void shouldConvertKeysToLowercaseInGetConfigForDisplay() {
    SCMMetadataStore.getInstance().addMetadataFor("plugin-id", new SCMConfigurations(), null);
    Configuration configuration = new Configuration(create("kEY1", false, "vALue1"), create("KEY_MORE_2", false, "VALUE_2"), create("key_3", false, "value3"));
    SCM scm = SCMMother.create("scm", "scm-name", "plugin-id", "1.0", configuration);
    assertThat(scm.getConfigForDisplay()).isEqualTo("[key1=vALue1, key_more_2=VALUE_2, key_3=value3]");
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 12 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore.

@Test
void shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore() {
    SCMConfigurations scmConfigurations = new SCMConfigurations();
    scmConfigurations.add(new SCMConfiguration("KEY1"));
    SCMPreference scmPreference = mock(SCMPreference.class);
    when(scmPreference.getScmConfigurations()).thenReturn(scmConfigurations);
    SCMMetadataStore.getInstance().setPreferenceFor("plugin-id", scmPreference);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    SCM scm = new SCM("scm-id", new PluginConfiguration("plugin-id", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    scm.setConfigAttributes(attributeMap);
    assertThat(scm.getConfigAsMap().get("KEY1").get(SCM.VALUE_KEY)).isEqualTo("value1");
    assertThat(scm.getConfigAsMap().containsKey("Key2")).isFalse();
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 13 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldNotDisplayEmptyValuesInGetConfigForDisplay.

@Test
void shouldNotDisplayEmptyValuesInGetConfigForDisplay() {
    SCMMetadataStore.getInstance().addMetadataFor("plugin-id", new SCMConfigurations(), null);
    Configuration configuration = new Configuration(create("rk1", false, ""), create("rk2", false, "some-non-empty-value"), create("rk3", false, null));
    SCM scm = SCMMother.create("scm", "scm-name", "plugin-id", "1.0", configuration);
    assertThat(scm.getConfigForDisplay()).isEqualTo("[rk2=some-non-empty-value]");
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 14 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldNotOverwriteValuesIfTheyAreNotAvailableInConfigAttributesMap.

@Test
void shouldNotOverwriteValuesIfTheyAreNotAvailableInConfigAttributesMap() {
    SCMConfigurations scmConfigurations = new SCMConfigurations();
    scmConfigurations.add(new SCMConfiguration("KEY1"));
    scmConfigurations.add(new SCMConfiguration("Key2"));
    SCMPreference scmPreference = mock(SCMPreference.class);
    when(scmPreference.getScmConfigurations()).thenReturn(scmConfigurations);
    SCMMetadataStore.getInstance().setPreferenceFor("plugin-id", scmPreference);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
    SCM scm = new SCM("scm-id", new PluginConfiguration("plugin-id", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1");
    scm.setConfigAttributes(attributeMap);
    assertThat(scm.getConfigAsMap().get("KEY1").get(SCM.VALUE_KEY)).isEqualTo("value1");
    assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY)).isNull();
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 15 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldReturnSomethingMoreSaneForToString.

@Test
void shouldReturnSomethingMoreSaneForToString() throws Exception {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    SCMMetadataStore.getInstance().addMetadataFor(material.getPluginId(), new SCMConfigurations(), null);
    assertThat(material.toString()).isEqualTo("'PluggableSCMMaterial{[k1=v1, k2=v2]}'");
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Aggregations

SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)16 Test (org.junit.jupiter.api.Test)12 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)11 SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)6 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)2 SCMProperty (com.thoughtworks.go.plugin.access.scm.SCMProperty)2 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 Before (org.junit.Before)2 Configuration (com.thoughtworks.go.domain.config.Configuration)1 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)1 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)1 SCM (com.thoughtworks.go.domain.scm.SCM)1 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)1 JsonBasedPluggableTask (com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask)1 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)1 SCMView (com.thoughtworks.go.plugin.access.scm.SCMView)1 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)1 GoCipher (com.thoughtworks.go.security.GoCipher)1