Search in sources :

Example 81 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method isValidShouldVerifyIfPluginIdIsValid.

@Test
public void isValidShouldVerifyIfPluginIdIsValid() {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("does_not_exist", "1.1");
    Configuration configuration = new Configuration();
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
    pluggableTask.isValid();
    assertThat(pluggableTask.errors().get("pluggable_task").get(0), is("Could not find plugin for given pluggable id:[does_not_exist]."));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 82 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method validateTreeShouldVerifyIfOnCancelTasksHasErrors.

@Test
public void validateTreeShouldVerifyIfOnCancelTasksHasErrors() {
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
    pluggableTask.onCancelConfig = mock(OnCancelConfig.class);
    com.thoughtworks.go.domain.Task cancelTask = mock(com.thoughtworks.go.domain.Task.class);
    when(pluggableTask.onCancelConfig.getTask()).thenReturn(cancelTask);
    when(cancelTask.hasCancelTask()).thenReturn(false);
    when(pluggableTask.onCancelConfig.validateTree(null)).thenReturn(false);
    assertFalse(pluggableTask.validateTree(null));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig) Test(org.junit.Test)

Example 83 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method validateTreeShouldVerifyIfConfigurationHasErrors.

@Test
public void validateTreeShouldVerifyIfConfigurationHasErrors() {
    Configuration configuration = mock(Configuration.class);
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), configuration);
    when(configuration.hasErrors()).thenReturn(true);
    assertFalse(pluggableTask.validateTree(null));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 84 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method shouldPopulateItselfFromConfigAttributesMap.

@Test
public void shouldPopulateItselfFromConfigAttributesMap() throws Exception {
    TaskPreference taskPreference = mock(TaskPreference.class);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
    PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    TaskConfig taskConfig = new TaskConfig();
    TaskProperty property1 = new TaskProperty("KEY1", "value1");
    TaskProperty property2 = new TaskProperty("Key2", "value2");
    taskConfig.addProperty(property1.getName());
    taskConfig.addProperty(property2.getName());
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    task.setTaskConfigAttributes(attributeMap);
    assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
    assertThat(task.configAsMap().get("Key2").get(PluggableTask.VALUE_KEY), is("value2"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskProperty(com.thoughtworks.go.domain.TaskProperty) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 85 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method shouldAddConfigurationPropertiesForAInvalidPlugin.

@Test
public void shouldAddConfigurationPropertiesForAInvalidPlugin() {
    List<ConfigurationProperty> configurationProperties = Arrays.asList(ConfigurationPropertyMother.create("key", "value", "encValue"));
    PluginConfiguration pluginConfiguration = new PluginConfiguration("does_not_exist", "1.1");
    Configuration configuration = new Configuration();
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
    pluggableTask.addConfigurations(configurationProperties);
    assertThat(configuration.size(), is(1));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)136 Test (org.junit.Test)114 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)97 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)29 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)20 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)17 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)17 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)15 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)14 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)12 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)12 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)11 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)11 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)10 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)9