@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 shouldNotTryAndUpdateManifestOfAnAddedInvalidPlugin() throws Exception {
        File pluginJarFile = new File(pluginWorkDir, PLUGIN_JAR_FILE_NAME);
        copyPluginToTheDirectory(pluginWorkDir, PLUGIN_JAR_FILE_NAME);
        File expectedBundleDirectory = new File(bundleDir, PLUGIN_JAR_FILE_NAME);

        String pluginJarFileLocation = pluginJarFile.getAbsolutePath();
        GoPluginBundleDescriptor descriptorForInvalidPlugin = new GoPluginBundleDescriptor(
                GoPluginDescriptor.builder()
                        .id("testplugin.descriptorValidator")
                        .bundleLocation(expectedBundleDirectory)
                        .pluginJarFileLocation(pluginJarFileLocation)
                        .pluginJarFileLocation(pluginJarFileLocation)
                        .isBundledPlugin(true)
                        .build())
                .markAsInvalid(List.of("For a test"), null);

        when(goPluginBundleDescriptorBuilder.build(new BundleOrPluginFileDetails(pluginJarFile, true, pluginWorkDir))).thenReturn(descriptorForInvalidPlugin);
        doNothing().when(registry).loadPlugin(descriptorForInvalidPlugin);


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

        assertThat(expectedBundleDirectory).exists();
        verify(registry).loadPlugin(descriptorForInvalidPlugin);
        verifyNoMoreInteractions(osgiManifestGenerator);
    }