org.kurento.jsonrpc.JsonUtils Java Examples

The following examples show how to use org.kurento.jsonrpc.JsonUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KurentoRoomServerApp.java    From kurento-room with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public KurentoClientProvider kmsManager() {

  JsonArray kmsUris = getPropertyJson(KMSS_URIS_PROPERTY, KMSS_URIS_DEFAULT, JsonArray.class);
  List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);

  if (kmsWsUris.isEmpty()) {
    throw new IllegalArgumentException(KMSS_URIS_PROPERTY
        + " should contain at least one kms url");
  }

  String firstKmsWsUri = kmsWsUris.get(0);

  if (firstKmsWsUri.equals("autodiscovery")) {
    log.info("Using autodiscovery rules to locate KMS on every pipeline");
    return new AutodiscoveryKurentoClientProvider();
  } else {
    log.info("Configuring Kurento Room Server to use first of the following kmss: " + kmsWsUris);
    return new FixedOneKmsManager(firstKmsWsUri);
  }
}
 
Example #2
Source File: SessionIdMessageTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void responseTest() {

  Data data = new Data();
  data.data1 = "Value1";

  Response<Data> response = new Response<Data>(1, data);
  response.setSessionId("xxxxxxx");

  String responseJson = response.toString();
  Assert.assertEquals(
      "{\"id\":1,\"result\":{\"data1\":\"Value1\",\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}",
      responseJson);

  log.debug(responseJson);

  Response<Data> newResponse = JsonUtils.fromJsonResponse(responseJson, Data.class);

  Assert.assertEquals(data.data1, newResponse.getResult().data1);
  Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx");
}
 
Example #3
Source File: SessionIdMessageTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void noResultResponseTest() {

  Response<Void> response = new Response<Void>(1);
  response.setSessionId("xxxxxxx");

  String responseJson = response.toString();
  JsonParser parser = new JsonParser();
  JsonObject expected = (JsonObject) parser
      .parse("{\"id\":1,\"result\":{\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}");
  JsonObject result = (JsonObject) parser.parse(responseJson);
  Assert.assertEquals(expected, result);

  log.debug(responseJson);

  Response<Void> newResponse = JsonUtils.fromJsonResponse(responseJson, Void.class);

  // Assert.assertEquals(null, newResponse.getResult());
  Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx");

}
 
Example #4
Source File: GenericMessageTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void requestTest() {

  Params params = new Params();
  params.param1 = "Value1";
  params.param2 = "Value2";
  params.data = new Data();
  params.data.data1 = "XX";
  params.data.data2 = "YY";

  Request<Params> request = new Request<Params>(1, "method", params);

  String requestJson = JsonUtils.toJsonRequest(request);

  log.debug(requestJson);

  Request<Params> newRequest = JsonUtils.fromJsonRequest(requestJson, Params.class);

  Assert.assertEquals(params.param1, newRequest.getParams().param1);
  Assert.assertEquals(params.param2, newRequest.getParams().param2);
  Assert.assertEquals(params.data.data1, newRequest.getParams().data.data1);
  Assert.assertEquals(params.data.data2, newRequest.getParams().data.data2);

}
 
Example #5
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void jsonToPropsConversion() {

  Props param = new Props();
  param.add("prop1", "XXX");
  param.add("prop2", 33);
  param.add("prop3", "YYY");
  param.add("prop4", 5.5f);

  JsonObject jsonObject = JsonUtils.toJsonObject(param);

  assertEquals(jsonObject.get("prop1").getAsString(), "XXX");
  assertEquals(jsonObject.get("prop2").getAsInt(), 33);
  assertEquals(jsonObject.get("prop3").getAsString(), "YYY");
  assertEquals(jsonObject.get("prop4").getAsFloat(), 5.5f, 0.01);

}
 
Example #6
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void propsToJsonConversion() {

  JsonObject jsonObject = new JsonObject();
  jsonObject.addProperty("prop1", "XXX");
  jsonObject.addProperty("prop2", 33);
  jsonObject.addProperty("prop3", "YYY");
  jsonObject.addProperty("prop4", 5.5f);

  Props props = JsonUtils.fromJson(jsonObject, Props.class);

  assertEquals(props.getProp("prop1"), "XXX");
  assertEquals(props.getProp("prop2"), 33);
  assertEquals(props.getProp("prop3"), "YYY");
  assertEquals(props.getProp("prop4"), 5.5f);
}
 
Example #7
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void objectToJsonConversion() {

  JsonObject jsonObject = new JsonObject();
  jsonObject.addProperty("prop1", "XXX");
  jsonObject.addProperty("prop2", 33);
  jsonObject.addProperty("prop3", "YYY");
  jsonObject.addProperty("prop4", 5.5f);

  ComplexParam param = JsonUtils.fromJson(jsonObject, ComplexParam.class);

  assertEquals(param.getProp1(), "XXX");
  assertEquals(param.getProp2(), 33);
  assertEquals(param.getProp3(), "YYY");
  assertEquals(param.getProp4(), 5.5f, 0.01);
}
 
Example #8
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void jsonToObjectListConversion() {

  ComplexParam param = new ComplexParam("XXX", 33);
  param.setProp3("YYY");
  param.setProp4(5.5f);

  ComplexParam param2 = new ComplexParam("XXX2", 66);
  param2.setProp3("YYY2");
  param2.setProp4(11.5f);

  List<ComplexParam> params = new ArrayList<>();
  params.add(param);
  params.add(param2);

  JsonArray jsonArray = (JsonArray) JsonUtils.toJsonElement(params);

  JsonObject obj0 = (JsonObject) jsonArray.get(0);
  assertEquals(obj0.get("prop1").getAsString(), "XXX");
  assertEquals(obj0.get("prop2").getAsInt(), 33);
  assertEquals(obj0.get("prop3").getAsString(), "YYY");
  assertEquals(obj0.get("prop4").getAsFloat(), 5.5f, 0.01);

  JsonObject obj1 = (JsonObject) jsonArray.get(1);
  assertEquals(obj1.get("prop1").getAsString(), "XXX2");
  assertEquals(obj1.get("prop2").getAsInt(), 66);
  assertEquals(obj1.get("prop3").getAsString(), "YYY2");
  assertEquals(obj1.get("prop4").getAsFloat(), 11.5f, 0.01);

}
 
Example #9
Source File: KmsEvent.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public JsonObject toJson() {
	JsonObject json = JsonUtils.toJsonObject(event);
	json.remove("tags");
	json.remove("timestampMillis");
	json.addProperty("timestamp", timestamp);
	json.addProperty("sessionId", participant.getSessionId());
	json.addProperty("user", participant.getFinalUserId());
	json.addProperty("connection", participant.getParticipantPublicId());
	json.addProperty("endpoint", this.endpoint);
	json.addProperty("msSinceEndpointCreation", msSinceCreation);
	return json;
}
 
Example #10
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void integerListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive(1));
  array.add(new JsonPrimitive(2));
  array.add(new JsonPrimitive(3));

  List<Integer> list = JsonUtils.fromJson(array, new TypeToken<List<Integer>>() {
  }.getType());

  assertEquals(list.get(0), (Integer) 1);
  assertEquals(list.get(1), (Integer) 2);
  assertEquals(list.get(2), (Integer) 3);
}
 
Example #11
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void floatListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive(0.1));
  array.add(new JsonPrimitive(0.2));
  array.add(new JsonPrimitive(0.3));

  List<Float> list = JsonUtils.fromJson(array, new TypeToken<List<Float>>() {
  }.getType());

  assertEquals(list.get(0), 0.1, 0.01);
  assertEquals(list.get(1), 0.2, 0.01);
  assertEquals(list.get(2), 0.3, 0.01);
}
 
Example #12
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void booleanListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive(true));
  array.add(new JsonPrimitive(false));
  array.add(new JsonPrimitive(true));

  @SuppressWarnings("unchecked")
  List<Boolean> list = JsonUtils.fromJson(array, List.class);

  assertEquals(list.get(0), true);
  assertEquals(list.get(1), false);
  assertEquals(list.get(2), true);
}
 
Example #13
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void stringToEnumListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive("CONST1"));
  array.add(new JsonPrimitive("CONST2"));
  array.add(new JsonPrimitive("CONST3"));

  List<EnumType> list = JsonUtils.fromJson(array, new TypeToken<List<EnumType>>() {
  }.getType());

  assertEquals(list.get(0), EnumType.CONST1);
  assertEquals(list.get(1), EnumType.CONST2);
  assertEquals(list.get(2), EnumType.CONST3);
}
 
Example #14
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void enumToStringListConversion() {

  List<EnumType> list = new ArrayList<EnumType>();
  list.add(EnumType.CONST1);
  list.add(EnumType.CONST2);
  list.add(EnumType.CONST3);

  JsonArray array = (JsonArray) JsonUtils.toJsonElement(list);

  assertEquals(array.get(0), new JsonPrimitive("CONST1"));
  assertEquals(array.get(1), new JsonPrimitive("CONST2"));
  assertEquals(array.get(2), new JsonPrimitive("CONST3"));
}
 
Example #15
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void jsonToObjectConversion() {

  ComplexParam param = new ComplexParam("XXX", 33);
  param.setProp3("YYY");
  param.setProp4(5.5f);

  JsonObject jsonObject = JsonUtils.toJsonObject(param);

  assertEquals(jsonObject.get("prop1").getAsString(), "XXX");
  assertEquals(jsonObject.get("prop2").getAsInt(), 33);
  assertEquals(jsonObject.get("prop3").getAsString(), "YYY");
  assertEquals(jsonObject.get("prop4").getAsFloat(), 5.5f, 0.01);

}
 
Example #16
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void objectListToJsonConversion() {

  JsonObject jsonObject = new JsonObject();
  jsonObject.addProperty("prop1", "XXX");
  jsonObject.addProperty("prop2", 33);
  jsonObject.addProperty("prop3", "YYY");
  jsonObject.addProperty("prop4", 5.5f);

  JsonArray array = new JsonArray();
  array.add(jsonObject);

  JsonObject jsonObject2 = new JsonObject();
  jsonObject2.addProperty("prop1", "XXX2");
  jsonObject2.addProperty("prop2", 66);
  jsonObject2.addProperty("prop3", "YYY2");
  jsonObject2.addProperty("prop4", 11.5f);

  array.add(jsonObject2);

  List<ComplexParam> params = JsonUtils.fromJson(array, new TypeToken<List<ComplexParam>>() {
  }.getType());

  assertEquals(params.get(0).getProp1(), "XXX");
  assertEquals(params.get(0).getProp2(), 33);
  assertEquals(params.get(0).getProp3(), "YYY");
  assertEquals(params.get(0).getProp4(), 5.5f, 0.01);

  assertEquals(params.get(1).getProp1(), "XXX2");
  assertEquals(params.get(1).getProp2(), 66);
  assertEquals(params.get(1).getProp3(), "YYY2");
  assertEquals(params.get(1).getProp4(), 11.5f, 0.01);
}
 
Example #17
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void stringListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive("XXX"));
  array.add(new JsonPrimitive("YYY"));
  array.add(new JsonPrimitive("ZZZ"));

  @SuppressWarnings("unchecked")
  List<String> list = JsonUtils.fromJson(array, List.class);

  assertEquals(list.get(0), "XXX");
  assertEquals(list.get(1), "YYY");
  assertEquals(list.get(2), "ZZZ");
}
 
Example #18
Source File: ProtocolManager.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
private void processResponseMessage(JsonObject messagetJsonObject, String internalSessionId) {

    Response<JsonElement> response = JsonUtils.fromJsonResponse(messagetJsonObject,
        JsonElement.class);

    ServerSession session = sessionsManager.getByTransportId(internalSessionId);

    if (session != null) {
      session.handleResponse(response);
    } else {
      log.debug("Processing response {} for non-existent session {}", response.toString(),
          internalSessionId);
    }
  }
 
Example #19
Source File: UserSession.java    From kurento-tutorial-java with Apache License 2.0 5 votes vote down vote up
public UserSession(final String name, String roomName, final WebSocketSession session,
    MediaPipeline pipeline) {

  this.pipeline = pipeline;
  this.name = name;
  this.session = session;
  this.roomName = roomName;
  this.outgoingMedia = new WebRtcEndpoint.Builder(pipeline).build();

  this.outgoingMedia.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {

    @Override
    public void onEvent(IceCandidateFoundEvent event) {
      JsonObject response = new JsonObject();
      response.addProperty("id", "iceCandidate");
      response.addProperty("name", name);
      response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
      try {
        synchronized (session) {
          session.sendMessage(new TextMessage(response.toString()));
        }
      } catch (IOException e) {
        log.debug(e.getMessage());
      }
    }
  });
}
 
Example #20
Source File: UserSession.java    From kurento-tutorial-java with Apache License 2.0 5 votes vote down vote up
private WebRtcEndpoint getEndpointForUser(final UserSession sender) {
  if (sender.getName().equals(name)) {
    log.debug("PARTICIPANT {}: configuring loopback", this.name);
    return outgoingMedia;
  }

  log.debug("PARTICIPANT {}: receiving video from {}", this.name, sender.getName());

  WebRtcEndpoint incoming = incomingMedia.get(sender.getName());
  if (incoming == null) {
    log.debug("PARTICIPANT {}: creating new endpoint for {}", this.name, sender.getName());
    incoming = new WebRtcEndpoint.Builder(pipeline).build();

    incoming.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {

      @Override
      public void onEvent(IceCandidateFoundEvent event) {
        JsonObject response = new JsonObject();
        response.addProperty("id", "iceCandidate");
        response.addProperty("name", sender.getName());
        response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
        try {
          synchronized (session) {
            session.sendMessage(new TextMessage(response.toString()));
          }
        } catch (IOException e) {
          log.debug(e.getMessage());
        }
      }
    });

    incomingMedia.put(sender.getName(), incoming);
  }

  log.debug("PARTICIPANT {}: obtained endpoint for {}", this.name, sender.getName());
  sender.getOutgoingWebRtcPeer().connect(incoming);

  return incoming;
}
 
Example #21
Source File: OpenviduConfig.java    From openvidu with Apache License 2.0 5 votes vote down vote up
protected List<String> asJsonStringsArray(String property) {
	try {
		Gson gson = new Gson();
		JsonArray jsonArray = gson.fromJson(getValue(property), JsonArray.class);
		List<String> list = JsonUtils.toStringList(jsonArray);
		if (list.size() == 1 && list.get(0).isEmpty()) {
			list = new ArrayList<>();
		}
		return list;
	} catch (JsonSyntaxException e) {
		addError(property, "Is not a valid strings array in JSON format. " + e.getMessage());
		return Arrays.asList();
	}
}
 
Example #22
Source File: KStream.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
private WebRtcEndpoint createEndpoint(final StreamProcessor processor, String sid, String uid) {
	WebRtcEndpoint endpoint = createWebRtcEndpoint(room.getPipeline());
	endpoint.addTag("outUid", this.uid);
	endpoint.addTag("uid", uid);

	endpoint.addIceCandidateFoundListener(evt -> processor.getHandler().sendClient(sid
			, newKurentoMsg()
				.put("id", "iceCandidate")
				.put("uid", KStream.this.uid)
				.put(PARAM_CANDIDATE, convert(JsonUtils.toJsonObject(evt.getCandidate()))))
			);
	return endpoint;
}
 
Example #23
Source File: KurentoRoomDemoApp.java    From kurento-room with Apache License 2.0 5 votes vote down vote up
@Override
public KmsManager kmsManager() {
  JsonArray kmsUris = getPropertyJson(KurentoRoomServerApp.KMSS_URIS_PROPERTY,
      KurentoRoomServerApp.KMSS_URIS_DEFAULT, JsonArray.class);
  List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);

  log.info("Configuring Kurento Room Server to use the following kmss: {}", kmsWsUris);

  FixedNKmsManager fixedKmsManager = new FixedNKmsManager(kmsWsUris, DEMO_KMS_NODE_LIMIT);
  fixedKmsManager.setAuthRegex(DEMO_AUTH_REGEX);
  log.debug("Authorization regex for new rooms: {}", DEMO_AUTH_REGEX);
  return fixedKmsManager;
}
 
Example #24
Source File: RomServerJsonRpcHandler.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
private void handleInvokeCommand(Transaction transaction, String objectRef, String operationName,
    JsonObject operationParams) throws IOException {

  Object result = server.invoke(objectRef, operationName,
      JsonUtils.fromJson(operationParams, Props.class), Object.class);

  transaction.sendResponse(result);
}
 
Example #25
Source File: RomClientJsonRpcClient.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("serial")
public void transaction(final List<Operation> operations, final Continuation<Void> continuation) {

  JsonArray opJsons = new JsonArray();
  final List<RequestAndResponseType> opReqres = new ArrayList<>();

  int numReq = 0;
  for (Operation op : operations) {
    RequestAndResponseType reqres = op.createRequest(this);
    opReqres.add(reqres);
    reqres.request.setId(numReq);
    opJsons.add(JsonUtils.toJsonElement(reqres.request));
    numReq++;
  }

  JsonObject params = new JsonObject();
  params.add(TRANSACTION_OPERATIONS, opJsons);

  DefaultContinuation<List<Response<JsonElement>>> wrappedContinuation = null;

  if (continuation != null) {
    wrappedContinuation = new DefaultContinuation<List<Response<JsonElement>>>(continuation) {
      @Override
      public void onSuccess(List<Response<JsonElement>> responses) throws Exception {
        processTransactionResponse(operations, opReqres, responses);
        continuation.onSuccess(null);
      }
    };
  }

  List<Response<JsonElement>> responses = this.sendRequest(
      new Request<>(TRANSACTION_METHOD, params), new TypeToken<List<Response<JsonElement>>>() {
      }.getType(), null, wrappedContinuation);

  if (continuation == null) {
    processTransactionResponse(operations, opReqres, responses);
  }
}
 
Example #26
Source File: RomClientJsonRpcClient.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
public RequestAndResponseType createUnsubscribeRequest(String objectRef,
    String listenerSubscription) {

  JsonObject params = JsonUtils.toJsonObject(
      new Props(UNSUBSCRIBE_OBJECT, objectRef).add(UNSUBSCRIBE_LISTENER, listenerSubscription));

  return new RequestAndResponseType(new Request<>(UNSUBSCRIBE_METHOD, params), Void.class);
}
 
Example #27
Source File: RomJsonConverterTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void stringToEnumConversion() {
  assertEquals(JsonUtils.fromJson(new JsonPrimitive("CONST1"), EnumType.class), EnumType.CONST1);
}
 
Example #28
Source File: ProtocolManager.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
private void processRequestMessage(ServerSessionFactory factory, JsonObject requestJsonObject,
    final ResponseSender responseSender, String transportId) throws IOException {

  final Request<JsonElement> request = JsonUtils.fromJsonRequest(requestJsonObject,
      JsonElement.class);

  switch (request.getMethod()) {
  case METHOD_CONNECT:

    log.debug("{} Req-> {} (transportId={})", label, request, transportId);
    processReconnectMessage(factory, request, responseSender, transportId);
    break;
  case METHOD_PING:
    log.trace("{} Req-> {} (transportId={})", label, request, transportId);
    processPingMessage(factory, request, responseSender, transportId);
    break;

  case METHOD_CLOSE:
    log.trace("{} Req-> {} (transportId={})", label, request, transportId);
    processCloseMessage(factory, request, responseSender, transportId);

    break;
  default:

    final ServerSession session = getOrCreateSession(factory, transportId, request);

    log.debug("{} Req-> {} [jsonRpcSessionId={}, transportId={}]", label, request,
        session.getSessionId(), transportId);

    // TODO, Take out this an put in Http specific handler. The main
    // reason is to wait for request before responding to the client.
    // And for no contaminate the ProtocolManager.
    if (request.getMethod().equals(Request.POLL_METHOD_NAME)) {

      Type collectionType = new TypeToken<List<Response<JsonElement>>>() {
      }.getType();

      List<Response<JsonElement>> responseList = JsonUtils.fromJson(request.getParams(),
          collectionType);

      for (Response<JsonElement> response : responseList) {
        session.handleResponse(response);
      }

      // Wait for some time if there is a request from server to
      // client

      // TODO Allow send empty responses. Now you have to send at
      // least an
      // empty string
      responseSender.sendResponse(new Response<Object>(request.getId(), Collections.emptyList()));

    } else {
      session.processRequest(new Runnable() {
        @Override
        public void run() {
          handlerManager.handleRequest(session, request, responseSender);
        }
      });
    }
    break;
  }

}
 
Example #29
Source File: RomClientJsonRpcClient.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
public RequestAndResponseType createInvokeRequest(String objectRef, String operationName,
    Props operationParams, Type type, boolean inTx) {

  JsonObject params = new JsonObject();
  params.addProperty(INVOKE_OBJECT, objectRef);
  params.addProperty(INVOKE_OPERATION_NAME, operationName);

  if (operationParams != null) {

    Props flatParams = ParamsFlattener.getInstance().flattenParams(operationParams, inTx);

    params.add(INVOKE_OPERATION_PARAMS, JsonUtils.toJsonObject(flatParams));
  }

  return new RequestAndResponseType(new Request<>(INVOKE_METHOD, params), type);
}
 
Example #30
Source File: SessionIdMessageTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void noParamsRequestTest() {

  Request<Void> request = new Request<Void>(1, "method", null);
  request.setSessionId("xxxxxxx");

  String requestJson = request.toString();
  Assert.assertEquals(
      "{\"id\":1,\"method\":\"method\",\"jsonrpc\":\"2.0\",\"params\":{\"sessionId\":\"xxxxxxx\"}}",
      requestJson);

  log.debug(requestJson);

  Request<Void> newRequest = JsonUtils.fromJsonRequest(requestJson, Void.class);

  // Assert.assertEquals(null, newRequest.getParams());
  Assert.assertEquals(newRequest.getSessionId(), "xxxxxxx");

}