use of com.thoughtworks.go.plugin.access.common.models.Image 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.plugin.access.common.models.Image in project gocd by gocd.
the class ImageTest method convertsToDataUri.
@Test
public void convertsToDataUri() throws Exception {
String encodedString = Base64.getEncoder().encodeToString("asdf".getBytes(StandardCharsets.UTF_8));
String dataURI = new Image("foo", encodedString).toDataURI();
assertThat(dataURI, is("data:foo;base64," + encodedString));
}
Aggregations