use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.
the class RouteServerResolverTest method testResolvingInternalServersWithPortWithTransportProtocol.
@Test
public void testResolvingInternalServersWithPortWithTransportProtocol() {
Service service = createService("service11", "machine", CONTAINER_PORT, singletonMap("http-server", new ServerConfigImpl("3054/udp", "xxx", "api", ATTRIBUTES_MAP)));
Route route = createRoute("matched", "machine", null);
RouteServerResolver serverResolver = new RouteServerResolver(singletonList(service), singletonList(route));
Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
assertEquals(resolved.size(), 1);
assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("xxx://service11:3054/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.
the class RouteServerResolverTest method testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsEmpty.
@Test
public void testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsEmpty() {
Route route = createRoute("matched", "machine", singletonMap("http-server", new ServerConfigImpl("3054", "http", "", ATTRIBUTES_MAP)));
RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
assertEquals(resolved.size(), 1);
assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://localhost").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.
the class RouteServerResolverTest method shouldSetEndpointOrigin.
@Test
public void shouldSetEndpointOrigin() {
// given
Route route = new RouteBuilder().withNewMetadata().addToAnnotations(Annotations.newSerializer().machineName("m1").server("svr", new ServerConfigImpl().withPort("8080").withProtocol("http").withPath("/kachny")).annotations()).endMetadata().withNewSpec().withHost("che.host").endSpec().build();
RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
// when
Map<String, ServerImpl> resolvedServers = serverResolver.resolve("m1");
// then
ServerImpl svr = resolvedServers.get("svr");
assertNotNull(svr);
assertEquals("/", ServerConfig.getEndpointOrigin(svr.getAttributes()));
assertEquals("http://che.host/kachny", svr.getUrl());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.
the class RouteServerResolverTest method testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine.
@Test
public void testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine() {
Route route = createRoute("matched", "machine", ImmutableMap.of("http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));
RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
assertEquals(resolved.size(), 1);
assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://localhost/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project devspaces-images by redhat-developer.
the class WorkspaceServiceTest method shouldGetWorkspaceWithExternalServersByDefault.
@Test
public void shouldGetWorkspaceWithExternalServersByDefault() throws Exception {
// given
WorkspaceImpl workspace = createWorkspace(createConfigDto());
String externalServerKey = "server2";
ServerImpl externalServer = createExternalServer();
Map<String, Server> servers = ImmutableMap.of("server1", 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(singletonMap(externalServerKey, newDto(ServerDto.class).withUrl(externalServer.getUrl()).withStatus(externalServer.getStatus()).withAttributes(externalServer.getAttributes()))));
// when
Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).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