Search in sources :

Example 71 with JsonArray

use of com.google.gson.JsonArray in project che by eclipse.

the class JsonRpcParamsTest method shouldToStringForParsedListStringParams.

@Test
public void shouldToStringForParsedListStringParams() throws Exception {
    String value = "value";
    JsonArray array = new JsonArray();
    array.add(new JsonPrimitive(value));
    String expected = array.toString();
    JsonRpcParams jsonRpcParams = new JsonRpcParams("[\"" + value + "\"]", jsonParser);
    String actual = jsonRpcParams.toString();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 72 with JsonArray

use of com.google.gson.JsonArray in project che by eclipse.

the class JsonRpcListTest method shouldToJsonArrayParsedBooleanArray.

@Test
public void shouldToJsonArrayParsedBooleanArray() throws Exception {
    Boolean expected = false;
    JsonArray array = new JsonArray();
    array.add(new JsonPrimitive(expected));
    String message = array.toString();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonParser);
    JsonArray actual = jsonRpcList.toJsonArray();
    assertEquals(array, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) Test(org.testng.annotations.Test)

Example 73 with JsonArray

use of com.google.gson.JsonArray in project che by eclipse.

the class JsonRpcListTest method shouldParseNumberArray.

@Test
public void shouldParseNumberArray() throws Exception {
    Double expected = 0D;
    JsonArray array = new JsonArray();
    array.add(new JsonPrimitive(expected));
    String message = array.toString();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonParser);
    Double actual = jsonRpcList.get(0, Double.class);
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) Test(org.testng.annotations.Test)

Example 74 with JsonArray

use of com.google.gson.JsonArray in project che by eclipse.

the class JsonRpcListTest method shouldToJsonArrayCreatedStringArray.

@Test
public void shouldToJsonArrayCreatedStringArray() throws Exception {
    JsonArray expected = new JsonArray();
    expected.add(new JsonPrimitive("a"));
    JsonRpcList jsonRpcList = new JsonRpcList(singletonList("a"), jsonParser);
    JsonArray actual = jsonRpcList.toJsonArray();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) Test(org.testng.annotations.Test)

Example 75 with JsonArray

use of com.google.gson.JsonArray in project che by eclipse.

the class JsonRpcListTest method shouldToJsonArrayParsedNumberArray.

@Test
public void shouldToJsonArrayParsedNumberArray() throws Exception {
    JsonArray expected = new JsonArray();
    expected.add(new JsonPrimitive(0D));
    String message = expected.toString();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonParser);
    JsonArray actual = jsonRpcList.toJsonArray();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) Test(org.testng.annotations.Test)

Aggregations

JsonArray (com.google.gson.JsonArray)424 JsonObject (com.google.gson.JsonObject)290 JsonElement (com.google.gson.JsonElement)167 JsonPrimitive (com.google.gson.JsonPrimitive)118 Test (org.testng.annotations.Test)59 JsonParser (com.google.gson.JsonParser)57 ArrayList (java.util.ArrayList)50 HashMap (java.util.HashMap)34 Map (java.util.Map)34 Gson (com.google.gson.Gson)22 IOException (java.io.IOException)17 Test (org.junit.Test)16 Type (java.lang.reflect.Type)12 List (java.util.List)11 Matchers.anyString (org.mockito.Matchers.anyString)10 TextView (android.widget.TextView)9 Point (android.graphics.Point)8 JsonParseException (com.google.gson.JsonParseException)7 GsonUtilities.jboolean (com.ibm.streamsx.topology.internal.gson.GsonUtilities.jboolean)7 KcaUtils.getStringFromException (com.antest1.kcanotify.KcaUtils.getStringFromException)6