@Override
    public void pluginJarAdded(BundleOrPluginFileDetails bundleOrPluginFileDetails) {
        final GoPluginBundleDescriptor bundleDescriptor = goPluginBundleDescriptorBuilder.build(bundleOrPluginFileDetails);

        try {
            LOGGER.info("Plugin load starting: {}", bundleOrPluginFileDetails.file());

            validateIfExternalPluginRemovingBundledPlugin(bundleDescriptor);
            validatePluginCompatibilityWithCurrentOS(bundleDescriptor);
            validatePluginCompatibilityWithGoCD(bundleDescriptor);
            addPlugin(bundleOrPluginFileDetails, bundleDescriptor);
        } finally {
            LOGGER.info("Plugin load finished: {}", bundleOrPluginFileDetails.file());
        }
    }
@Test
    void shouldCopyPluginToBundlePathAndInformRegistryAndUpdateTheOSGiManifestWhenAPluginIsAdded() throws Exception {
        String pluginId = "testplugin.descriptorValidator";
        File pluginJarFile = new File(pluginWorkDir, PLUGIN_JAR_FILE_NAME);
        File expectedBundleDirectory = new File(bundleDir, PLUGIN_JAR_FILE_NAME);

        copyPluginToTheDirectory(pluginWorkDir, PLUGIN_JAR_FILE_NAME);
        String pluginJarFileLocation = pluginJarFile.getAbsolutePath();
        GoPluginBundleDescriptor descriptor = new GoPluginBundleDescriptor(GoPluginDescriptor.builder()
                .id(pluginId)
                .bundleLocation(expectedBundleDirectory)
                .pluginJarFileLocation(pluginJarFileLocation)
                .isBundledPlugin(true)
                .build());
        when(goPluginBundleDescriptorBuilder.build(new BundleOrPluginFileDetails(pluginJarFile, true, pluginWorkDir))).thenReturn(descriptor);
        when(registry.getPluginByIdOrFileName(pluginId, PLUGIN_JAR_FILE_NAME)).thenReturn(null);
        doNothing().when(registry).loadPlugin(descriptor);

        listener.pluginJarAdded(new BundleOrPluginFileDetails(pluginJarFile, true, pluginWorkDir));

        assertThat(expectedBundleDirectory).exists();
        verify(registry).getPluginByIdOrFileName(pluginId, PLUGIN_JAR_FILE_NAME);
        verify(registry).loadPlugin(descriptor);
        verify(osgiManifestGenerator).updateManifestOf(descriptor);
        verify(pluginLoader).loadPlugin(descriptor);
        verifyNoMoreInteractions(osgiManifestGenerator);
        verifyNoMoreInteractions(registry);
        assertThat(new File(expectedBundleDirectory, "lib/go-plugin-activator.jar")).exists();
    }