Search in sources :

Example 6 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DefaultEditorProvisionerTest method shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNonDefaultEditor.

@Test
public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNonDefaultEditor() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, "", "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    ComponentImpl nonDefaultEditor = new ComponentImpl(EDITOR_COMPONENT_TYPE, "anypublisher/anyname/v" + EDITOR_VERSION);
    devfile.getComponents().add(nonDefaultEditor);
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 1);
    assertTrue(components.contains(nonDefaultEditor));
}
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 7 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

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 8 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DefaultEditorProvisionerTest method shouldProvisionAsyncStoragePluginsIfWorkspaceHasBothAttributes.

@Test
public void shouldProvisionAsyncStoragePluginsIfWorkspaceHasBothAttributes() 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", Constants.PERSIST_VOLUMES_ATTRIBUTE, "false"));
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 3);
    assertTrue(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 9 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DefaultEditorProvisionerTest method shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute.

@Test
public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    devfile.getAttributes().put(EDITOR_FREE_DEVFILE_ATTRIBUTE, "true");
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertTrue(components.isEmpty());
}
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 10 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DefaultEditorProvisionerTest method shouldNotProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDifferentVersion.

@Test
public void shouldNotProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDifferentVersion() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, "", "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    ComponentImpl myTheiaEditor = new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + EDITOR_NAME + "/my-custom");
    devfile.getComponents().add(myTheiaEditor);
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 1);
    assertTrue(components.contains(myTheiaEditor));
}
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

DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)162 Test (org.testng.annotations.Test)126 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)76 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)22 FileContentProvider (org.eclipse.che.api.workspace.server.devfile.FileContentProvider)20 MetadataImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl)20 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)18 ActionImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl)16 ProjectImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl)16 Container (io.fabric8.kubernetes.api.model.Container)14 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl)14 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)14 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)14 EndpointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl)12 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)10 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)10 Secret (io.fabric8.kubernetes.api.model.Secret)10 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)10 HashMap (java.util.HashMap)10 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)10