use of com.google.gson.JsonPrimitive 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);
}
use of com.google.gson.JsonPrimitive 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);
}
use of com.google.gson.JsonPrimitive in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsStringWhenParsingStringWithResultAsString.
@Test
public void shouldGetAsStringWhenParsingStringWithResultAsString() throws Exception {
JsonPrimitive primitive = new JsonPrimitive("a");
String expected = primitive.getAsString();
JsonRpcResult jsonRpcResult = new JsonRpcResult(primitive.toString(), jsonParser);
String actual = jsonRpcResult.getAs(String.class);
assertEquals(expected, actual);
}
use of com.google.gson.JsonPrimitive in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsNumberWhenParsingStringWithResultAsNumber.
@Test
public void shouldGetAsNumberWhenParsingStringWithResultAsNumber() throws Exception {
JsonPrimitive value = new JsonPrimitive(0D);
Double expected = value.getAsDouble();
JsonRpcResult jsonRpcResult = new JsonRpcResult(value.toString(), jsonParser);
Double actual = jsonRpcResult.getAs(Double.class);
assertEquals(expected, actual);
}
use of com.google.gson.JsonPrimitive in project che by eclipse.
the class JsonRpcResultTest method shouldToStringWhenPassingParametersWithResultAsAListOfString.
@Test
public void shouldToStringWhenPassingParametersWithResultAsAListOfString() throws Exception {
String value = "a";
JsonArray array = new JsonArray();
array.add(new JsonPrimitive(value));
String expected = array.toString();
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(value), jsonParser);
String actual = jsonRpcResult.toString();
assertEquals(expected, actual);
}
Aggregations