Search in sources :

Example 61 with JsonArray

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

the class JsonRpcListTest method shouldToListParsedBooleanArray.

@Test
public void shouldToListParsedBooleanArray() throws Exception {
    JsonArray array = new JsonArray();
    array.add(new JsonPrimitive(false));
    String message = array.toString();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonParser);
    List<Boolean> actual = jsonRpcList.toList(Boolean.class);
    assertEquals(singletonList(false), actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) Test(org.testng.annotations.Test)

Example 62 with JsonArray

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

the class JsonRpcListTest method shouldToJsonArrayCreatedDoubleArray.

@Test
public void shouldToJsonArrayCreatedDoubleArray() throws Exception {
    JsonArray expected = new JsonArray();
    expected.add(new JsonPrimitive(0D));
    JsonRpcList jsonRpcList = new JsonRpcList(singletonList(0D), 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 63 with JsonArray

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

the class JsonRpcListTest method shouldToStringArrayParsedNumberArray.

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

Example 64 with JsonArray

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

the class JsonRpcListTest method shouldToStringCreatedBooleanArray.

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

Example 65 with JsonArray

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

the class JsonRpcListTest method shouldToStringifiedListParsedBooleanArray.

@Test
public void shouldToStringifiedListParsedBooleanArray() throws Exception {
    Boolean expected = false;
    JsonArray array = new JsonArray();
    array.add(new JsonPrimitive(expected));
    String message = array.toString();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonParser);
    List<String> actual = jsonRpcList.toStringifiedList();
    assertEquals(expected, Boolean.valueOf(actual.iterator().next()));
}
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