Search in sources :

Example 1 with CombinedPluginInfo

use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.

the class GoVelocityViewTest method shouldSetSupportsAnalyticsDashboardIfPluginInstalled.

@Test
public void shouldSetSupportsAnalyticsDashboardIfPluginInstalled() throws Exception {
    List<SupportedAnalytics> supportedAnalytics = Collections.singletonList(new SupportedAnalytics("dashboard", "id", "foo"));
    AnalyticsPluginInfo info = new AnalyticsPluginInfo(null, null, new Capabilities(supportedAnalytics), null);
    when(pluginInfoFinder.allPluginInfos(ANALYTICS_EXTENSION)).thenReturn(Collections.singletonList(new CombinedPluginInfo(info)));
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.SUPPORTS_ANALYTICS_DASHBOARD), is(true));
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) Capabilities(com.thoughtworks.go.plugin.domain.analytics.Capabilities) SupportedAnalytics(com.thoughtworks.go.plugin.domain.analytics.SupportedAnalytics) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo) Test(org.junit.Test)

Example 2 with CombinedPluginInfo

use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.

the class PluginInfoProviderTest method shouldGetPluginInformationAsJson.

@Test
public void shouldGetPluginInformationAsJson() {
    when(pluginManager.plugins()).thenReturn(Arrays.asList(passwordFilePluginDescriptor(), ldapPluginDescriptor()));
    when(pluginInfoFinder.pluginInfoFor("cd.go.authentication.passwordfile")).thenReturn(new CombinedPluginInfo(new PluginInfo(passwordFilePluginDescriptor(), "authorization", null, null)));
    Map<String, Object> json = pluginInfoProvider.asJson();
    Map<String, Object> expectedJson = new LinkedHashMap<>();
    Map<String, Object> passwordFilePluginJson = new LinkedHashMap<>();
    passwordFilePluginJson.put("id", "cd.go.authentication.passwordfile");
    passwordFilePluginJson.put("type", Collections.singletonList("authorization"));
    passwordFilePluginJson.put("version", "1.0.1-48");
    passwordFilePluginJson.put("bundled_plugin", true);
    passwordFilePluginJson.put("status", passwordFilePluginDescriptor().getStatus());
    Map<String, Object> ldapPluginJson = new LinkedHashMap<>();
    ldapPluginJson.put("id", "cd.go.authentication.ldap");
    ldapPluginJson.put("type", Collections.emptyList());
    ldapPluginJson.put("version", "1.1");
    ldapPluginJson.put("bundled_plugin", true);
    ldapPluginJson.put("status", ldapPluginDescriptor().getStatus());
    expectedJson.put("plugins", Arrays.asList(passwordFilePluginJson, ldapPluginJson));
    assertThat(json, is(expectedJson));
}
Also used : PluginInfo(com.thoughtworks.go.plugin.domain.common.PluginInfo) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo) Test(org.junit.Test)

Example 3 with CombinedPluginInfo

use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.

the class InitialContextProviderTest method shouldShowAnalyticsDashboard.

@Test
public void shouldShowAnalyticsDashboard() {
    Map<String, Object> modelMap = new HashMap<>();
    when(securityService.isUserAdmin(any(Username.class))).thenReturn(true);
    CombinedPluginInfo combinedPluginInfo = new CombinedPluginInfo(analyticsPluginInfo());
    when(pluginInfoFinder.allPluginInfos(PluginConstants.ANALYTICS_EXTENSION)).thenReturn(Collections.singletonList(combinedPluginInfo));
    VelocityContext velocityContext = initialContextProvider.getVelocityContext(modelMap, dummySparkController.getClass(), "viewName");
    assertThat(velocityContext.internalGet("showAnalyticsDashboard")).isEqualTo(true);
}
Also used : HashMap(java.util.HashMap) Username(com.thoughtworks.go.server.domain.Username) VelocityContext(org.apache.velocity.VelocityContext) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo) Test(org.junit.jupiter.api.Test)

Example 4 with CombinedPluginInfo

use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.

the class PluginInfoProvider method asJson.

@Override
public Map<String, Object> asJson() {
    List<Map<String, Object>> plugins = new ArrayList<>();
    List<GoPluginDescriptor> goPluginDescriptors = pluginManager.plugins();
    for (GoPluginDescriptor goPluginDescriptor : goPluginDescriptors) {
        CombinedPluginInfo combinedPluginInfo = pluginInfoFinder.pluginInfoFor(goPluginDescriptor.id());
        Map<String, Object> pluginJson = getPluginJson(combinedPluginInfo, goPluginDescriptor);
        plugins.add(pluginJson);
    }
    Map<String, Object> json = new LinkedHashMap<>();
    json.put("plugins", plugins);
    return json;
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo)

Example 5 with CombinedPluginInfo

use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.

the class DefaultPluginInfoFinder method pluginInfoFor.

public CombinedPluginInfo pluginInfoFor(String pluginId) {
    CombinedPluginInfo result = new CombinedPluginInfo();
    List<PluginInfo> allPluginInfosForPluginID = builders.values().stream().map(new Function<MetadataStore, PluginInfo>() {

        @Override
        public PluginInfo apply(MetadataStore metadataStore) {
            return metadataStore.getPluginInfo(pluginId);
        }
    }).filter(new Predicate<PluginInfo>() {

        @Override
        public boolean test(PluginInfo obj) {
            return Objects.nonNull(obj);
        }
    }).collect(toList());
    if (allPluginInfosForPluginID.isEmpty()) {
        return null;
    }
    result.addAll(allPluginInfosForPluginID);
    return result;
}
Also used : AnalyticsMetadataStore(com.thoughtworks.go.plugin.access.analytics.AnalyticsMetadataStore) NewSCMMetadataStore(com.thoughtworks.go.plugin.access.scm.NewSCMMetadataStore) ElasticAgentMetadataStore(com.thoughtworks.go.plugin.access.elastic.ElasticAgentMetadataStore) PluggableTaskMetadataStore(com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskMetadataStore) NotificationMetadataStore(com.thoughtworks.go.plugin.access.notification.NotificationMetadataStore) ArtifactMetadataStore(com.thoughtworks.go.plugin.access.artifact.ArtifactMetadataStore) AuthorizationMetadataStore(com.thoughtworks.go.plugin.access.authorization.AuthorizationMetadataStore) MetadataStore(com.thoughtworks.go.plugin.access.common.MetadataStore) ConfigRepoMetadataStore(com.thoughtworks.go.plugin.access.configrepo.ConfigRepoMetadataStore) PackageMaterialMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.PackageMaterialMetadataStore) PluginInfo(com.thoughtworks.go.plugin.domain.common.PluginInfo) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo) Predicate(java.util.function.Predicate)

Aggregations

CombinedPluginInfo (com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo)8 Username (com.thoughtworks.go.server.domain.Username)3 HashMap (java.util.HashMap)3 VelocityContext (org.apache.velocity.VelocityContext)3 Test (org.junit.jupiter.api.Test)3 PluginInfo (com.thoughtworks.go.plugin.domain.common.PluginInfo)2 Test (org.junit.Test)2 AnalyticsMetadataStore (com.thoughtworks.go.plugin.access.analytics.AnalyticsMetadataStore)1 ArtifactMetadataStore (com.thoughtworks.go.plugin.access.artifact.ArtifactMetadataStore)1 AuthorizationMetadataStore (com.thoughtworks.go.plugin.access.authorization.AuthorizationMetadataStore)1 MetadataStore (com.thoughtworks.go.plugin.access.common.MetadataStore)1 ConfigRepoMetadataStore (com.thoughtworks.go.plugin.access.configrepo.ConfigRepoMetadataStore)1 ElasticAgentMetadataStore (com.thoughtworks.go.plugin.access.elastic.ElasticAgentMetadataStore)1 NotificationMetadataStore (com.thoughtworks.go.plugin.access.notification.NotificationMetadataStore)1 PackageMaterialMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.PackageMaterialMetadataStore)1 PluggableTaskMetadataStore (com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskMetadataStore)1 NewSCMMetadataStore (com.thoughtworks.go.plugin.access.scm.NewSCMMetadataStore)1 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)1 Capabilities (com.thoughtworks.go.plugin.domain.analytics.Capabilities)1 SupportedAnalytics (com.thoughtworks.go.plugin.domain.analytics.SupportedAnalytics)1