use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class WorkspaceRuntimesTest method shouldBeAbleToStartMachine.
@Test
public void shouldBeAbleToStartMachine() throws Exception {
// when
setRuntime("workspace", WorkspaceStatus.RUNNING, "env-name");
MachineConfig config = newMachine("workspace", "env-name", "new", false).getConfig();
Instance instance = mock(Instance.class);
when(envEngine.startMachine(anyString(), any(MachineConfig.class), any())).thenReturn(instance);
when(instance.getConfig()).thenReturn(config);
// when
Instance actual = runtimes.startMachine("workspace", config);
// then
assertEquals(actual, instance);
verify(envEngine).startMachine(eq("workspace"), eq(config), any());
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class WorkspaceRuntimesTest method shouldBeAbleToGetMachine.
@Test
public void shouldBeAbleToGetMachine() throws Exception {
// given
Instance expected = newMachine("workspace", "env-name", "existing", false);
when(envEngine.getMachine("workspace", expected.getId())).thenReturn(expected);
// when
Instance actualMachine = runtimes.getMachine("workspace", expected.getId());
// then
assertEquals(actualMachine, expected);
verify(envEngine).getMachine("workspace", expected.getId());
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class WorkspaceRuntimesTest method injectsRuntime.
@Test
public void injectsRuntime() throws Exception {
setRuntime("workspace", WorkspaceStatus.RUNNING, "env-name");
List<Instance> machines = prepareMachines("workspace", "env-name");
WorkspaceImpl workspace = WorkspaceImpl.builder().setId("workspace").build();
runtimes.injectRuntime(workspace);
assertEquals(workspace.getStatus(), WorkspaceStatus.RUNNING);
assertEquals(workspace.getRuntime(), new WorkspaceRuntimeImpl("env-name", machines));
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class WorkspaceRuntimesTest method startsWorkspace.
@Test
public void startsWorkspace() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
List<Instance> machines = allowEnvironmentStart(workspace, "env-name");
prepareMachines(workspace.getId(), machines);
CompletableFuture<WorkspaceRuntimeImpl> cmpFuture = runtimes.startAsync(workspace, "env-name", false);
captureAsyncTaskAndExecuteSynchronously();
WorkspaceRuntimeImpl runtime = cmpFuture.get();
assertEquals(runtimes.getStatus(workspace.getId()), WorkspaceStatus.RUNNING);
assertEquals(runtime.getActiveEnv(), "env-name");
assertEquals(runtime.getMachines().size(), machines.size());
verifyEventsSequence(event("workspace", WorkspaceStatus.STOPPED, WorkspaceStatus.STARTING, EventType.STARTING, null), event("workspace", WorkspaceStatus.STARTING, WorkspaceStatus.RUNNING, EventType.RUNNING, null));
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class WorkspaceRuntimesTest method getsRuntime.
@Test
public void getsRuntime() throws Exception {
setRuntime("workspace", WorkspaceStatus.RUNNING, "env-name");
List<Instance> machines = prepareMachines("workspace", "env-name");
assertEquals(runtimes.getRuntime("workspace"), new WorkspaceRuntimeImpl("env-name", machines));
verify(envEngine).getMachines("workspace");
}
Aggregations