Search in sources :

Example 36 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetAttributesWithSecureFields.

@Test
public void shouldGetAttributesWithSecureFields() {
    PluggableSCMMaterial material = createPluggableSCMMaterialWithSecureConfiguration();
    Map<String, Object> attributes = material.getAttributes(true);
    assertThat(attributes.get("type"), is("scm"));
    assertThat(attributes.get("plugin-id"), is("pluginid"));
    Map<String, Object> configuration = (Map<String, Object>) attributes.get("scm-configuration");
    assertThat(configuration.get("k1"), is("v1"));
    assertThat(configuration.get("k2"), is("v2"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 37 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldUpdateMaterialFromMaterialConfig.

@Test
public void shouldUpdateMaterialFromMaterialConfig() {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    PluggableSCMMaterialConfig materialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig();
    Configuration configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey("new_key"), new ConfigurationValue("new_value")));
    materialConfig.getSCMConfig().setConfiguration(configuration);
    material.updateFromConfig(materialConfig);
    assertThat(material.getScmConfig().getConfiguration().equals(materialConfig.getSCMConfig().getConfiguration()), is(true));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Example 38 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldCreatePluggableSCMMaterialInstance.

@Test
public void shouldCreatePluggableSCMMaterialInstance() {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    PluggableSCMMaterialInstance materialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance();
    assertThat(materialInstance, is(notNullValue()));
    assertThat(materialInstance.getFlyweightName(), is(notNullValue()));
    assertThat(materialInstance.getConfiguration(), is(JsonHelper.toJsonString(material)));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) PluggableSCMMaterialInstance(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance) Test(org.junit.Test)

Example 39 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldCorrectlyGetTypeDisplay.

@Test
public void shouldCorrectlyGetTypeDisplay() {
    PluggableSCMMaterial pluggableSCMMaterial = new PluggableSCMMaterial("scm-id");
    assertThat(pluggableSCMMaterial.getTypeForDisplay(), is("SCM"));
    pluggableSCMMaterial.setSCMConfig(SCMMother.create("scm-id"));
    assertThat(pluggableSCMMaterial.getTypeForDisplay(), is("SCM"));
    SCMMetadataStore.getInstance().addMetadataFor("plugin", null, null);
    assertThat(pluggableSCMMaterial.getTypeForDisplay(), is("SCM"));
    SCMView scmView = mock(SCMView.class);
    when(scmView.displayValue()).thenReturn("scm-name");
    SCMMetadataStore.getInstance().addMetadataFor("plugin", null, scmView);
    assertThat(pluggableSCMMaterial.getTypeForDisplay(), is("scm-name"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCMView(com.thoughtworks.go.plugin.access.scm.SCMView) Test(org.junit.Test)

Example 40 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetSqlCriteria.

@Test
public void shouldGetSqlCriteria() {
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1")));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    Map<String, Object> criteria = material.getSqlCriteria();
    assertThat(criteria.get("type"), is(PluggableSCMMaterial.class.getSimpleName()));
    assertThat(criteria.get("fingerprint"), is(material.getFingerprint()));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Aggregations

PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)64 Test (org.junit.Test)55 SCM (com.thoughtworks.go.domain.scm.SCM)25 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)18 File (java.io.File)13 Modification (com.thoughtworks.go.domain.materials.Modification)11 Modifications (com.thoughtworks.go.domain.materials.Modifications)10 Date (java.util.Date)10 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)9 HashMap (java.util.HashMap)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)7 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)7 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)6 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)6 Map (java.util.Map)6 Material (com.thoughtworks.go.domain.materials.Material)5 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)5 LinkedHashMap (java.util.LinkedHashMap)5 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)4