Search in sources :

Example 46 with JsonArray

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

Example 47 with JsonArray

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());
}
Also used : JsonArray(elemental.json.JsonArray) JsonNumber(elemental.json.JsonNumber) Test(org.junit.Test)

Example 48 with JsonArray

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());
}
Also used : JsonArray(elemental.json.JsonArray) JsonNumber(elemental.json.JsonNumber) Test(org.junit.Test)

Example 49 with JsonArray

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

Example 50 with JsonArray

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

Aggregations

JsonArray (elemental.json.JsonArray)69 Test (org.junit.Test)62 JsonValue (elemental.json.JsonValue)23 JsonString (elemental.json.JsonString)19 JsonObject (elemental.json.JsonObject)14 Matchers.anyString (org.mockito.Matchers.anyString)10 JsonNumber (elemental.json.JsonNumber)5 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Node (org.eclipse.che.ide.api.data.tree.Node)2 ResourceNode (org.eclipse.che.ide.resources.tree.ResourceNode)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Promise (org.eclipse.che.api.promises.client.Promise)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 Path (org.eclipse.che.ide.resource.Path)1 MessageLoader (org.eclipse.che.ide.ui.loaders.request.MessageLoader)1 Ignore (org.junit.Ignore)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1