use of com.thoughtworks.go.server.ui.plugins.PluginView in project gocd by gocd.
the class ElasticAgentPluginInfoBuilderTest method pluginInfoFor_ShouldProvideEPluginInfoForAPlugin.
@Test
public void pluginInfoFor_ShouldProvideEPluginInfoForAPlugin() throws Exception {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
PluginProfileMetadataKeys metadataKeys = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("password", new PluginProfileMetadata(true, true))));
Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
;
String view = "some html view";
ElasticPluginConfigMetadataStore store = mock(ElasticPluginConfigMetadataStore.class);
when(store.find("docker-plugin")).thenReturn(plugin);
when(store.getProfileMetadata(plugin)).thenReturn(metadataKeys);
when(store.getIcon(plugin)).thenReturn(image);
when(store.getProfileView(plugin)).thenReturn(view);
ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(store);
ElasticPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
PluggableInstanceSettings settings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(metadataKeys), new PluginView(view));
assertEquals(new ElasticPluginInfo(plugin, settings, image), pluginInfo);
}
use of com.thoughtworks.go.server.ui.plugins.PluginView in project gocd by gocd.
the class ElasticAgentViewViewModelBuilderTest method shouldBeAbleToFetchPluginInfoForSinglePlugin.
@Test
public void shouldBeAbleToFetchPluginInfoForSinglePlugin() throws Exception {
when(elasticPluginConfigMetadataStore.find(dockerPlugin.id())).thenReturn(dockerPlugin);
Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
;
when(elasticPluginConfigMetadataStore.getIcon(dockerPlugin)).thenReturn(image);
when(elasticPluginConfigMetadataStore.getProfileView(dockerPlugin)).thenReturn("html");
PluginProfileMetadataKey pluginProfileMetadataKey = new PluginProfileMetadataKey("foo", new PluginProfileMetadata(true, true));
PluginProfileMetadataKeys pluginProfileMetadataKeys = new PluginProfileMetadataKeys(Collections.singletonList(pluginProfileMetadataKey));
when(elasticPluginConfigMetadataStore.getProfileMetadata(dockerPlugin)).thenReturn(pluginProfileMetadataKeys);
PluginInfo pluginInfo = builder.pluginInfoFor(dockerPlugin.id());
assertThat(pluginInfo.getImage(), is(image));
assertThat(pluginInfo.getPluggableInstanceSettings().getView(), is(new PluginView("html")));
Map<String, Object> metadata = new HashMap<>();
metadata.put(REQUIRED_OPTION, true);
metadata.put(SECURE_OPTION, true);
assertEquals(pluginInfo.getPluggableInstanceSettings().getConfigurations(), Arrays.asList(new PluginConfiguration("foo", metadata, null)));
}
use of com.thoughtworks.go.server.ui.plugins.PluginView in project gocd by gocd.
the class SCMViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithViewTemplate.
@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithViewTemplate() {
when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
PluginInfo pluginInfo = builder.pluginInfoFor("github.pr");
PluginView view = pluginInfo.getPluggableInstanceSettings().getView();
assertThat(view.getTemplate(), is("scm view template"));
}
Aggregations