use of org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType in project che by eclipse.
the class JsonRpcMessageReceiver method processObject.
private void processObject(String endpointId, String message) throws JsonRpcException {
LOG.debug("Processing end object: " + message);
JsonRpcEntityType type = entityQualifier.qualify(message);
switch(type) {
case REQUEST:
JsonRpcRequest request = jsonRpcFactory.createRequest(message);
requestDispatcher.dispatch(endpointId, request);
break;
case RESPONSE:
JsonRpcResponse response = jsonRpcFactory.createResponse(message);
responseDispatcher.dispatch(endpointId, response);
break;
case UNDEFINED:
default:
String msg = "The JSON sent is not a valid Request object";
LOG.error(msg);
throw new JsonRpcException(-32600, msg);
}
}
use of org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType in project che by eclipse.
the class JsonRpcEntityQualifierTest method shouldQualifyUndefinedWhenMessageContainsResultAndError.
@Test
public void shouldQualifyUndefinedWhenMessageContainsResultAndError() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("error", "error-value");
jsonObject.addProperty("result", "result-value");
JsonRpcEntityType type = qualifier.qualify(jsonObject.toString());
assertEquals(JsonRpcEntityType.UNDEFINED, type);
}
use of org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType in project che by eclipse.
the class JsonRpcEntityQualifierTest method shouldQualifyResponseWhenMessageContainsResult.
@Test
public void shouldQualifyResponseWhenMessageContainsResult() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("result", "result-value");
JsonRpcEntityType type = qualifier.qualify(jsonObject.toString());
assertEquals(JsonRpcEntityType.RESPONSE, type);
}
use of org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType in project che by eclipse.
the class JsonRpcEntityQualifierTest method shouldQualifyResponseWhenMessageContainsError.
@Test
public void shouldQualifyResponseWhenMessageContainsError() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("error", "error-value");
JsonRpcEntityType type = qualifier.qualify(jsonObject.toString());
assertEquals(JsonRpcEntityType.RESPONSE, type);
}
use of org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType in project che by eclipse.
the class JsonRpcEntityQualifierTest method shouldQualifyRequestWhenMessageContainsMethod.
@Test
public void shouldQualifyRequestWhenMessageContainsMethod() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("method", "method-name");
JsonRpcEntityType type = qualifier.qualify(jsonObject.toString());
assertEquals(JsonRpcEntityType.REQUEST, type);
}
Aggregations