Search in sources :

Example 1 with PluginInfo

use of com.thoughtworks.go.plugin.domain.common.PluginInfo 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 2 with PluginInfo

use of com.thoughtworks.go.plugin.domain.common.PluginInfo 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)2 PluginInfo (com.thoughtworks.go.plugin.domain.common.PluginInfo)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 Predicate (java.util.function.Predicate)1 Test (org.junit.Test)1