Search in sources :

Example 16 with JsonPrimitive

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

the class JsonRpcListTest method shouldToListParsedNumberArray.

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

Example 17 with JsonPrimitive

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

the class JsonRpcParamsTest method shouldToStringForParsedListDoubleParams.

@Test
public void shouldToStringForParsedListDoubleParams() throws Exception {
    Double value = 0D;
    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 18 with JsonPrimitive

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

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

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

Aggregations

JsonPrimitive (com.google.gson.JsonPrimitive)168 JsonArray (com.google.gson.JsonArray)103 JsonObject (com.google.gson.JsonObject)78 Test (org.testng.annotations.Test)56 JsonElement (com.google.gson.JsonElement)47 Test (org.junit.Test)12 Map (java.util.Map)9 Matchers.anyString (org.mockito.Matchers.anyString)8 JsonProcessorInjectionMap (com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap)7 Gson (com.google.gson.Gson)5 JsonParser (com.google.gson.JsonParser)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 GsonBuilder (com.google.gson.GsonBuilder)3 ArrayList (java.util.ArrayList)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 IRenderState (com.builtbroken.mc.client.json.imp.IRenderState)2