use of org.eclipse.che.api.machine.shared.Constants.TERMINAL_REFERENCE in project che by eclipse.
the class MachineServiceLinksInjectorTest method shouldInjectLinksIntoMachineDto.
@Test
public void shouldInjectLinksIntoMachineDto() {
when(terminalServerMock.getRef()).thenReturn(TERMINAL_REFERENCE);
when(terminalServerMock.getUrl()).thenReturn(URI_BASE + "/pty");
when(execAgentServerMock.getRef()).thenReturn(EXEC_AGENT_REFERENCE);
when(execAgentServerMock.getUrl()).thenReturn(URI_BASE + "/connect");
when(machineRuntimeInfoDtoMock.getServers()).thenReturn(ImmutableMap.of(TERMINAL_REFERENCE, terminalServerMock, EXEC_AGENT_REFERENCE, execAgentServerMock));
final MachineDto machineDto = DtoFactory.newDto(MachineDto.class).withId("id").withWorkspaceId("wsId").withConfig(machineConfigDtoMock).withRuntime(machineRuntimeInfoDtoMock);
machineLinksInjector.injectLinks(machineDto, serviceContextMock);
final Set<Pair<String, String>> links = machineDto.getLinks().stream().map(link -> Pair.of(link.getMethod(), link.getRel())).collect(Collectors.toSet());
final Set<Pair<String, String>> expectedLinks = new HashSet<>(asList(Pair.of("GET", TERMINAL_REFERENCE), Pair.of("GET", EXEC_AGENT_REFERENCE), Pair.of("GET", LINK_REL_ENVIRONMENT_OUTPUT_CHANNEL), Pair.of("GET", ENVIRONMENT_STATUS_CHANNEL_TEMPLATE)));
assertEquals(links, expectedLinks, "Difference " + Sets.symmetricDifference(links, expectedLinks) + "\n");
}
Aggregations