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));
}
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));
}
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);
}
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;
}
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;
}
Aggregations