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