Search in sources :

Example 76 with ComponentImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.

the class DefaultEditorProvisionerTest method shouldProvisionAsyncStoragePluginsIfWorkspaceHasOnlyOneAttribute.

@Test
public void shouldProvisionAsyncStoragePluginsIfWorkspaceHasOnlyOneAttribute() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, ASYNC_STORAGE_PLUGIN_REF, fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    devfile.setAttributes(ImmutableMap.of(Constants.ASYNC_PERSIST_ATTRIBUTE, "true"));
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 2);
    assertFalse(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, ASYNC_STORAGE_PLUGIN_REF)));
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 77 with ComponentImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.

the class DefaultEditorProvisionerTest method shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny.

@Test
public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF + "," + COMMAND_PLUGIN_REF, "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 3);
    assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF)));
    assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, COMMAND_PLUGIN_REF)));
    assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF)));
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 78 with ComponentImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.

the class DefaultEditorProvisionerTest method shouldGenerateDefaultPluginNameIfIdIsNotUnique.

@Test
public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, EDITOR_PUBLISHER + "/" + "my-plugin/v2.0", "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    ComponentImpl myPlugin = new ComponentImpl(PLUGIN_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + "my-custom-plugin/v0.0.3");
    devfile.getComponents().add(myPlugin);
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 3);
    assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF)));
    assertTrue(components.contains(myPlugin));
    ComponentImpl defaultPlugin = findByRef(components, EDITOR_PUBLISHER + "/" + "my-plugin/v2.0");
    assertNotNull(defaultPlugin);
    assertNull(defaultPlugin.getAlias());
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 79 with ComponentImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.

the class DefaultEditorProvisionerTest method shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIsConfigured.

@Test
public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIsConfigured() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    ComponentImpl defaultEditorWithDifferentVersion = new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + EDITOR_NAME + "/latest");
    devfile.getComponents().add(defaultEditorWithDifferentVersion);
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 2);
    assertTrue(components.contains(defaultEditorWithDifferentVersion));
    assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF)));
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 80 with ComponentImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.

the class DefaultEditorProvisionerTest method shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne.

@Test
public void shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    ComponentImpl pluginWithNameSimilarToDefault = new ComponentImpl(PLUGIN_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + TERMINAL_PLUGIN_NAME + "-dummy/latest");
    devfile.getComponents().add(pluginWithNameSimilarToDefault);
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 3);
    assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF)));
    assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF)));
    assertTrue(components.contains(pluginWithNameSimilarToDefault));
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Aggregations

ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)218 Test (org.testng.annotations.Test)184 DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)76 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)56 Container (io.fabric8.kubernetes.api.model.Container)48 MachineConfigImpl (org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl)44 EndpointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl)42 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)38 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)36 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)26 EntrypointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl)26 Map (java.util.Map)24 EnvImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl)24 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)22 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)20 Collections.emptyMap (java.util.Collections.emptyMap)18 DevfileException (org.eclipse.che.api.workspace.server.devfile.exception.DevfileException)18 ImmutableMap (com.google.common.collect.ImmutableMap)16 ArrayList (java.util.ArrayList)14 List (java.util.List)14