use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsListOfStringWhenParsingStringWithResultAsString.
@Test
public void shouldGetAsListOfStringWhenParsingStringWithResultAsString() throws Exception {
String expected = "a";
JsonString string = jsonFactory.create(expected);
JsonArray array = jsonFactory.createArray();
array.set(0, string);
JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toJson(), jsonFactory, dtoFactory);
List<String> actual = jsonRpcResult.getAsListOf(String.class);
assertEquals(expected, actual.iterator().next());
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsListOfNumberWhenParsingStringWithResultAsListOfNumber.
@Test
public void shouldGetAsListOfNumberWhenParsingStringWithResultAsListOfNumber() throws Exception {
Double expected = 0D;
JsonNumber string = jsonFactory.create(expected);
JsonArray array = jsonFactory.createArray();
array.set(0, string);
JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toJson(), jsonFactory, dtoFactory);
List<Double> actual = jsonRpcResult.getAsListOf(Double.class);
assertEquals(expected, actual.iterator().next());
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsListOfNumberWhenPassingParametersWithResultAsListOfNumber.
@Test
public void shouldGetAsListOfNumberWhenPassingParametersWithResultAsListOfNumber() throws Exception {
Double expected = 0D;
JsonNumber string = jsonFactory.create(expected);
JsonArray array = jsonFactory.createArray();
array.set(0, string);
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(expected), jsonFactory, dtoFactory);
List<Double> actual = jsonRpcResult.getAsListOf(Double.class);
assertEquals(expected, actual.iterator().next());
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfNumber.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfNumber() throws Exception {
Double value = 0D;
JsonArray expected = jsonFactory.createArray();
expected.set(0, value);
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(value), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcResultTest method shouldToStringWhenParsingStringWithResultAsAListOfNumber.
@Test
public void shouldToStringWhenParsingStringWithResultAsAListOfNumber() throws Exception {
JsonNumber number = jsonFactory.create(0D);
JsonArray array = jsonFactory.createArray();
array.set(0, number);
String expected = array.toJson();
JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toJson(), jsonFactory, dtoFactory);
String actual = jsonRpcResult.toString();
assertEquals(expected, actual);
}
Aggregations