Search in sources :

Example 46 with JsonObject

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

the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto.

@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto() throws Exception {
    JsonArray expected = new JsonArray();
    JsonObject value = jsonParser.parse(dto.toString()).getAsJsonObject();
    expected.add(value);
    JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(dto), jsonParser);
    JsonElement actual = jsonRpcResult.toJsonElement();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 47 with JsonObject

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

the class JsonRpcResultTest method shouldGetAsVoidWhenParsingStringWithResultAsVoid.

//Void
@Test
public void shouldGetAsVoidWhenParsingStringWithResultAsVoid() throws Exception {
    JsonObject value = new JsonObject();
    Void expected = null;
    JsonRpcResult jsonRpcResult = new JsonRpcResult(value.toString(), jsonParser);
    Void actual = jsonRpcResult.getAs(Void.class);
    assertEquals(expected, actual);
}
Also used : JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 48 with JsonObject

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

the class JsonRpcResultTest method shouldToStringWhenParsingStringWithResultAsASingleVoid.

@Test
public void shouldToStringWhenParsingStringWithResultAsASingleVoid() throws Exception {
    JsonObject value = new JsonObject();
    String expected = value.toString();
    JsonRpcResult jsonRpcResult = new JsonRpcResult(value.toString(), jsonParser);
    String actual = jsonRpcResult.toString();
    assertEquals(expected, actual);
}
Also used : JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 49 with JsonObject

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

the class JsonRpcResultTest method shouldToStringWhenPassingParametersWithResultAsAListOfDto.

@Test
public void shouldToStringWhenPassingParametersWithResultAsAListOfDto() throws Exception {
    JsonArray array = new JsonArray();
    JsonObject value = jsonParser.parse(dto.toString()).getAsJsonObject();
    array.add(value);
    String expected = array.toString();
    JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(dto), jsonParser);
    String actual = jsonRpcResult.toString();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 50 with JsonObject

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

the class JsonRpcParamsTest method shouldToStringForParsedListDtoParams.

@Test
public void shouldToStringForParsedListDtoParams() throws Exception {
    JsonArray array = new JsonArray();
    JsonObject jsonObject = jsonParser.parse(DTO_JSON).getAsJsonObject();
    array.add(jsonObject);
    String expected = array.toString();
    JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + DTO_JSON + "]", jsonParser);
    String actual = jsonRpcParams.toString();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) Matchers.anyString(org.mockito.Matchers.anyString) 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