@Override
    public ElasticAgentPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
        String pluginId = descriptor.id();

        PluggableInstanceSettings pluggableInstanceSettings = null;
        if (!extension.supportsClusterProfiles(pluginId)) {
            pluggableInstanceSettings = getPluginSettingsAndView(descriptor, extension);
        }

        return new ElasticAgentPluginInfo(descriptor,
                elasticElasticAgentProfileSettings(pluginId),
                elasticClusterProfileSettings(pluginId),
                image(pluginId),
                pluggableInstanceSettings,
                capabilities(pluginId));
    }
@Test
    public void shouldBuildPluginInfoWithoutClusterProfileSettingsForPluginsImplementedUsingv4Extension() {
        GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
        List<PluginConfiguration> elasticAgentProfileConfigurations = List.of(new PluginConfiguration("aws_password", new Metadata(true, false)));
        PluginSettingsProperty property = new PluginSettingsProperty("ami-id", "ami-123");
        PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration();
        pluginSettingsConfiguration.add(property);
        Image icon = new Image("content_type", "data", "hash");

        when(pluginManager.resolveExtensionVersion("plugin1", ELASTIC_AGENT_EXTENSION, SUPPORTED_VERSIONS)).thenReturn("1.0");
        when(extension.getPluginSettingsConfiguration(descriptor.id())).thenReturn(pluginSettingsConfiguration);
        when(extension.getPluginSettingsView(descriptor.id())).thenReturn("some html");

        when(extension.getIcon(descriptor.id())).thenReturn(icon);

        when(extension.getProfileMetadata(descriptor.id())).thenReturn(elasticAgentProfileConfigurations);
        when(extension.getProfileView(descriptor.id())).thenReturn("elastic_agent_profile_view");

        when(extension.supportsClusterProfiles("plugin1")).thenReturn(false);

        ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(extension);
        ElasticAgentPluginInfo pluginInfo = builder.pluginInfoFor(descriptor);

        assertThat(pluginInfo.getDescriptor(), is(descriptor));
        assertThat(pluginInfo.getExtensionName(), is("elastic-agent"));

        assertThat(pluginInfo.getImage(), is(icon));
        assertThat(pluginInfo.getElasticAgentProfileSettings(), is(new PluggableInstanceSettings(elasticAgentProfileConfigurations, new PluginView("elastic_agent_profile_view"))));
        assertThat(pluginInfo.getClusterProfileSettings(), is(new PluggableInstanceSettings(null, null)));
        assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(builder.configurations(pluginSettingsConfiguration), new PluginView("some html"))));
        assertFalse(pluginInfo.supportsStatusReport());

        verify(extension, never()).getClusterProfileMetadata(any());
        verify(extension, never()).getClusterProfileView(any());
    }