Search in sources :

Example 1 with ServerStatus

use of org.eclipse.che.api.core.model.workspace.runtime.ServerStatus in project che-server by eclipse-che.

the class InternalRuntimeTest method getMachinesResultShouldNotBeAffectedByFollowingModificationOfResultOfGetInternalMachines.

@Test
public void getMachinesResultShouldNotBeAffectedByFollowingModificationOfResultOfGetInternalMachines() throws Exception {
    // given
    setRunningRuntime(new URLRewriter.NoOpURLRewriter());
    String originMachineName = "exp_m";
    String originServerName = "exp_s";
    ServerStatus originServerStatus = ServerStatus.UNKNOWN;
    String originServerUrl = "https://expected.url:1000";
    Map<String, String> originProps = ImmutableMap.of("origProp1", "value1");
    int initialPropsSize = originProps.size();
    HashMap<String, MachineImpl> originInternalMachines = createMachines(originMachineName, originProps, originServerName, originServerUrl, originServerStatus);
    int initialMachinesAmount = originInternalMachines.size();
    int initialServersAmountInOriginMachine = originInternalMachines.get(originMachineName).getServers().size();
    doReturn(originInternalMachines).when(internalRuntime).getInternalMachines();
    // when
    Map<String, ? extends Machine> actualMachines = internalRuntime.getMachines();
    // verify that retrieved state is equal to the origin one
    assertValues(actualMachines, initialMachinesAmount, originMachineName, initialPropsSize, initialServersAmountInOriginMachine, originServerName, originServerUrl, originServerStatus);
    // modify origin machines
    modifyMachines(originInternalMachines, originMachineName, originServerName);
    // then
    // ensure actual values retrieved from runtime
    // are not changed automatically after changes in origin internal runtime
    assertValues(actualMachines, initialMachinesAmount, originMachineName, initialPropsSize, initialServersAmountInOriginMachine, originServerName, originServerUrl, originServerStatus);
}
Also used : URLRewriter(org.eclipse.che.api.workspace.server.URLRewriter) MachineImpl(org.eclipse.che.api.workspace.server.model.impl.MachineImpl) ServerStatus(org.eclipse.che.api.core.model.workspace.runtime.ServerStatus) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 2 with ServerStatus

use of org.eclipse.che.api.core.model.workspace.runtime.ServerStatus in project devspaces-images by redhat-developer.

the class InternalRuntimeTest method getMachinesResultShouldNotBeAffectedByFollowingModificationOfResultOfGetInternalMachines.

@Test
public void getMachinesResultShouldNotBeAffectedByFollowingModificationOfResultOfGetInternalMachines() throws Exception {
    // given
    setRunningRuntime(new URLRewriter.NoOpURLRewriter());
    String originMachineName = "exp_m";
    String originServerName = "exp_s";
    ServerStatus originServerStatus = ServerStatus.UNKNOWN;
    String originServerUrl = "https://expected.url:1000";
    Map<String, String> originProps = ImmutableMap.of("origProp1", "value1");
    int initialPropsSize = originProps.size();
    HashMap<String, MachineImpl> originInternalMachines = createMachines(originMachineName, originProps, originServerName, originServerUrl, originServerStatus);
    int initialMachinesAmount = originInternalMachines.size();
    int initialServersAmountInOriginMachine = originInternalMachines.get(originMachineName).getServers().size();
    doReturn(originInternalMachines).when(internalRuntime).getInternalMachines();
    // when
    Map<String, ? extends Machine> actualMachines = internalRuntime.getMachines();
    // verify that retrieved state is equal to the origin one
    assertValues(actualMachines, initialMachinesAmount, originMachineName, initialPropsSize, initialServersAmountInOriginMachine, originServerName, originServerUrl, originServerStatus);
    // modify origin machines
    modifyMachines(originInternalMachines, originMachineName, originServerName);
    // then
    // ensure actual values retrieved from runtime
    // are not changed automatically after changes in origin internal runtime
    assertValues(actualMachines, initialMachinesAmount, originMachineName, initialPropsSize, initialServersAmountInOriginMachine, originServerName, originServerUrl, originServerStatus);
}
Also used : URLRewriter(org.eclipse.che.api.workspace.server.URLRewriter) MachineImpl(org.eclipse.che.api.workspace.server.model.impl.MachineImpl) ServerStatus(org.eclipse.che.api.core.model.workspace.runtime.ServerStatus) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Aggregations

ServerStatus (org.eclipse.che.api.core.model.workspace.runtime.ServerStatus)2 URLRewriter (org.eclipse.che.api.workspace.server.URLRewriter)2 MachineImpl (org.eclipse.che.api.workspace.server.model.impl.MachineImpl)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Test (org.testng.annotations.Test)2