use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldPopulateEnvironmentContext.
@Test
public void shouldPopulateEnvironmentContext() {
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
ConfigurationProperty k2 = ConfigurationPropertyMother.create("scm-secure", true, "value");
SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1, k2));
PluggableSCMMaterial material = new PluggableSCMMaterial();
material.setSCMConfig(scmConfig);
material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
Modifications modifications = new Modifications(new Modification(null, null, null, new Date(), "revision-123"));
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_SCM_SECURE"), is("value"));
assertThat(environmentVariableContext.getPropertyForDisplay("GO_SCM_TW_DEV_GO_AGENT_SCM_SECURE"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldPopulateEnvironmentContextWithEnvironmentVariablesCreatedOutOfAdditionalDataFromModification.
@Test
public void shouldPopulateEnvironmentContextWithEnvironmentVariablesCreatedOutOfAdditionalDataFromModification() {
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1));
PluggableSCMMaterial material = new PluggableSCMMaterial();
material.setSCMConfig(scmConfig);
material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
HashMap<String, String> map = new HashMap<>();
map.put("MY_NEW_KEY", "my_value");
Modification modification = new Modification("loser", "comment", "email", new Date(), "revision-123", JsonHelper.toJsonString(map));
Modifications modifications = new Modifications(modification);
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_MY_NEW_KEY"), is("my_value"));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class ScmMaterialTest method shouldIncludeMaterialNameInEnvVariableNameIfAvailable.
@Test
public void shouldIncludeMaterialNameInEnvVariableNameIfAvailable() {
EnvironmentVariableContext context = new EnvironmentVariableContext();
material.setVariableWithName(context, "value", "GO_PROPERTY");
assertThat(context.getProperty("GO_PROPERTY"), is("value"));
context = new EnvironmentVariableContext();
material.setName(new CaseInsensitiveString("dummy"));
material.setVariableWithName(context, "value", "GO_PROPERTY");
assertThat(context.getProperty("GO_PROPERTY_" + material.getName().toUpper()), is("value"));
assertThat(context.getProperty("GO_PROPERTY"), is(nullValue()));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class ScmMaterialTest method displayNameShouldReturnNameWhenSet.
@Test
public void displayNameShouldReturnNameWhenSet() throws Exception {
material.setName(new CaseInsensitiveString("blah-name"));
assertThat(material.getDisplayName(), is("blah-name"));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class ModificationBuildCauseTest method shouldReturnBuildCauseMessage.
@Test
public void shouldReturnBuildCauseMessage() {
MaterialRevisions revisions = new MaterialRevisions();
Modification modification = new Modification(new Date(), "pipelineName/123/stageName/1", "MOCK_LABEL-12", null);
revisions.addRevision(new DependencyMaterial(new CaseInsensitiveString("cruise"), new CaseInsensitiveString("dev")), modification);
BuildCause modificationBuildCause = BuildCause.createWithModifications(revisions, "");
String message = modificationBuildCause.getBuildCauseMessage();
assertThat(message, containsString("triggered by pipelineName/123/stageName/1"));
}
Aggregations