Search in sources :

Example 31 with JsonPrimitive

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

the class JsonRpcListTest method shouldToJsonArrayCreatedBooleanArray.

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

use of com.google.gson.JsonPrimitive 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 33 with JsonPrimitive

use of com.google.gson.JsonPrimitive 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 34 with JsonPrimitive

use of com.google.gson.JsonPrimitive 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 35 with JsonPrimitive

use of com.google.gson.JsonPrimitive 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)

Aggregations

JsonPrimitive (com.google.gson.JsonPrimitive)230 JsonObject (com.google.gson.JsonObject)137 JsonArray (com.google.gson.JsonArray)118 JsonElement (com.google.gson.JsonElement)106 Test (org.testng.annotations.Test)56 Test (org.junit.Test)12 Map (java.util.Map)10 Matchers.anyString (org.mockito.Matchers.anyString)8 JsonProcessorInjectionMap (com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap)7 Gson (com.google.gson.Gson)6 HashMap (java.util.HashMap)5 GsonBuilder (com.google.gson.GsonBuilder)4 JsonParser (com.google.gson.JsonParser)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Type (java.lang.reflect.Type)3 HashSet (java.util.HashSet)3 Matcher (java.util.regex.Matcher)3 LobWrapper (angularBeans.io.LobWrapper)2 DatasetCreationSpec (co.cask.cdap.internal.dataset.DatasetCreationSpec)2