use of org.eclipse.che.api.workspace.server.model.impl.RuntimeImpl in project che-server by eclipse-che.
the class WorkspaceManagerTest method getsWorkspacesByNamespaceWithRuntimes.
@Test
public void getsWorkspacesByNamespaceWithRuntimes() throws Exception {
// given
final WorkspaceImpl workspace = createAndMockWorkspace();
final TestRuntime runtime = mockRuntime(workspace, RUNNING);
// when
final Page<WorkspaceImpl> result = workspaceManager.getByNamespace(workspace.getNamespace(), true, 30, 0);
// then
assertEquals(result.getItems().size(), 1);
final WorkspaceImpl res1 = result.getItems().get(0);
assertEquals(res1.getStatus(), RUNNING, "Workspace status wasn't changed to the runtime instance status");
assertEquals(res1.getRuntime(), new RuntimeImpl(runtime), "Workspace doesn't have expected runtime");
assertFalse(res1.isTemporary(), "Workspace must be permanent");
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeImpl in project che-server by eclipse-che.
the class PreviewUrlLinksVariableGeneratorTest method createWorkspaceWithCommands.
private WorkspaceImpl createWorkspaceWithCommands(List<CommandImpl> commands) {
RuntimeImpl runtime = new RuntimeImpl("", Collections.emptyMap(), "", commands, new ArrayList<>());
WorkspaceImpl w = new WorkspaceImpl();
w.setRuntime(runtime);
return w;
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeImpl in project devspaces-images by redhat-developer.
the class RamResourceUsageTrackerTest method createWorkspace.
/**
* Creates users workspace object based on the status and machines RAM.
*/
private static WorkspaceImpl createWorkspace(WorkspaceStatus status, Integer... machineRams) {
final Map<String, MachineImpl> machines = new HashMap<>(machineRams.length - 1);
final Map<String, MachineConfigImpl> machineConfigs = new HashMap<>(machineRams.length - 1);
byte i = 1;
for (Integer machineRam : machineRams) {
final String machineName = "machine_" + i++;
machines.put(machineName, createMachine(machineRam));
machineConfigs.put(machineName, createMachineConfig(machineRam));
}
return WorkspaceImpl.builder().setConfig(WorkspaceConfigImpl.builder().setEnvironments(ImmutableBiMap.of(ACTIVE_ENV_NAME, new EnvironmentImpl(null, machineConfigs))).build()).setRuntime(new RuntimeImpl(ACTIVE_ENV_NAME, machines, null)).setStatus(status).build();
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeImpl in project devspaces-images by redhat-developer.
the class WorkspaceManagerTest method getsWorkspacesByNamespaceWithRuntimes.
@Test
public void getsWorkspacesByNamespaceWithRuntimes() throws Exception {
// given
final WorkspaceImpl workspace = createAndMockWorkspace();
final TestRuntime runtime = mockRuntime(workspace, RUNNING);
// when
final Page<WorkspaceImpl> result = workspaceManager.getByNamespace(workspace.getNamespace(), true, 30, 0);
// then
assertEquals(result.getItems().size(), 1);
final WorkspaceImpl res1 = result.getItems().get(0);
assertEquals(res1.getStatus(), RUNNING, "Workspace status wasn't changed to the runtime instance status");
assertEquals(res1.getRuntime(), new RuntimeImpl(runtime), "Workspace doesn't have expected runtime");
assertFalse(res1.isTemporary(), "Workspace must be permanent");
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeImpl in project devspaces-images by redhat-developer.
the class WorkspaceServiceTest method shouldGetWorkspaceWithInternalServers.
@Test
public void shouldGetWorkspaceWithInternalServers() throws Exception {
// given
WorkspaceImpl workspace = createWorkspace(createConfigDto());
String externalServerKey = "server2";
String internalServerKey = "server1";
ServerImpl externalServer = createExternalServer();
ServerImpl internalServer = createInternalServer();
Map<String, Server> servers = ImmutableMap.of(internalServerKey, createInternalServer(), externalServerKey, externalServer);
Map<String, Machine> machines = singletonMap("machine1", new MachineImpl(singletonMap("key", "value"), servers, RUNNING));
workspace.setRuntime(new RuntimeImpl("activeEnv", machines, "user123"));
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
Map<String, MachineDto> expected = singletonMap("machine1", newDto(MachineDto.class).withAttributes(singletonMap("key", "value")).withStatus(RUNNING).withServers(ImmutableMap.of(externalServerKey, newDto(ServerDto.class).withUrl(externalServer.getUrl()).withStatus(externalServer.getStatus()).withAttributes(externalServer.getAttributes()), internalServerKey, newDto(ServerDto.class).withUrl(createInternalServer().getUrl()).withStatus(internalServer.getStatus()).withAttributes(internalServer.getAttributes()))));
// when
Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).queryParam("includeInternalServers", Boolean.TRUE.toString()).when().get(SECURE_PATH + "/workspace/" + workspace.getId());
// then
assertEquals(response.getStatusCode(), 200);
RuntimeDto retrievedRuntime = unwrapDto(response, WorkspaceDto.class).getRuntime();
assertNotNull(retrievedRuntime);
assertEquals(expected, retrievedRuntime.getMachines());
}
Aggregations