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