Search in sources :

Example 41 with JsonValue

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

the class JsonRpcParamsTest method shouldToJsonValueForParsedSingleBooleanParams.

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

Example 42 with JsonValue

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

the class JsonRpcParamsTest method shouldToJsonForCreatedListDoubleParams.

@Test
public void shouldToJsonForCreatedListDoubleParams() throws Exception {
    double value = 0D;
    List<Double> list = singletonList(value);
    JsonArray expected = jsonFactory.createArray();
    expected.set(0, value);
    JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonFactory, dtoFactory);
    JsonValue actual = jsonRpcParams.toJsonValue();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 43 with JsonValue

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

the class JsonRpcResponseTest method shouldToStringWhenPassingParametersWithError.

@Test
public void shouldToStringWhenPassingParametersWithError() throws Exception {
    JsonObject expected = response;
    expected.remove("result");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(ID, null, error, jsonFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcResponse.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 44 with JsonValue

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

the class JsonRpcResponseTest method shouldToStringWhenParsingStringWithError.

@Test
public void shouldToStringWhenParsingStringWithError() throws Exception {
    JsonObject expected = response;
    expected.remove("result");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(expected.toJson(), jsonFactory, dtoFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcResponse.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 45 with JsonValue

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

the class JsonRpcResponseTest method shouldToStringWhenPassingParametersWithResult.

@Test
public void shouldToStringWhenPassingParametersWithResult() throws Exception {
    JsonObject expected = response;
    expected.remove("error");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(ID, result, null, jsonFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcResponse.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