本文整理汇总了Java中com.thoughtworks.go.plugin.api.GoPlugin类的典型用法代码示例。如果您正苦于以下问题:Java GoPlugin类的具体用法?Java GoPlugin怎么用?Java GoPlugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GoPlugin类属于com.thoughtworks.go.plugin.api包,在下文中一共展示了GoPlugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldRemoveConfigForTheTaskCorrespondingToGivenPluginId
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@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);
}
示例2: PluginsZip
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Autowired
public PluginsZip(SystemEnvironment systemEnvironment, PluginManager pluginManager) {
destZipFile = new File(systemEnvironment.get(SystemEnvironment.ALL_PLUGINS_ZIP_PATH));
bundledPlugins = new File(systemEnvironment.get(SystemEnvironment.PLUGIN_GO_PROVIDED_PATH));
externalPlugins = new File(systemEnvironment.get(SystemEnvironment.PLUGIN_EXTERNAL_PROVIDED_PATH));
this.pluginManager = pluginManager;
this.pluginManager.addPluginChangeListener(this, GoPlugin.class);
predicate = new Predicate<GoPluginDescriptor>() {
@Override
public boolean test(GoPluginDescriptor goPluginDescriptor) {
return PluginsZip.this.pluginManager.isPluginOfType("task", goPluginDescriptor.id()) ||
PluginsZip.this.pluginManager.isPluginOfType("scm", goPluginDescriptor.id()) ||
PluginsZip.this.pluginManager.isPluginOfType("package-repository", goPluginDescriptor.id()) ||
PluginsZip.this.pluginManager.isPluginOfType("artifact", goPluginDescriptor.id());
}
};
}
示例3: submitTo
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Override
public GoPluginApiResponse submitTo(final String pluginId, final GoPluginApiRequest apiRequest) {
return goPluginOSGiFramework.doOn(GoPlugin.class, pluginId, new ActionWithReturn<GoPlugin, GoPluginApiResponse>() {
@Override
public GoPluginApiResponse execute(GoPlugin plugin, GoPluginDescriptor pluginDescriptor) {
ensureInitializerInvoked(pluginDescriptor, plugin);
try {
return plugin.handle(apiRequest);
} catch (UnhandledRequestTypeException e) {
LOGGER.error(e.getMessage());
LOGGER.debug(e.getMessage(), e);
throw new RuntimeException(e);
}
}
});
}
示例4: resolveExtensionVersion
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Override
public String resolveExtensionVersion(String pluginId, final List<String> goSupportedExtensionVersions) {
String resolvedExtensionVersion = doOn(GoPlugin.class, pluginId, new ActionWithReturn<GoPlugin, String>() {
@Override
public String execute(GoPlugin goPlugin, GoPluginDescriptor pluginDescriptor) {
List<String> pluginSupportedVersions = goPlugin.pluginIdentifier().getSupportedExtensionVersions();
String currentMaxVersion = "0";
for (String pluginSupportedVersion : pluginSupportedVersions) {
if (goSupportedExtensionVersions.contains(pluginSupportedVersion) && parseDouble(currentMaxVersion) < parseDouble(pluginSupportedVersion)) {
currentMaxVersion = pluginSupportedVersion;
}
}
return currentMaxVersion;
}
});
if ("0".equals(resolvedExtensionVersion)) {
throw new RuntimeException(String.format("Could not find matching extension version between Plugin[%s] and Go", pluginId));
}
return resolvedExtensionVersion;
}
示例5: shouldSubmitPluginApiRequestToGivenPlugin
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldSubmitPluginApiRequestToGivenPlugin() throws Exception {
GoPluginApiRequest request = mock(GoPluginApiRequest.class);
GoPluginApiResponse expectedResponse = mock(GoPluginApiResponse.class);
final GoPlugin goPlugin = mock(GoPlugin.class);
final GoPluginDescriptor descriptor = mock(GoPluginDescriptor.class);
when(goPlugin.handle(request)).thenReturn(expectedResponse);
ArgumentCaptor<PluginAwareDefaultGoApplicationAccessor> captor = ArgumentCaptor.forClass(PluginAwareDefaultGoApplicationAccessor.class);
doNothing().when(goPlugin).initializeGoApplicationAccessor(captor.capture());
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
ActionWithReturn<GoPlugin, GoPluginApiResponse> action = (ActionWithReturn<GoPlugin, GoPluginApiResponse>) invocationOnMock.getArguments()[2];
return action.execute(goPlugin, descriptor);
}
}).when(goPluginOSGiFramework).doOn(eq(GoPlugin.class), eq("plugin-id"), any(ActionWithReturn.class));
DefaultPluginManager pluginManager = new DefaultPluginManager(monitor, registry, goPluginOSGiFramework, jarChangeListener, pluginRequestProcessorRegistry, pluginWriter, pluginValidator, systemEnvironment);
GoPluginApiResponse actualResponse = pluginManager.submitTo("plugin-id", request);
assertThat(actualResponse, is(expectedResponse));
PluginAwareDefaultGoApplicationAccessor accessor = captor.getValue();
assertThat(accessor.pluginDescriptor(), is(descriptor));
}
示例6: shouldReturnTrueIfPluginIsOfGivenExtensionWhenReferenceFoundAndExtensionMatch
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldReturnTrueIfPluginIsOfGivenExtensionWhenReferenceFoundAndExtensionMatch() throws Exception {
String pluginId = "plugin-id";
GoPluginIdentifier pluginIdentifier = new GoPluginIdentifier("sample-extension", asList("1.0"));
final GoPlugin goPlugin = mock(GoPlugin.class);
final GoPluginDescriptor descriptor = mock(GoPluginDescriptor.class);
when(goPluginOSGiFramework.hasReferenceFor(GoPlugin.class, pluginId)).thenReturn(true);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
ActionWithReturn<GoPlugin, GoPluginApiResponse> action = (ActionWithReturn<GoPlugin, GoPluginApiResponse>) invocationOnMock.getArguments()[2];
return action.execute(goPlugin, descriptor);
}
}).when(goPluginOSGiFramework).doOn(eq(GoPlugin.class), eq(pluginId), any(ActionWithReturn.class));
when(goPlugin.pluginIdentifier()).thenReturn(pluginIdentifier);
DefaultPluginManager pluginManager = new DefaultPluginManager(monitor, registry, goPluginOSGiFramework, jarChangeListener, pluginRequestProcessorRegistry, pluginWriter, pluginValidator, systemEnvironment);
assertTrue(pluginManager.isPluginOfType("sample-extension", pluginId));
}
示例7: shouldNotFindPluginIsOfGivenExtensionWhenReferenceNotFoundAndExtensionDoNotMatch
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldNotFindPluginIsOfGivenExtensionWhenReferenceNotFoundAndExtensionDoNotMatch() throws Exception {
final String pluginThatDoesNotImplement = "plugin-that-does-not-implement";
GoPluginIdentifier pluginIdentifier = new GoPluginIdentifier("another-extension-type", asList("1.0"));
final GoPlugin goPlugin = mock(GoPlugin.class);
final GoPluginDescriptor descriptor = mock(GoPluginDescriptor.class);
when(goPluginOSGiFramework.hasReferenceFor(GoPlugin.class, pluginThatDoesNotImplement)).thenReturn(true);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
ActionWithReturn<GoPlugin, GoPluginApiResponse> action = (ActionWithReturn<GoPlugin, GoPluginApiResponse>) invocationOnMock.getArguments()[2];
return action.execute(goPlugin, descriptor);
}
}).when(goPluginOSGiFramework).doOn(eq(GoPlugin.class), eq(pluginThatDoesNotImplement), any(ActionWithReturn.class));
when(goPlugin.pluginIdentifier()).thenReturn(pluginIdentifier);
DefaultPluginManager pluginManager = new DefaultPluginManager(monitor, registry, goPluginOSGiFramework, jarChangeListener, pluginRequestProcessorRegistry, pluginWriter, pluginValidator, systemEnvironment);
assertFalse(pluginManager.isPluginOfType("extension-type", pluginThatDoesNotImplement));
verify(goPluginOSGiFramework).doOn(eq(GoPlugin.class), eq(pluginThatDoesNotImplement), any(ActionWithReturn.class));
}
示例8: MetadataLoader
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
public MetadataLoader(PluginManager pluginManager, PluginInfoBuilder<T> builder, MetadataStore<T> metadataStore, AbstractExtension extension) {
this.builder = builder;
this.metadataStore = metadataStore;
this.extension = extension;
pluginManager.addPluginChangeListener(this, GoPlugin.class);
}
示例9: shouldSetConfigForTheTaskCorrespondingToGivenPluginId
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldSetConfigForTheTaskCorrespondingToGivenPluginId() 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);
PluginManager pluginManager = mock(PluginManager.class);
final TaskExtension taskExtension = mock(TaskExtension.class);
when(taskExtension.canHandlePlugin(pluginId)).thenReturn(true);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
final Action<Task> action = (Action<Task>) invocationOnMock.getArguments()[1];
action.execute(task, descriptor);
return null;
}
}).when(taskExtension).doOnTask(eq(pluginId), any(Action.class));
when(pluginManager.hasReferenceFor(Task.class, pluginId)).thenReturn(true);
when(pluginManager.isPluginOfType("task-plugin", pluginId)).thenReturn(false);
PluggableTaskPreferenceLoader pluggableTaskPreferenceLoader = new PluggableTaskPreferenceLoader(pluginManager, taskExtension);
pluggableTaskPreferenceLoader.pluginLoaded(descriptor);
assertThat(PluggableTaskConfigStore.store().hasPreferenceFor(pluginId), is(true));
assertThat(PluggableTaskConfigStore.store().preferenceFor(pluginId), is(new TaskPreference(task)));
verify(pluginManager).addPluginChangeListener(pluggableTaskPreferenceLoader, Task.class, GoPlugin.class);
}
示例10: shouldLoadPreferencesOnlyForTaskPlugins
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldLoadPreferencesOnlyForTaskPlugins() {
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);
PluginManager pluginManager = mock(PluginManager.class);
final TaskExtension taskExtension = mock(TaskExtension.class);
when(taskExtension.canHandlePlugin(pluginId)).thenReturn(false);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
final Action<Task> action = (Action<Task>) invocationOnMock.getArguments()[1];
action.execute(task, descriptor);
return null;
}
}).when(taskExtension).doOnTask(eq(pluginId), any(Action.class));
PluggableTaskPreferenceLoader pluggableTaskPreferenceLoader = new PluggableTaskPreferenceLoader(pluginManager, taskExtension);
pluggableTaskPreferenceLoader.pluginLoaded(descriptor);
assertThat(PluggableTaskConfigStore.store().hasPreferenceFor(pluginId), is(false));
verify(pluginManager).addPluginChangeListener(pluggableTaskPreferenceLoader, Task.class, GoPlugin.class);
}
示例11: ensureInitializerInvoked
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
private void ensureInitializerInvoked(GoPluginDescriptor pluginDescriptor, GoPlugin plugin) {
synchronized (initializedPlugins) {
if (initializedPlugins.contains(pluginDescriptor)) {
return;
}
initializedPlugins.add(pluginDescriptor);
PluginAwareDefaultGoApplicationAccessor accessor = new PluginAwareDefaultGoApplicationAccessor(pluginDescriptor, requestProcesRegistry);
plugin.initializeGoApplicationAccessor(accessor);
}
}
示例12: isPluginOfType
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Override
public boolean isPluginOfType(final String extension, String pluginId) {
return hasReferenceFor(GoPlugin.class, pluginId) && goPluginOSGiFramework.doOn(GoPlugin.class, pluginId, new ActionWithReturn<GoPlugin, Boolean>() {
@Override
public Boolean execute(GoPlugin plugin, GoPluginDescriptor pluginDescriptor) {
return extension.equals(plugin.pluginIdentifier().getExtension());
}
});
}
示例13: shouldCheckIfReferenceCanBeFoundForServiceClassAndPluginId
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldCheckIfReferenceCanBeFoundForServiceClassAndPluginId() throws Exception {
String pluginId = "plugin-id";
when(goPluginOSGiFramework.hasReferenceFor(GoPlugin.class, pluginId)).thenReturn(true);
DefaultPluginManager pluginManager = new DefaultPluginManager(monitor, registry, goPluginOSGiFramework, jarChangeListener, pluginRequestProcessorRegistry, pluginWriter, pluginValidator, systemEnvironment);
assertThat(pluginManager.hasReferenceFor(GoPlugin.class, pluginId), is(true));
}
示例14: shouldNotFindPluginIsOfGivenExtensionWhenReferenceNotFound
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldNotFindPluginIsOfGivenExtensionWhenReferenceNotFound() throws Exception {
final String pluginThatDoesNotImplement = "plugin-that-does-not-implement";
when(goPluginOSGiFramework.hasReferenceFor(GoPlugin.class, pluginThatDoesNotImplement)).thenReturn(false);
DefaultPluginManager pluginManager = new DefaultPluginManager(monitor, registry, goPluginOSGiFramework, jarChangeListener, pluginRequestProcessorRegistry, pluginWriter, pluginValidator, systemEnvironment);
assertFalse(pluginManager.isPluginOfType("extension-type", pluginThatDoesNotImplement));
verify(goPluginOSGiFramework).hasReferenceFor(GoPlugin.class, pluginThatDoesNotImplement);
verify(goPluginOSGiFramework, never()).doOn(eq(GoPlugin.class), eq(pluginThatDoesNotImplement), any(ActionWithReturn.class));
}
示例15: shouldResolveToCorrectExtensionVersion
import com.thoughtworks.go.plugin.api.GoPlugin; //导入依赖的package包/类
@Test
public void shouldResolveToCorrectExtensionVersion() throws Exception {
String pluginId = "plugin-id";
GoPlugin goPlugin = mock(GoPlugin.class);
GoPlugginOSGiFrameworkStub osGiFrameworkStub = new GoPlugginOSGiFrameworkStub(goPlugin);
osGiFrameworkStub.addHasReferenceFor(GoPlugin.class, pluginId, true);
when(goPlugin.pluginIdentifier()).thenReturn(new GoPluginIdentifier("sample-extension", asList("1.0", "2.0")));
DefaultPluginManager pluginManager = new DefaultPluginManager(monitor, registry, osGiFrameworkStub, jarChangeListener, pluginRequestProcessorRegistry, pluginWriter, pluginValidator, systemEnvironment);
assertThat(pluginManager.resolveExtensionVersion(pluginId, asList("1.0", "2.0", "3.0")), is("2.0"));
}