Search in sources :

Example 26 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo 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 27 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class SCMViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenId.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenId() {
    when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
    PluginInfo pluginInfo = builder.pluginInfoFor("github.pr");
    assertThat(pluginInfo.getId(), is("github.pr"));
    assertThat(pluginInfo.getType(), is("scm"));
    assertThat(pluginInfo.getName(), is(githubPR.about().name()));
    assertThat(pluginInfo.getDisplayName(), is(preference.getScmView().displayValue()));
    assertThat(pluginInfo.getVersion(), is(githubPR.about().version()));
}
Also used : PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 28 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo 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"));
}
Also used : PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 29 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class SCMViewModelBuilderTest method shouldBeAbleToFetchAllPluginInfos.

@Test
public void shouldBeAbleToFetchAllPluginInfos() {
    when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
    when(manager.getPluginDescriptorFor("stash.pr")).thenReturn(stashPR);
    List<PluginInfo> pluginInfos = builder.allPluginInfos();
    assertThat(pluginInfos.size(), is(2));
    PluginInfo pluginInfo = pluginInfos.get(0).getId() == "github.pr" ? pluginInfos.get(0) : pluginInfos.get(1);
    assertThat(pluginInfo.getId(), is("github.pr"));
    assertThat(pluginInfo.getType(), is("scm"));
    assertThat(pluginInfo.getName(), is(githubPR.about().name()));
    assertThat(pluginInfo.getDisplayName(), is(preference.getScmView().displayValue()));
    assertThat(pluginInfo.getVersion(), is(githubPR.about().version()));
    assertNull(pluginInfo.getPluggableInstanceSettings());
}
Also used : PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 30 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class ElasticAgentViewViewModelBuilderTest method shouldBeAbleToFetchAllPluginInfos.

@Test
public void shouldBeAbleToFetchAllPluginInfos() throws Exception {
    when(elasticPluginConfigMetadataStore.getPlugins()).thenReturn(new ArrayList<>(Arrays.asList(dockerPlugin, awsPlugin)));
    List<PluginInfo> pluginInfos = builder.allPluginInfos();
    assertThat(pluginInfos.size(), is(2));
    PluginInfo dockerPluginInfo = pluginInfos.get(0);
    PluginInfo awsPluginInfo = pluginInfos.get(1);
    assertEquals(new PluginInfo(dockerPlugin, ElasticAgentPluginConstants.EXTENSION_NAME, null, null), dockerPluginInfo);
    assertEquals(new PluginInfo(awsPlugin, ElasticAgentPluginConstants.EXTENSION_NAME, null, null), awsPluginInfo);
}
Also used : PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Aggregations

PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)32 Test (org.junit.Test)20 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)9 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)9 ArrayList (java.util.ArrayList)9 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)7 Image (com.thoughtworks.go.plugin.access.common.models.Image)5 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)5 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)4 HashSet (java.util.HashSet)4 HashMap (java.util.HashMap)3 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)2 SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)2 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)1 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)1 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)1