Search in sources :

Example 11 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 shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchByReference.

@Test
public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchByReference() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    String meta = "apiVersion: v2\n" + "publisher: " + EDITOR_PUBLISHER + "\n" + "name: " + TERMINAL_PLUGIN_NAME + "\n" + "version: " + TERMINAL_PLUGIN_VERSION + "\n" + "type: Che Plugin";
    ComponentImpl myTerminal = new ComponentImpl(PLUGIN_COMPONENT_TYPE, null, "https://myregistry.com/abc/meta.yaml", null, null, null);
    when(fileContentProvider.fetchContent(anyString())).thenReturn(meta);
    devfile.getComponents().add(myTerminal);
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 2);
    assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF)));
    assertTrue(components.contains(myTerminal));
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 12 with DevfileImpl

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

the class DevfileConverterTest method shouldUseDevfileNameForWorkspaceNameDuringConvertingDevfileToWorkspaceConfig.

@Test
public void shouldUseDevfileNameForWorkspaceNameDuringConvertingDevfileToWorkspaceConfig() throws Exception {
    // given
    FileContentProvider fileContentProvider = mock(FileContentProvider.class);
    DevfileImpl devfile = newDevfile("petclinic");
    // when
    WorkspaceConfigImpl workspaceConfig = devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
    // then
    assertEquals(workspaceConfig.getName(), "petclinic");
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) Test(org.testng.annotations.Test)

Example 13 with DevfileImpl

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

the class DevfileConverterTest method shouldThrowAnExceptionIfDevfileApiVersionIsNotSupportedDuringConvertingDevfileToWorkspaceConfig.

@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Provided Devfile has unsupported version '1\\.0\\.0-non-supported'. The following versions are supported: .*")
public void shouldThrowAnExceptionIfDevfileApiVersionIsNotSupportedDuringConvertingDevfileToWorkspaceConfig() throws Exception {
    // given
    FileContentProvider fileContentProvider = mock(FileContentProvider.class);
    DevfileImpl devfile = new DevfileImpl();
    devfile.setApiVersion("1.0.0-non-supported");
    devfile.setName("petclinic");
    // when
    devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Test(org.testng.annotations.Test)

Example 14 with DevfileImpl

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

the class DevfileConverterTest method shouldConvertCommandsDuringConvertingDevfileToWorkspaceConfig.

@Test
public void shouldConvertCommandsDuringConvertingDevfileToWorkspaceConfig() throws Exception {
    // given
    FileContentProvider fileContentProvider = mock(FileContentProvider.class);
    DevfileImpl devfile = newDevfile("petclinic");
    CommandImpl devfileCommand = mock(CommandImpl.class);
    devfile.getCommands().add(devfileCommand);
    org.eclipse.che.api.workspace.server.model.impl.CommandImpl workspaceCommand = mock(org.eclipse.che.api.workspace.server.model.impl.CommandImpl.class);
    when(commandConverter.toWorkspaceCommand(any(), any())).thenReturn(workspaceCommand);
    // when
    WorkspaceConfigImpl workspaceConfig = devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
    // then
    assertEquals(workspaceConfig.getCommands().size(), 1);
    assertSame(workspaceConfig.getCommands().get(0), workspaceCommand);
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) Test(org.testng.annotations.Test)

Example 15 with DevfileImpl

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

the class DevfileConverterTest method shouldInvokeDefaultEditorProvisionerDuringConvertingDevfileToWorkrspaceConfig.

@Test
public void shouldInvokeDefaultEditorProvisionerDuringConvertingDevfileToWorkrspaceConfig() throws Exception {
    // given
    FileContentProvider fileContentProvider = mock(FileContentProvider.class);
    DevfileImpl devfile = newDevfile("petclinic");
    // when
    devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
    // then
    verify(defaultEditorToolApplier).apply(devfile, fileContentProvider);
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) 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