Search in sources :

Example 26 with Configuration

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

the class PluggableTaskTest method shouldReturnFalseWhenPluggableTaskIsComparedWithAnyOtherTask.

@Test
public void shouldReturnFalseWhenPluggableTaskIsComparedWithAnyOtherTask() {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("test-plugin-1", "1.0");
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, new Configuration());
    AntTask antTask = new AntTask();
    assertFalse(pluggableTask.hasSameTypeAs(antTask));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) AntTask(com.thoughtworks.go.config.AntTask) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 27 with Configuration

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

the class PluggableTaskTest method shouldAddConfigurationProperties.

@Test
public void shouldAddConfigurationProperties() {
    List<ConfigurationProperty> configurationProperties = Arrays.asList(ConfigurationPropertyMother.create("key", "value", "encValue"), new ConfigurationProperty());
    PluginConfiguration pluginConfiguration = new PluginConfiguration("github.pr", "1.1");
    TaskPreference taskPreference = mock(TaskPreference.class);
    TaskConfig taskConfig = new TaskConfig();
    Configuration configuration = new Configuration();
    Property property = new Property("key");
    property.with(Property.SECURE, false);
    PluggableTaskConfigStore.store().setPreferenceFor(pluginConfiguration.getId(), taskPreference);
    TaskConfigProperty taskConfigProperty = taskConfig.addProperty("key");
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
    pluggableTask.addConfigurations(configurationProperties);
    assertThat(configuration.size(), is(2));
}
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) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) TaskProperty(com.thoughtworks.go.domain.TaskProperty) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) Property(com.thoughtworks.go.plugin.api.config.Property) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 28 with Configuration

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

the class PluggableTaskTest method shouldGetOnlyConfiguredPropertiesIfACertainPropertyDefinedByPluginIsNotConfiguredByUser.

@Test
public void shouldGetOnlyConfiguredPropertiesIfACertainPropertyDefinedByPluginIsNotConfiguredByUser() throws Exception {
    Task taskDetails = mock(Task.class);
    TaskConfig taskConfig = new TaskConfig();
    addProperty(taskConfig, "KEY2", "Key 2", 1);
    addProperty(taskConfig, "KEY1", "Key 1", 0);
    addProperty(taskConfig, "KEY3", "Key 3", 2);
    when(taskDetails.config()).thenReturn(taskConfig);
    when(taskDetails.view()).thenReturn(mock(TaskView.class));
    String pluginId = "plugin_with_all_details";
    PluggableTaskConfigStore.store().setPreferenceFor(pluginId, new TaskPreference(taskDetails));
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1", false, "value1"), ConfigurationPropertyMother.create("KEY2", false, "value2"));
    PluggableTask task = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
    List<TaskProperty> propertiesForDisplay = task.getPropertiesForDisplay();
    assertThat(propertiesForDisplay.size(), is(2));
    assertProperty(propertiesForDisplay.get(0), "Key 1", "value1", "key1");
    assertProperty(propertiesForDisplay.get(1), "Key 2", "value2", "key2");
}
Also used : Task(com.thoughtworks.go.plugin.api.task.Task) AntTask(com.thoughtworks.go.config.AntTask) TaskView(com.thoughtworks.go.plugin.api.task.TaskView) 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 29 with Configuration

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

the class PluggableSCMMaterialConfigTest method shouldGetNameFromSCMName.

@Test
public void shouldGetNameFromSCMName() {
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig();
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(create("k1", false, "v1")));
    pluggableSCMMaterialConfig.setSCMConfig(scmConfig);
    assertThat(pluggableSCMMaterialConfig.getName().toString(), is("scm-name"));
    pluggableSCMMaterialConfig.setSCMConfig(null);
    assertThat(pluggableSCMMaterialConfig.getName(), is(nullValue()));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 30 with Configuration

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

the class PluggableSCMMaterialConfigTest method shouldCheckEquals.

@Test
public void shouldCheckEquals() throws Exception {
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(create("k1", false, "v1")));
    // same fingerprint
    PluggableSCMMaterialConfig p1 = new PluggableSCMMaterialConfig();
    p1.setSCMConfig(scmConfig);
    PluggableSCMMaterialConfig p2 = new PluggableSCMMaterialConfig();
    p2.setSCMConfig(scmConfig);
    assertThat(p1.equals(p2), is(true));
    // folder
    p2.setFolder("dest");
    assertThat(p1.equals(p2), is(false));
    // scmConfig null
    p1 = new PluggableSCMMaterialConfig();
    p2 = new PluggableSCMMaterialConfig();
    assertThat(p1.equals(p2), is(true));
    p2.setSCMConfig(scmConfig);
    assertThat(p1.equals(p2), is(false));
    p1.setSCMConfig(scmConfig);
    p2 = new PluggableSCMMaterialConfig();
    assertThat(p1.equals(p2), is(false));
    p2.setSCMConfig(scmConfig);
    assertThat(p1.equals(p2), is(true));
    // null comparison
    assertThat(p1.equals(null), is(false));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)134 Test (org.junit.Test)116 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)95 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)28 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