use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn in project scout.rt by eclipse.
the class JsonCellToJsonTest method testNullValueAndEmptyText.
/**
* Send only empty text if both are empty
*/
@Test
public void testNullValueAndEmptyText() throws JSONException {
TableWithLongColumn table = new TableWithLongColumn();
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, null);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
JSONObject jsonObj = (JSONObject) jsonTable.cellToJson(row, table.getColumn());
assertEquals("", jsonObj.get("text"));
assertNull(jsonObj.opt("value"));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn in project scout.rt by eclipse.
the class JsonCellToJsonTest method testNullValue.
/**
* Send {@link JSONObject#NULL} if value is null if value is required.
*/
@Test
public void testNullValue() throws JSONException {
TableWithLongColumn table = new TableWithLongColumn();
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, null);
row.getCellForUpdate(table.getColumn()).setText("-empty-");
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
JSONObject jsonObj = (JSONObject) jsonTable.cellToJson(row, table.getColumn());
assertEquals("-empty-", jsonObj.get("text"));
assertEquals(JSONObject.NULL, jsonObj.get("value"));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn in project scout.rt by eclipse.
the class JsonCellToJsonTest method testLongColumn.
/**
* Don't send value and text if they are equal.
*/
@Test
public void testLongColumn() throws JSONException {
TableWithLongColumn table = new TableWithLongColumn();
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, 15L);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
JSONObject jsonObj = (JSONObject) jsonTable.cellToJson(row, table.getColumn());
Assert.assertEquals("15", jsonObj.get("text"));
assertNull(jsonObj.opt("value"));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn in project scout.rt by eclipse.
the class JsonCellToJsonTest method testLongColumn_leftAlignment.
/**
* Don't generate a cell object if text is the only property.
*/
@Test
public void testLongColumn_leftAlignment() throws JSONException {
TableWithLongColumn table = new TableWithLongColumn();
table.getColumn().setHorizontalAlignment(-1);
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, 15L);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
Object jsonObj = jsonTable.cellToJson(row, table.getColumn());
assertTrue(jsonObj instanceof String);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn in project scout.rt by eclipse.
the class JsonCellToJsonTest method testNullValueAndEmptyText_leftAlignment.
/**
* Send only empty text if both are empty
*/
@Test
public void testNullValueAndEmptyText_leftAlignment() throws JSONException {
TableWithLongColumn table = new TableWithLongColumn();
table.getColumn().setHorizontalAlignment(-1);
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, null);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
Object jsonObj = jsonTable.cellToJson(row, table.getColumn());
assertEquals("", jsonObj);
}
Aggregations