Search in sources :

Example 36 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.

the class JsonRpcResponseTest method shouldToJsonObjectWhenPassingParametersWithResult.

@Test
public void shouldToJsonObjectWhenPassingParametersWithResult() throws Exception {
    JsonObject expected = response;
    expected.remove("error");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(ID, result, null);
    JsonObject actual = jsonRpcResponse.toJsonObject();
    assertEquals(expected, actual);
}
Also used : JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 37 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.

the class JsonRpcParamsTest method shouldToJsonForCreatedSingleDtoParams.

@Test
public void shouldToJsonForCreatedSingleDtoParams() throws Exception {
    JsonObject expected = jsonParser.parse(dto.toString()).getAsJsonObject();
    JsonRpcParams jsonRpcParams = new JsonRpcParams(dto, jsonParser);
    JsonElement actual = jsonRpcParams.toJsonElement();
    assertEquals(expected, actual);
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 38 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.

the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams.

@Test
public void shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(true);
    JsonObject expected = request;
    expected.remove("params");
    expected.remove("id");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("method", params, jsonParser);
    JsonElement actual = jsonParser.parse(jsonRpcRequest.toString());
    assertEquals(expected, actual);
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 39 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.

the class JsonRpcRequestTest method shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithoutParams.

@Test
public void shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    expected.remove("params");
    expected.remove("id");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toString(), jsonParser, jsonRpcFactory);
    JsonObject actual = jsonRpcRequest.toJsonObject();
    assertEquals(expected, actual);
}
Also used : JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 40 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.

the class JsonRpcRequestTest method shouldToJsonObjectWhenParseStringParamsWithIdAndWithoutParams.

@Test
public void shouldToJsonObjectWhenParseStringParamsWithIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    expected.remove("params");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toString(), jsonParser, jsonRpcFactory);
    JsonObject actual = jsonRpcRequest.toJsonObject();
    assertEquals(expected, actual);
}
Also used : JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Aggregations

JsonObject (com.google.gson.JsonObject)5111 JsonArray (com.google.gson.JsonArray)1162 JsonElement (com.google.gson.JsonElement)1084 JsonParser (com.google.gson.JsonParser)710 Test (org.junit.Test)491 IOException (java.io.IOException)471 JsonPrimitive (com.google.gson.JsonPrimitive)387 ArrayList (java.util.ArrayList)376 Gson (com.google.gson.Gson)369 HashMap (java.util.HashMap)324 Map (java.util.Map)269 Test (org.testng.annotations.Test)208 Test (org.junit.jupiter.api.Test)201 File (java.io.File)146 List (java.util.List)142 InputStreamReader (java.io.InputStreamReader)135 JsonParseException (com.google.gson.JsonParseException)121 GsonBuilder (com.google.gson.GsonBuilder)93 JsonSyntaxException (com.google.gson.JsonSyntaxException)88 Nonnull (javax.annotation.Nonnull)87