assertEquals(4, natTableFixture.getColumnIndexByPosition(1));
}
@Test
public void reorderMultipleNotConsecutiveColumnsInHiddenState() {
DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(
new DataLayerFixture(10, 10, 100, 20));
NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer,
1000, 400, true);
// Add listener
LayerListenerFixture listenerFixture = new LayerListenerFixture();
natTableFixture.addLayerListener(listenerFixture);
assertEquals(10, natTableFixture.getColumnCount());
// hide some columns
natTableFixture.doCommand(new MultiColumnHideCommand(natTableFixture,
new int[] { 2, 5, 8 }));
assertEquals(7, natTableFixture.getColumnCount());
List<Integer> columnToMove = Arrays.asList(3, 4, 6, 7);
int destinationPosition = 0;
natTableFixture.doCommand(new MultiColumnReorderCommand(underlyingLayer
.getColumnReorderLayer(), columnToMove, destinationPosition));
// verify the event
ColumnReorderEvent event = (ColumnReorderEvent) listenerFixture
.getReceivedEvent(ColumnReorderEvent.class);
assertNotNull(event);
assertTrue(StructuralChangeEventHelper
.isReorder(event.getColumnDiffs()));
assertEquals(7, natTableFixture.getColumnCount());
assertEquals(0, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(3));
assertEquals(1, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(4));
assertEquals(2, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(6));
assertEquals(3, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(7));
assertEquals(4, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(0));
assertEquals(5, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(1));
assertEquals(6, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(2));
assertEquals(7, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(5));
assertEquals(8, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(8));
assertEquals(9, underlyingLayer.getColumnReorderLayer()
.getColumnPositionByIndex(9));
}