Search in sources :

Example 66 with ServerImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.

the class InternalRuntimeTest method shouldNotRewriteURLsOfInternalServers.

@Test
public void shouldNotRewriteURLsOfInternalServers() throws Exception {
    // given
    ServerImpl internalServer = createServer(singletonMap(ServerConfig.INTERNAL_SERVER_ATTRIBUTE, "true"));
    ServerImpl regularServer = createServer(RUNNING);
    MachineImpl machineWithInternalServer = new MachineImpl(createAttributes(), ImmutableMap.of("server1", regularServer, "server2", internalServer), MachineStatus.RUNNING);
    ImmutableMap<String, MachineImpl> internalMachines = ImmutableMap.of("m1", createMachine(), "m2", machineWithInternalServer);
    ImmutableMap<String, MachineImpl> expected = ImmutableMap.of("m1", rewriteURLs(createMachine()), "m2", new MachineImpl(createAttributes(), ImmutableMap.of("server1", rewriteURL(regularServer), "server2", internalServer), MachineStatus.RUNNING));
    setRunningRuntime();
    doReturn(internalMachines).when(internalRuntime).getInternalMachines();
    // when
    Map<String, ? extends Machine> actual = internalRuntime.getMachines();
    // then
    assertEquals(actual, expected);
}
Also used : MachineImpl(org.eclipse.che.api.workspace.server.model.impl.MachineImpl) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 67 with ServerImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.

the class InternalRuntimeTest method modifyMachines.

private void modifyMachines(HashMap<String, MachineImpl> originInternalMachines, String machineToModify, String serverToModify) throws Exception {
    // add new machine
    originInternalMachines.put("newM", createMachine());
    MachineImpl originMachine = originInternalMachines.get(machineToModify);
    // change properties of origin server
    originMachine.getAttributes().put("new_prop", "new_value");
    // add new server in origin machine
    originMachine.getServers().put("newS", createServer(RUNNING));
    ServerImpl originServer = originMachine.getServers().get(serverToModify);
    // change status and URL of origin server
    originServer.setStatus(RUNNING);
    originServer.setUrl("http://localhost:9191/new_url");
}
Also used : MachineImpl(org.eclipse.che.api.workspace.server.model.impl.MachineImpl) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl)

Example 68 with ServerImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.

the class InternalRuntimeTest method assertValues.

private void assertValues(Map<String, ? extends Machine> actualMachines, int expectedMachinesAmount, String expectedMachineName, int expectedMachinePropsSize, int expectedMachineServersSize, String expectedServerName, String expectedServerUrl, ServerStatus expectedServerStatus) {
    assertEquals(actualMachines.size(), expectedMachinesAmount);
    assertTrue(actualMachines.containsKey(expectedMachineName));
    Machine actualMachine = actualMachines.get(expectedMachineName);
    assertEquals(actualMachine.getAttributes().size(), expectedMachinePropsSize);
    assertEquals(actualMachine.getServers().size(), expectedMachineServersSize);
    assertTrue(actualMachine.getServers().containsKey(expectedServerName));
    assertEquals(actualMachine.getServers().get(expectedServerName), new ServerImpl().withUrl(expectedServerUrl).withStatus(expectedServerStatus).withAttributes(emptyMap()));
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Machine(org.eclipse.che.api.core.model.workspace.runtime.Machine)

Aggregations

ServerImpl (org.eclipse.che.api.workspace.server.model.impl.ServerImpl)68 Test (org.testng.annotations.Test)54 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)32 MachineImpl (org.eclipse.che.api.workspace.server.model.impl.MachineImpl)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 Route (io.fabric8.openshift.api.model.Route)16 RouteServerResolver (org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver)16 Service (io.fabric8.kubernetes.api.model.Service)14 IngressServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver)14 ServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver)14 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)12 Machine (org.eclipse.che.api.core.model.workspace.runtime.Machine)12 Server (org.eclipse.che.api.core.model.workspace.runtime.Server)12 Response (io.restassured.response.Response)10 RuntimeImpl (org.eclipse.che.api.workspace.server.model.impl.RuntimeImpl)10 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)10 MachineDto (org.eclipse.che.api.workspace.shared.dto.MachineDto)10 RuntimeDto (org.eclipse.che.api.workspace.shared.dto.RuntimeDto)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)10 HashMap (java.util.HashMap)8