Search in sources :

Example 1 with TaskProperty

use of com.thoughtworks.go.domain.TaskProperty in project gocd by gocd.

the class FetchTask method getPropertiesForDisplay.

public List<TaskProperty> getPropertiesForDisplay() {
    ArrayList<TaskProperty> taskProperties = new ArrayList<>();
    if (pipelineName != null && !CaseInsensitiveString.isBlank(pipelineName.getPath())) {
        taskProperties.add(new TaskProperty("PIPELINE_NAME", CaseInsensitiveString.str(pipelineName.getPath())));
    }
    taskProperties.add(new TaskProperty("STAGE_NAME", CaseInsensitiveString.str(stage)));
    taskProperties.add(new TaskProperty("JOB_NAME", job.toString()));
    if (!StringUtil.isBlank(srcfile)) {
        taskProperties.add(new TaskProperty("SRC_FILE", srcfile));
    }
    if (!StringUtil.isBlank(srcdir)) {
        taskProperties.add(new TaskProperty("SRC_DIR", srcdir));
    }
    if (!StringUtil.isBlank(dest)) {
        taskProperties.add(new TaskProperty("DEST_FILE", dest));
    }
    return taskProperties;
}
Also used : ArrayList(java.util.ArrayList) TaskProperty(com.thoughtworks.go.domain.TaskProperty)

Example 2 with TaskProperty

use of com.thoughtworks.go.domain.TaskProperty in project gocd by gocd.

the class AbstractFetchTask method getPropertiesForDisplay.

@Override
public List<TaskProperty> getPropertiesForDisplay() {
    List<TaskProperty> taskProperties = new ArrayList<>();
    if (pipelineName != null && !CaseInsensitiveString.isBlank(pipelineName.getPath())) {
        taskProperties.add(new TaskProperty("Pipeline Name", CaseInsensitiveString.str(pipelineName.getPath())));
    }
    taskProperties.add(new TaskProperty("Stage Name", CaseInsensitiveString.str(stage)));
    taskProperties.add(new TaskProperty("Job Name", job.toString()));
    return taskProperties;
}
Also used : TaskProperty(com.thoughtworks.go.domain.TaskProperty) ArrayList(java.util.ArrayList)

Example 3 with TaskProperty

use of com.thoughtworks.go.domain.TaskProperty in project gocd by gocd.

the class PluggableTaskTest method shouldPopulatePropertiesForDisplayRetainingOrderAndDisplayNameIfConfigured.

@Test
public void shouldPopulatePropertiesForDisplayRetainingOrderAndDisplayNameIfConfigured() 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("KEY3", true, "encryptedValue1"), 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(3));
    assertProperty(propertiesForDisplay.get(0), "Key 1", "value1", "key1");
    assertProperty(propertiesForDisplay.get(1), "Key 2", "value2", "key2");
    assertProperty(propertiesForDisplay.get(2), "Key 3", "****", "key3");
}
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.jupiter.api.Test)

Example 4 with TaskProperty

use of com.thoughtworks.go.domain.TaskProperty in project gocd by gocd.

the class PluggableTaskTest method shouldNotOverwriteValuesIfTheyAreNotAvailableInConfigAttributesMap.

@Test
public void shouldNotOverwriteValuesIfTheyAreNotAvailableInConfigAttributesMap() 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");
    TaskConfig taskConfig = new TaskConfig();
    TaskProperty property1 = new TaskProperty("KEY1", "value1");
    TaskProperty property2 = new TaskProperty("Key2", null);
    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(nullValue()));
}
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.jupiter.api.Test)

Example 5 with TaskProperty

use of com.thoughtworks.go.domain.TaskProperty 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.jupiter.api.Test)

Aggregations

TaskProperty (com.thoughtworks.go.domain.TaskProperty)13 Test (org.junit.jupiter.api.Test)9 Configuration (com.thoughtworks.go.domain.config.Configuration)7 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)7 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)7 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)6 ArrayList (java.util.ArrayList)3 AntTask (com.thoughtworks.go.config.AntTask)2 Task (com.thoughtworks.go.plugin.api.task.Task)2 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)1 Property (com.thoughtworks.go.plugin.api.config.Property)1 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)1