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"));
}
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));
}
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)));
}
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"));
}
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()));
}
Aggregations