@Test public void shouldUpdateOnInsertAndDelete() { DefaultBodyLayerStack body = this.grid.getBodyLayer(); ColumnReorderLayer reorderLayer = body.getColumnReorderLayer(); ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer(); body.doCommand(new ColumnReorderCommand(body, 3, 6)); body.doCommand(new ColumnReorderCommand(body, 3, 5)); body.doCommand(new MultiColumnHideCommand(body, new int[] {2, 3, 5})); assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString()); assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString()); this.provider.setColumnCount(7); this.grid .getBodyDataLayer() .fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3)); assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString()); assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString()); this.provider.setColumnCount(6); this.grid .getBodyDataLayer() .fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3)); assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString()); assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString()); }
@Test public void shouldUpdateReorderOnInsert() { DefaultBodyLayerStack body = this.grid.getBodyLayer(); ColumnReorderLayer reorderLayer = body.getColumnReorderLayer(); body.doCommand(new ColumnReorderCommand(body, 3, 6)); body.doCommand(new ColumnReorderCommand(body, 3, 5)); assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString()); this.provider.setColumnCount(7); this.grid .getBodyDataLayer() .fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3)); assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString()); }