Search in sources :

Example 66 with PluginConfiguration

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

the class SCMsTest method shouldFindFunctionallyDuplicateSCMs.

@Test
void shouldFindFunctionallyDuplicateSCMs() {
    Configuration config = new Configuration();
    config.addNewConfigurationWithValue("url", "url", false);
    PluginConfiguration pluginConfig = new PluginConfiguration("plugin_id", "1.0");
    SCM scm1 = new SCM("scmid", pluginConfig, config);
    scm1.setName("noName");
    SCMs scms = new SCMs(scm1);
    SCM scm2 = new SCM("scmid", new PluginConfiguration(), new Configuration());
    SCM scm3 = new SCM("id", pluginConfig, config);
    assertThat(scms.findDuplicate(scm2)).isEqualTo(scm1);
    assertThat(scms.findDuplicate(scm3)).isEqualTo(scm1);
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 67 with PluginConfiguration

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

the class PluggableTaskViewModelFactoryTest method dataForViewShouldBeGotFromTheTaskInJSONFormat.

@Test
public void dataForViewShouldBeGotFromTheTaskInJSONFormat() throws Exception {
    Configuration configuration = new Configuration(create("key1", false, "value1"), create("KEY2", false, "value2"));
    PluggableTask taskConfig = new PluggableTask(new PluginConfiguration("plugin-1", "2"), configuration);
    PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
    PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(taskConfig, "new");
    String actualData = (String) viewModel.getParameters().get("data");
    Gson gson = new Gson();
    Map actual = gson.fromJson(actualData, Map.class);
    Map expected = gson.fromJson("{\"KEY2\":{\"value\":\"value2\"},\"key1\":{\"value\":\"value1\"}}", Map.class);
    assertEquals(expected, actual);
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Gson(com.google.gson.Gson) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 68 with PluginConfiguration

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

the class PluggableTaskViewModelFactoryTest method getModelWithTaskTemplateHavingValue.

private PluggableViewModel<PluggableTask> getModelWithTaskTemplateHavingValue(final String templateContentValue) {
    when(taskPreference.getView()).thenReturn(new TaskView() {

        @Override
        public String displayValue() {
            return "view";
        }

        @Override
        public String template() {
            return templateContentValue;
        }
    });
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin-1", "2"), new Configuration());
    PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
    return factory.viewModelFor(pluggableTask, "new");
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask)

Example 69 with PluginConfiguration

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

the class PluggableTaskViewModelFactoryTest method assertPluggableViewModel.

private void assertPluggableViewModel(String actionName, String expectedTemplatePath) {
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin-1", "2"), new Configuration());
    PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
    PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(pluggableTask, actionName);
    assertThat(viewModel.getModel(), is(pluggableTask));
    assertThat(viewModel.getTaskType(), is("pluggable_task_plugin_1"));
    assertThat(viewModel.getTemplatePath(), is(expectedTemplatePath));
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask)

Example 70 with PluginConfiguration

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

the class ConfigElementImplementationRegistrarTest method shouldRegisterViewEngineForPluggableTask.

@Test
public void shouldRegisterViewEngineForPluggableTask() {
    TaskPreference taskPreference = mock(TaskPreference.class);
    TaskView view = mock(TaskView.class);
    when(taskPreference.getView()).thenReturn(view);
    when(view.template()).thenReturn("plugin-template-value");
    when(view.displayValue()).thenReturn("Plugin display value");
    PluggableTaskConfigStore.store().setPreferenceFor("plugin1", taskPreference);
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin1", "2"), new Configuration());
    PluggableViewModel<PluggableTask> pluggableTaskViewModel = registry.getViewModelFor(pluggableTask, "new");
    assertEquals(PluggableTaskViewModel.class, pluggableTaskViewModel.getClass());
    assertThat(pluggableTaskViewModel.getModel(), is(pluggableTask));
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) 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