use of org.eclipse.che.dto.definitions.DtoWithFieldNames in project che by eclipse.
the class ServerDtoTest method testSerializerWithFieldNames.
@Test
public void testSerializerWithFieldNames() throws Exception {
final String fooString = "Something";
final String _default = "test_default_keyword";
DtoWithFieldNames dto = dtoFactory.createDto(DtoWithFieldNames.class).withTheName(fooString).withTheDefault(_default);
final String json = dtoFactory.toJson(dto);
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
assertEquals(jsonObject.get(DtoWithFieldNames.THENAME_FIELD).getAsString(), fooString);
assertEquals(jsonObject.get(DtoWithFieldNames.THEDEFAULT_FIELD).getAsString(), _default);
}
use of org.eclipse.che.dto.definitions.DtoWithFieldNames in project che by eclipse.
the class ServerDtoTest method testDeerializerWithFieldNames.
@Test
public void testDeerializerWithFieldNames() throws Exception {
final String fooString = "Something";
final String _default = "test_default_keyword";
JsonObject json = new JsonObject();
json.add(DtoWithFieldNames.THENAME_FIELD, new JsonPrimitive(fooString));
json.add(DtoWithFieldNames.THEDEFAULT_FIELD, new JsonPrimitive(_default));
DtoWithFieldNames dto = dtoFactory.createDtoFromJson(json.toString(), DtoWithFieldNames.class);
assertEquals(dto.getTheName(), fooString);
assertEquals(dto.getTheDefault(), _default);
}
Aggregations