Search in sources :

Example 6 with JsonValue

use of elemental.json.JsonValue in project che by eclipse.

the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsASingleDto.

@Test
public void shouldToJsonValueWhenParsingStringWithResultAsASingleDto() throws Exception {
    JsonObject value = jsonFactory.parse(dto.toString());
    JsonRpcResult jsonRpcResult = new JsonRpcResult(dto.toString(), jsonFactory, dtoFactory);
    JsonValue actual = jsonRpcResult.toJsonValue();
    assertTrue(value.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 7 with JsonValue

use of elemental.json.JsonValue in project che by eclipse.

the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfString.

@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfString() throws Exception {
    String value = "a";
    JsonArray expected = jsonFactory.createArray();
    expected.set(0, value);
    JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(value), jsonFactory, dtoFactory);
    JsonValue actual = jsonRpcResult.toJsonValue();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) JsonString(elemental.json.JsonString) Test(org.junit.Test)

Example 8 with JsonValue

use of elemental.json.JsonValue 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));
}
Also used : JsonValue(elemental.json.JsonValue) JsonString(elemental.json.JsonString) Test(org.junit.Test)

Example 9 with JsonValue

use of elemental.json.JsonValue in project che by eclipse.

the class JsonRpcParamsTest method shouldToJsonValueForParsedSingleDoubleParams.

@Test
public void shouldToJsonValueForParsedSingleDoubleParams() throws Exception {
    Double expected = 0D;
    JsonRpcParams jsonRpcParams = new JsonRpcParams(expected.toString(), jsonFactory, dtoFactory);
    JsonValue actual = jsonRpcParams.toJsonValue();
    assertEquals(expected, Double.valueOf(actual.toJson()));
}
Also used : JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 10 with JsonValue

use of elemental.json.JsonValue in project che by eclipse.

the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithParams.

@Test
public void shouldToStringWhenPassStringParamsWithIdAndWithParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("0", "method", params, jsonFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonValue (elemental.json.JsonValue)55 Test (org.junit.Test)52 JsonArray (elemental.json.JsonArray)23 JsonObject (elemental.json.JsonObject)19 JsonString (elemental.json.JsonString)10 Matchers.anyString (org.mockito.Matchers.anyString)5 JsonNumber (elemental.json.JsonNumber)3 ArrayList (java.util.ArrayList)2