Search in sources :

Example 16 with Image

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)));
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) Image(com.thoughtworks.go.plugin.access.common.models.Image) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Example 17 with Image

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));
}
Also used : Image(com.thoughtworks.go.plugin.access.common.models.Image) Test(org.junit.jupiter.api.Test)

Aggregations

Image (com.thoughtworks.go.plugin.access.common.models.Image)17 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)9 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)8 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)7 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)6 Test (org.junit.Test)6 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)5 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)5 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)5 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)5 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 AuthorizationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo)3 ElasticPluginInfo (com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo)3 AuthorizationPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.authorization.AuthorizationPluginConfigMetadataStore)2 ElasticPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore)2 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 Capabilities (com.thoughtworks.go.plugin.access.authorization.models.Capabilities)1 NewPluginInfo (com.thoughtworks.go.server.ui.plugins.NewPluginInfo)1