use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class DefaultHttpJsonResponseTest method shouldBeAbleToRequestListOfJsonSerializableElements.
@Test
public void shouldBeAbleToRequestListOfJsonSerializableElements() throws Exception {
final Link testLink = createLink("POST", "http://localhost:8080", "rel");
final String responseBody = DtoFactory.getInstance().toJson(new JsonArrayImpl<>(singletonList(testLink)));
final DefaultHttpJsonResponse response = new DefaultHttpJsonResponse(responseBody, 200);
assertEquals(response.asList(Link.class), singletonList(testLink));
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class ServiceDescriptorTest method testLinkParameters.
@Test
public void testLinkParameters() throws Exception {
Link link = getLink("echo");
List<LinkParameter> parameters = link.getParameters();
Assert.assertEquals(parameters.size(), 1);
LinkParameter linkParameter = parameters.get(0);
Assert.assertEquals(linkParameter.getDefaultValue(), "a");
Assert.assertEquals(linkParameter.getDescription(), "some text");
Assert.assertEquals(linkParameter.getName(), "text");
Assert.assertEquals(linkParameter.getType(), ParameterType.String);
Assert.assertTrue(linkParameter.isRequired());
List<String> valid = linkParameter.getValid();
Assert.assertEquals(valid.size(), 2);
Assert.assertTrue(valid.contains("a"));
Assert.assertTrue(valid.contains("b"));
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class WorkspaceEventsHandler method subscribeOnEnvironmentOutputChannel.
private void subscribeOnEnvironmentOutputChannel(WorkspaceDto workspace) {
if (environmentOutputSubscriptionHandler != null) {
return;
}
final Link link = workspace.getLink(LINK_REL_ENVIRONMENT_OUTPUT_CHANNEL);
final LinkParameter logsChannelLinkParameter = link.getParameter("channel");
if (logsChannelLinkParameter == null) {
return;
}
environmentOutputChannel = logsChannelLinkParameter.getDefaultValue();
environmentOutputSubscriptionHandler = new EnvironmentOutputSubscriptionHandler();
subscribeToChannel(environmentOutputChannel, environmentOutputSubscriptionHandler);
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class WorkspaceEventsHandler method subscribeOnEnvironmentStatusChannel.
private void subscribeOnEnvironmentStatusChannel(WorkspaceDto workspace) {
if (environmentStatusSubscriptionHandler != null) {
return;
}
final Link link = workspace.getLink(LINK_REL_ENVIRONMENT_STATUS_CHANNEL);
final LinkParameter statusChannelLinkParameter = link.getParameter("channel");
if (statusChannelLinkParameter == null) {
return;
}
environmentStatusChannel = statusChannelLinkParameter.getDefaultValue();
environmentStatusSubscriptionHandler = new EnvironmentStatusSubscriptionHandler();
subscribeToChannel(environmentStatusChannel, environmentStatusSubscriptionHandler);
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class WorkspaceEventsHandler method subscribeToWorkspaceStatusEvents.
private void subscribeToWorkspaceStatusEvents(final WorkspaceDto workspace) {
final Link workspaceEventsLink = workspace.getLink(LINK_REL_GET_WORKSPACE_EVENTS_CHANNEL);
if (workspaceEventsLink == null) {
//should never be
notificationManager.notify(locale.workspaceSubscribeOnEventsFailed(), FAIL, EMERGE_MODE);
Log.error(getClass(), "Link " + LINK_REL_GET_WORKSPACE_EVENTS_CHANNEL + " not found in workspace links. So events will be not handle");
return;
}
workspaceStatusChannel = workspaceEventsLink.getParameter("channel").getDefaultValue();
if (isNullOrEmpty(workspaceStatusChannel)) {
//should never be
notificationManager.notify(locale.workspaceSubscribeOnEventsFailed(), FAIL, EMERGE_MODE);
Log.error(getClass(), "Channel for handling Workspace events not provide. So events will be not handle");
return;
}
try {
workspaceStatusSubscriptionHandler = new WorkspaceStatusSubscriptionHandler(workspace);
messageBus.subscribe(workspaceStatusChannel, workspaceStatusSubscriptionHandler);
} catch (WebSocketException exception) {
Log.error(getClass(), exception);
}
}
Aggregations