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);
}
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);
}
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;
}
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;
}
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());
}
Aggregations