Search in sources :

Example 1 with TableWithDateColumn

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithDateColumn in project scout.rt by eclipse.

the class JsonCellToJsonTest method testDateColumn_jsonDatePattern.

/**
 * Don't send value and text if they are equal. They may be equal if the date column uses the same pattern as
 * {@link JsonDate}.
 */
@Test
public void testDateColumn_jsonDatePattern() throws JSONException {
    TableWithDateColumn table = new TableWithDateColumn();
    table.initTable();
    ITableRow row = table.addRow(table.createRow());
    table.getColumn().setFormat(JsonDate.JSON_PATTERN_DATE_ONLY);
    table.getColumn().setValue(row, DateUtility.parse("01.01.2015", "dd.MM.yyyy"));
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    Object jsonObj = jsonTable.cellToJson(row, table.getColumn());
    assertTrue(jsonObj instanceof String);
}
Also used : ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) JSONObject(org.json.JSONObject) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) TableWithDateColumn(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithDateColumn) Test(org.junit.Test)

Example 2 with TableWithDateColumn

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithDateColumn in project scout.rt by eclipse.

the class JsonCellToJsonTest method testDateColumn.

@Test
public void testDateColumn() throws JSONException {
    TableWithDateColumn table = new TableWithDateColumn();
    table.initTable();
    ITableRow row = table.addRow(table.createRow());
    table.getColumn().setFormat("dd.MM.yyyy");
    table.getColumn().setValue(row, DateUtility.parse("01.01.2015", "dd.MM.yyyy"));
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    JSONObject jsonObj = (JSONObject) jsonTable.cellToJson(row, table.getColumn());
    Assert.assertEquals("01.01.2015", jsonObj.get("text"));
    // Pattern used by JsonDate
    Assert.assertEquals("2015-01-01", jsonObj.get("value"));
}
Also used : JSONObject(org.json.JSONObject) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) TableWithDateColumn(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithDateColumn) Test(org.junit.Test)

Aggregations

ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)2 TableWithDateColumn (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithDateColumn)2 JSONObject (org.json.JSONObject)2 Test (org.junit.Test)2