Search in sources :

Example 21 with DevfileImpl

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

the class WorkspaceManagerTest method nameIsUsedWhenNameAndGenerateNameSet.

@Test
public void nameIsUsedWhenNameAndGenerateNameSet() throws ValidationException, ConflictException, NotFoundException, ServerException, InfrastructureException {
    final String devfileName = "workspacename";
    final DevfileImpl devfile = new DevfileImpl();
    devfile.setApiVersion(CURRENT_API_VERSION);
    devfile.getMetadata().setName(devfileName);
    devfile.getMetadata().setGenerateName("this_will_not_be_set_as_a_name");
    when(runtimes.evalInfrastructureNamespace(any())).thenReturn("ns");
    Workspace workspace = workspaceManager.createWorkspace(devfile, NAMESPACE_1, null, null);
    assertEquals(workspace.getDevfile().getName(), devfileName);
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Workspace(org.eclipse.che.api.core.model.workspace.Workspace) Test(org.testng.annotations.Test)

Example 22 with DevfileImpl

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

the class WorkspaceManagerTest method createsWorkspaceFromDevfile.

@Test
public void createsWorkspaceFromDevfile() throws ValidationException, ConflictException, NotFoundException, ServerException, InfrastructureException {
    final DevfileImpl devfile = new DevfileImpl();
    devfile.setApiVersion(CURRENT_API_VERSION);
    devfile.setName("ws");
    when(runtimes.evalInfrastructureNamespace(any())).thenReturn("ns");
    Workspace workspace = workspaceManager.createWorkspace(devfile, NAMESPACE_1, null, null);
    assertEquals(workspace.getDevfile(), devfile);
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Workspace(org.eclipse.che.api.core.model.workspace.Workspace) Test(org.testng.annotations.Test)

Example 23 with DevfileImpl

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

the class WorkspaceRuntimesTest method mockWorkspaceWithDevfile.

private WorkspaceImpl mockWorkspaceWithDevfile(String workspaceId, String envName) throws NotFoundException, ServerException {
    DevfileImpl devfile = mock(DevfileImpl.class);
    WorkspaceImpl workspace = mock(WorkspaceImpl.class);
    lenient().when(workspace.getDevfile()).thenReturn(devfile);
    lenient().when(workspace.getId()).thenReturn(workspaceId);
    lenient().when(workspace.getAttributes()).thenReturn(new HashMap<>());
    lenient().when(workspaceDao.get(workspaceId)).thenReturn(workspace);
    WorkspaceConfigImpl convertedConfig = mock(WorkspaceConfigImpl.class);
    when(convertedConfig.getDefaultEnv()).thenReturn(envName);
    EnvironmentImpl environment = mockEnvironment();
    lenient().when(convertedConfig.getEnvironments()).thenReturn(ImmutableMap.of(envName, environment));
    lenient().when(devfileConverter.convert(devfile)).thenReturn(convertedConfig);
    return workspace;
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)

Example 24 with DevfileImpl

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

the class WorkspaceRuntimesTest method mockWorkspaceWithDevfile.

private WorkspaceImpl mockWorkspaceWithDevfile(RuntimeIdentity identity) throws NotFoundException, ServerException {
    DevfileImpl devfile = mock(DevfileImpl.class);
    WorkspaceImpl workspace = mock(WorkspaceImpl.class);
    lenient().when(workspace.getDevfile()).thenReturn(devfile);
    lenient().when(workspace.getId()).thenReturn(identity.getWorkspaceId());
    lenient().when(workspace.getAttributes()).thenReturn(new HashMap<>());
    lenient().when(workspaceDao.get(identity.getWorkspaceId())).thenReturn(workspace);
    WorkspaceConfigImpl convertedConfig = mock(WorkspaceConfigImpl.class);
    EnvironmentImpl environment = mockEnvironment();
    lenient().when(convertedConfig.getEnvironments()).thenReturn(ImmutableMap.of(identity.getEnvName(), environment));
    lenient().when(devfileConverter.convert(devfile)).thenReturn(convertedConfig);
    return workspace;
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)

Example 25 with DevfileImpl

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

the class WorkspaceRuntimesTest method shouldThrowExceptionIfWorkspaceDoesNotHaveInfraNamespaceSpecifiedOnStartAsync.

@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Workspace does not have infrastructure namespace specified. " + "Please set value of 'infrastructureNamespace' workspace attribute.")
public void shouldThrowExceptionIfWorkspaceDoesNotHaveInfraNamespaceSpecifiedOnStartAsync() throws Exception {
    WorkspaceImpl workspace = WorkspaceImpl.builder().setId("workspace123").setDevfile(new DevfileImpl()).build();
    runtimes.startAsync(workspace, "env", emptyMap());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) 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