Search in sources :

Example 6 with Task

use of com.thoughtworks.go.plugin.api.task.Task in project gocd by gocd.

the class PluggableTaskPreferenceLoaderTest method shouldRemoveConfigForTheTaskCorrespondingToGivenPluginId.

@Test
public void shouldRemoveConfigForTheTaskCorrespondingToGivenPluginId() throws Exception {
    final GoPluginDescriptor descriptor = mock(GoPluginDescriptor.class);
    String pluginId = "test-plugin-id";
    when(descriptor.id()).thenReturn(pluginId);
    final Task task = mock(Task.class);
    TaskConfig config = new TaskConfig();
    TaskView taskView = mock(TaskView.class);
    when(task.config()).thenReturn(config);
    when(task.view()).thenReturn(taskView);
    PluggableTaskConfigStore.store().setPreferenceFor(pluginId, new TaskPreference(task));
    PluginManager pluginManager = mock(PluginManager.class);
    PluggableTaskPreferenceLoader pluggableTaskPreferenceLoader = new PluggableTaskPreferenceLoader(pluginManager, taskExtension);
    assertThat(PluggableTaskConfigStore.store().hasPreferenceFor(pluginId), is(true));
    pluggableTaskPreferenceLoader.pluginUnLoaded(descriptor);
    assertThat(PluggableTaskConfigStore.store().hasPreferenceFor(pluginId), is(false));
    verify(pluginManager).addPluginChangeListener(pluggableTaskPreferenceLoader, Task.class, GoPlugin.class);
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) Task(com.thoughtworks.go.plugin.api.task.Task) TaskView(com.thoughtworks.go.plugin.api.task.TaskView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) Test(org.junit.Test)

Aggregations

Task (com.thoughtworks.go.plugin.api.task.Task)6 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)6 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)6 Test (org.junit.Test)6 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)3 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)3 AntTask (com.thoughtworks.go.config.AntTask)2 TaskProperty (com.thoughtworks.go.domain.TaskProperty)2 Configuration (com.thoughtworks.go.domain.config.Configuration)2 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)2 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)2 Action (com.thoughtworks.go.plugin.infra.Action)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2