Search in sources :

Example 81 with PluginConfiguration

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

the class SCMRepresenter method fromJSON.

public static SCM fromJSON(JsonReader jsonReader, boolean mustHaveId) {
    String id = mustHaveId ? jsonReader.getString("id") : jsonReader.getStringOrDefault("id", null);
    String name = jsonReader.getString("name");
    boolean autoUpdate = jsonReader.getBooleanOrDefault("auto_update", true);
    SCM scm = new SCM(id, name);
    scm.setAutoUpdate(autoUpdate);
    if (jsonReader.hasJsonObject("plugin_metadata")) {
        PluginConfiguration pluginMetadata = PluginConfigurationRepresenter.fromJSON(jsonReader.readJsonObject("plugin_metadata"));
        scm.setPluginConfiguration(pluginMetadata);
    }
    if (jsonReader.hasJsonArray("configuration")) {
        Configuration configuration = new Configuration(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "configuration"));
        scm.addConfigurations(configuration);
    }
    return scm;
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM)

Example 82 with PluginConfiguration

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

the class PluggableTaskRepresenter method fromJSON.

public static PluggableTask fromJSON(JsonReader jsonReader) {
    PluggableTask pluggableTask = new PluggableTask();
    if (jsonReader == null) {
        return pluggableTask;
    }
    BaseTaskRepresenter.fromJSON(jsonReader, pluggableTask);
    PluginConfiguration pluginConfiguration = PluginConfigurationRepresenter.fromJSON(jsonReader.readJsonObject("plugin_configuration"));
    pluggableTask.setPluginConfiguration(pluginConfiguration);
    pluggableTask.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "configuration"));
    return pluggableTask;
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask)

Example 83 with PluginConfiguration

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

the class PluggableTaskBuilder method extractFrom.

private void extractFrom(PluggableTask task) {
    PluginConfiguration pluginConfiguration = task.getPluginConfiguration();
    pluginId = pluginConfiguration.getId();
    pluginConfig = task.configAsMap();
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration)

Example 84 with PluginConfiguration

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

the class PluggableTaskRepresenter method fromJSON.

public static PluggableTask fromJSON(JsonReader jsonReader) {
    PluggableTask pluggableTask = new PluggableTask();
    if (jsonReader == null) {
        return pluggableTask;
    }
    BaseTaskRepresenter.fromJSON(jsonReader, pluggableTask);
    PluginConfiguration pluginConfiguration = PluginConfigurationRepresenter.fromJSON(jsonReader.readJsonObject("plugin_configuration"));
    pluggableTask.setPluginConfiguration(pluginConfiguration);
    pluggableTask.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "configuration"));
    return pluggableTask;
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask)

Example 85 with PluginConfiguration

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

the class PluggableTaskBuilderTest method shouldReturnDefaultValueInExecConfigWhenConfigValueIsNull.

@Test
public void shouldReturnDefaultValueInExecConfigWhenConfigValueIsNull() throws Exception {
    TaskConfig defaultTaskConfig = new TaskConfig();
    String propertyName = "URL";
    String defaultValue = "ABC.TXT";
    Map<String, Map<String, String>> configMap = new HashMap<>();
    configMap.put(propertyName, null);
    PluggableTask task = mock(PluggableTask.class);
    when(task.getPluginConfiguration()).thenReturn(new PluginConfiguration());
    when(task.configAsMap()).thenReturn(configMap);
    PluggableTaskBuilder taskBuilder = new PluggableTaskBuilder(runIfConfigs, cancelBuilder, task, TEST_PLUGIN_ID, "test-directory");
    defaultTaskConfig.addProperty(propertyName).withDefault(defaultValue);
    TaskConfig config = taskBuilder.buildTaskConfig(defaultTaskConfig);
    assertThat(config.getValue(propertyName), is(defaultValue));
}
Also used : HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) HashMap(java.util.HashMap) Map(java.util.Map) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.jupiter.api.Test)

Aggregations

PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)88 Configuration (com.thoughtworks.go.domain.config.Configuration)63 Test (org.junit.jupiter.api.Test)61 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)29 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)23 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)13 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)9 Test (org.junit.Test)9 TaskProperty (com.thoughtworks.go.domain.TaskProperty)8 Map (java.util.Map)8 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)6 HashMap (java.util.HashMap)5 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4 Result (com.thoughtworks.go.plugin.api.response.Result)4 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 AntTask (com.thoughtworks.go.config.AntTask)3