Search in sources :

Example 41 with JsonObject

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

the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithParams.

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

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

the class JsonRpcParamsTest method shouldToJsonValueForParsedListDtoParams.

@Test
public void shouldToJsonValueForParsedListDtoParams() throws Exception {
    JsonArray array = new JsonArray();
    JsonObject jsonObject = jsonParser.parse(DTO_JSON).getAsJsonObject();
    array.add(jsonObject);
    JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + DTO_JSON + "]", jsonParser);
    JsonElement jsonValue = jsonRpcParams.toJsonElement();
    assertEquals(array, jsonValue);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 43 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject 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);
}
Also used : JsonRpcEntityType(org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 44 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject 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);
}
Also used : JsonRpcEntityType(org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 45 with JsonObject

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject 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);
}
Also used : JsonRpcEntityType(org.eclipse.che.api.core.jsonrpc.JsonRpcEntityQualifier.JsonRpcEntityType) 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