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