Search in sources :

Example 31 with JsonObject

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

the class JsonRpcResponseTest method shouldToStringWhenPassingParametersWithError.

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

Example 32 with JsonObject

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

the class JsonRpcResponseTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    response = new JsonObject();
    JsonObject error = new JsonObject();
    JsonObject result = new JsonObject();
    error.addProperty("code", 0);
    error.addProperty("message", "error message");
    response.addProperty("jsonrpc", "2.0");
    response.addProperty("id", "0");
    response.add("error", error);
    response.add("result", result);
    when(this.result.toJsonElement()).thenReturn(result);
    when(this.error.toJsonObject()).thenReturn(error);
}
Also used : JsonObject(com.google.gson.JsonObject) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 33 with JsonObject

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

the class JsonRpcResponseTest method shouldToStringWhenParsingStringWithError.

@Test
public void shouldToStringWhenParsingStringWithError() throws Exception {
    JsonObject expected = response;
    expected.remove("result");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(expected.toString(), jsonParser);
    JsonElement actual = jsonParser.parse(jsonRpcResponse.toString());
    assertEquals(expected, actual);
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 34 with JsonObject

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

the class JsonRpcResponseTest method shouldToJsonObjectWhenParsingStringWithError.

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

Example 35 with JsonObject

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

the class JsonRpcResponseTest method shouldToJsonObjectWhenPassingParametersWithError.

@Test
public void shouldToJsonObjectWhenPassingParametersWithError() throws Exception {
    JsonObject expected = response;
    expected.remove("result");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(ID, null, error);
    JsonObject actual = jsonRpcResponse.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