use of elemental.json.JsonArray in project che by eclipse.
the class AbstractPerspectivePersistenceTest method shouldRestoreOpenedParts.
@Test
//TODO
@Ignore
public void shouldRestoreOpenedParts() throws Exception {
JsonObject state = Json.createObject();
JsonObject parts = Json.createObject();
state.put("PART_STACKS", parts);
JsonObject partStack = Json.createObject();
parts.put("INFORMATION", partStack);
JsonArray partsArray = Json.createArray();
partStack.put("PARTS", partsArray);
JsonObject part = Json.createObject();
partsArray.set(0, part);
part.put("CLASS", "foo.Bar");
when(dynaProvider.<PartPresenter>getProvider(anyString())).thenReturn(partProvider);
when(partProvider.get()).thenReturn(partPresenter);
perspective.loadState(state);
verify(dynaProvider).getProvider("foo.Bar");
verify(partProvider).get();
verify(partStackPresenter).addPart(partPresenter);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldParseBooleanArray.
@Test
public void shouldParseBooleanArray() throws Exception {
Boolean expected = false;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
Boolean actual = jsonRpcList.get(0, Boolean.class);
assertEquals(expected, actual);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayCreatedDtoArray.
@Test
public void shouldToJsonArrayCreatedDtoArray() throws Exception {
Dto dto = mock(Dto.class);
when(dto.toString()).thenReturn(DTO);
when(dto.getParameter()).thenReturn("value");
when(dtoFactory.createDtoFromJson(DTO, Dto.class)).thenReturn(dto);
JsonArray expected = jsonFactory.createArray();
JsonValue parse = jsonFactory.parse(dto.toString());
expected.set(0, parse);
JsonRpcList jsonRpcList = new JsonRpcList(singletonList(dto), jsonFactory, dtoFactory);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldParseDtoArray.
@Test
public void shouldParseDtoArray() throws Exception {
Dto expected = mock(Dto.class);
when(expected.toString()).thenReturn(DTO);
when(expected.getParameter()).thenReturn("value");
when(dtoFactory.createDtoFromJson(DTO, Dto.class)).thenReturn(expected);
JsonValue parse = jsonFactory.parse(DTO);
JsonArray array = jsonFactory.createArray();
array.set(0, parse);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
Dto actual = jsonRpcList.get(0, Dto.class);
assertEquals(expected.getParameter(), actual.getParameter());
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringifiedListParsedNumberArray.
@Test
public void shouldToStringifiedListParsedNumberArray() throws Exception {
Double expected = 0D;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
List<String> actual = jsonRpcList.toStringifiedList();
assertEquals(expected, Double.valueOf(actual.iterator().next()));
}
Aggregations