use of org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable in project scout.rt by eclipse.
the class JsonTableTest method testTableEventCoalesceInUi_ReplaceRows.
@Test
public void testTableEventCoalesceInUi_ReplaceRows() throws Exception {
ListBoxTable listbox = new ListBoxTable();
ILookupRow<Long> row1 = new LookupRow<Long>(1L, "Row1");
ILookupRow<Long> row2 = new LookupRow<Long>(2L, "Row2").withActive(false);
ILookupRow<Long> row3 = new LookupRow<Long>(3L, "Row3");
ILookupRow<Long> row4 = new LookupRow<Long>(4L, "Row4");
ArrayList<ITableRow> rowsInitial = new ArrayList<ITableRow>();
rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row1));
rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row2));
rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row3));
ITable table = listbox.getTable();
table.addRows(rowsInitial);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
m_uiSession.currentJsonResponse().addAdapter(jsonTable);
JSONObject response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
JSONArray events = response.optJSONArray("events");
ArrayList<ITableRow> rowsUpdate = new ArrayList<ITableRow>();
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row1));
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row2));
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row3));
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row4));
table.replaceRows(rowsUpdate);
response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
events = response.optJSONArray("events");
JSONObject lastEvent = events.optJSONObject(events.length() - 1);
assertEquals(lastEvent.optString("type"), "rowOrderChanged");
JSONArray rowIds = lastEvent.optJSONArray("rowIds");
assertTrue(rowIds.length() == 3);
}
Aggregations