@Override
    public GoPluginApiResponse submitTo(final String pluginId, String extensionType, final GoPluginApiRequest apiRequest) {
        return goPluginOSGiFramework.doOn(GoPlugin.class, pluginId, extensionType, (plugin, pluginDescriptor) -> {
            ensureInitializerInvoked(pluginDescriptor, plugin, extensionType);
            try {
                return plugin.handle(apiRequest);
            } catch (UnhandledRequestTypeException e) {
                LOGGER.error(e.getMessage());
                LOGGER.debug(e.getMessage(), e);
                throw new RuntimeException(e);
            }
        });
    }
@Test
    void shouldSubmitPluginApiRequestToGivenPlugin() throws Exception {
        String extensionType = "sample-extension";
        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(invocationOnMock -> {
            ActionWithReturn<GoPlugin, GoPluginApiResponse> action = (ActionWithReturn<GoPlugin, GoPluginApiResponse>) invocationOnMock.getArguments()[3];
            return action.execute(goPlugin, descriptor);
        }).when(goPluginOSGiFramework).doOn(eq(GoPlugin.class), eq("plugin-id"), eq(extensionType), any(ActionWithReturn.class));

        DefaultPluginManager pluginManager = new DefaultPluginManager(monitor, registry, goPluginOSGiFramework, jarChangeListener, pluginRequestProcessorRegistry, systemEnvironment, pluginLoader);
        GoPluginApiResponse actualResponse = pluginManager.submitTo("plugin-id", extensionType, request);

        assertThat(actualResponse).isEqualTo(expectedResponse);
        PluginAwareDefaultGoApplicationAccessor accessor = captor.getValue();
        assertThat(accessor.pluginDescriptor()).isEqualTo(descriptor);
    }