Search in sources :

Example 26 with JsonObject

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

the class JsonRpcRequestTest method shouldToStringWhenParseStringParamsWithIdAndWithParams.

@Test
public void shouldToStringWhenParseStringParamsWithIdAndWithParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toString(), jsonParser, jsonRpcFactory);
    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 27 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenPassStringParamsWithIdAndWithParams.

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

Example 28 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenPassStringParamsWithIdAndWithoutParams.

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

Example 29 with JsonObject

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

the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithoutParams.

@Test
public void shouldToStringWhenPassStringParamsWithIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(true);
    JsonObject expected = request;
    expected.remove("params");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("0", "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 30 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithParams.

@Test
public void shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    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)

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