Search in sources :

Example 96 with JsonPrimitive

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

the class JsonRpcParamsTest method shouldToStringForParsedListBooleanParams.

@Test
public void shouldToStringForParsedListBooleanParams() throws Exception {
    Boolean value = false;
    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 97 with JsonPrimitive

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

the class JsonRpcParamsTest method shouldToJsonForCreatedListStringParams.

@Test
public void shouldToJsonForCreatedListStringParams() throws Exception {
    String value = "value";
    JsonArray expected = new JsonArray();
    expected.add(new JsonPrimitive(value));
    JsonRpcParams jsonRpcParams = new JsonRpcParams(singletonList(value), jsonParser);
    JsonElement actual = jsonRpcParams.toJsonElement();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 98 with JsonPrimitive

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

the class JsonRpcParamsTest method shouldToJsonValueForParsedListBooleanParams.

@Test
public void shouldToJsonValueForParsedListBooleanParams() throws Exception {
    Boolean expected = false;
    JsonArray array = new JsonArray();
    array.add(new JsonPrimitive(expected));
    JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + expected + "]", jsonParser);
    JsonElement jsonValue = jsonRpcParams.toJsonElement();
    assertEquals(array, jsonValue);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) Test(org.testng.annotations.Test)

Example 99 with JsonPrimitive

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

the class JsonRpcParamsTest method shouldToJsonForCreatedListBooleanParams.

@Test
public void shouldToJsonForCreatedListBooleanParams() throws Exception {
    Boolean value = false;
    List<Boolean> list = singletonList(value);
    JsonArray expected = new JsonArray();
    expected.add(new JsonPrimitive(value));
    JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonParser);
    JsonElement actual = jsonRpcParams.toJsonElement();
    assertEquals(expected, actual);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) Test(org.testng.annotations.Test)

Example 100 with JsonPrimitive

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

the class JsonRpcParamsTest method shouldToStringCreatedListDoubleParams.

@Test
public void shouldToStringCreatedListDoubleParams() throws Exception {
    double value = 0D;
    List<Double> list = singletonList(value);
    JsonArray jsonArray = new JsonArray();
    jsonArray.add(new JsonPrimitive(value));
    String expected = jsonArray.toString();
    JsonRpcParams jsonRpcParams = new JsonRpcParams(list, 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)

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