use of elemental.json.JsonString in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsAListOfString.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsAListOfString() throws Exception {
JsonString string = jsonFactory.create("a");
JsonArray expected = jsonFactory.createArray();
expected.set(0, string);
JsonRpcResult jsonRpcResult = new JsonRpcResult(expected.toJson(), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonString in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsStringWhenParsingStringWithResultAsString.
// String
@Test
public void shouldGetAsStringWhenParsingStringWithResultAsString() throws Exception {
JsonString value = jsonFactory.create("a");
String expected = value.asString();
JsonRpcResult jsonRpcResult = new JsonRpcResult(value.toJson(), jsonFactory, dtoFactory);
String actual = jsonRpcResult.getAs(String.class);
assertEquals(expected, actual);
}
use of elemental.json.JsonString in project che by eclipse.
the class JsonRpcResultTest method shouldToStringWhenParsingStringWithResultAsAListOfString.
@Test
public void shouldToStringWhenParsingStringWithResultAsAListOfString() throws Exception {
JsonString string = jsonFactory.create("a");
JsonArray array = jsonFactory.createArray();
array.set(0, string);
String expected = array.toJson();
JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toJson(), jsonFactory, dtoFactory);
String actual = jsonRpcResult.toString();
assertEquals(expected, actual);
}
use of elemental.json.JsonString in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsASingleString.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsASingleString() throws Exception {
JsonString expected = jsonFactory.create("a");
JsonRpcResult jsonRpcResult = new JsonRpcResult(expected.toJson(), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonString in project flow by vaadin.
the class JsonCodecTest method decodeAs_stringJson.
@Test
public void decodeAs_stringJson() {
JsonString json = Json.create("Test123 String\n !%");
Assert.assertTrue(JsonCodec.decodeAs(json, Boolean.class));
Assert.assertEquals("Test123 String\n !%", JsonCodec.decodeAs(json, String.class));
Assert.assertEquals(Integer.valueOf(0), JsonCodec.decodeAs(json, Integer.class));
Assert.assertTrue(JsonCodec.decodeAs(json, Double.class).isNaN());
Assert.assertEquals(json, JsonCodec.decodeAs(json, JsonValue.class));
}
Aggregations