use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class PersistenceHelperTest method testDeleteStateOnNullState.
@Test
public void testDeleteStateOnNullState() {
Properties properties = new Properties();
NatTable natTable = new NatTableFixture();
natTable.saveState("", properties);
natTable.saveState("Blubb", properties);
natTable.saveState("Temp", properties);
Collection<String> stateNames = PersistenceHelper.getAvailableStates(properties);
assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
PersistenceHelper.deleteState(null, properties);
// no impact
stateNames = PersistenceHelper.getAvailableStates(properties);
assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class PersistenceHelperTest method testDeleteStateOnNullProperties.
@Test
public void testDeleteStateOnNullProperties() {
Properties properties = new Properties();
NatTable natTable = new NatTableFixture();
natTable.saveState("", properties);
natTable.saveState("Blubb", properties);
natTable.saveState("Temp", properties);
Collection<String> stateNames = PersistenceHelper.getAvailableStates(properties);
assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
PersistenceHelper.deleteState("Blubb", null);
// no impact
stateNames = PersistenceHelper.getAvailableStates(properties);
assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class PersistenceHelperTest method testGetAvailableStates.
@Test
public void testGetAvailableStates() {
Properties properties = new Properties();
NatTable natTable = new NatTableFixture();
natTable.saveState("", properties);
natTable.saveState("Blubb", properties);
natTable.saveState("Temp", properties);
Collection<String> stateNames = PersistenceHelper.getAvailableStates(properties);
assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ConfigLabelProviderTest method testProvidedRegionLabels.
@Test
public void testProvidedRegionLabels() {
GridLayer grid = new GridLayer(this.bodyDataLayer, this.columnHeaderDataLayer, this.rowHeaderDataLayer, this.cornerDataLayer, false);
Collection<String> labels = grid.getProvidedLabels();
assertEquals(4, labels.size());
assertTrue(labels.contains(GridRegion.CORNER));
assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
assertTrue(labels.contains(GridRegion.ROW_HEADER));
assertTrue(labels.contains(GridRegion.BODY));
NatTable natTable = new NatTableFixture(grid);
labels = natTable.getProvidedLabels();
assertEquals(4, labels.size());
assertTrue(labels.contains(GridRegion.CORNER));
assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
assertTrue(labels.contains(GridRegion.ROW_HEADER));
assertTrue(labels.contains(GridRegion.BODY));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class BoxingStyleTest method retrievedCellShouldBeConvertedUsingTheDisplayConverter.
@Test
public void retrievedCellShouldBeConvertedUsingTheDisplayConverter() throws Exception {
IConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DisplayConverter() {
@Override
public Object canonicalToDisplayValue(Object canonicalValue) {
if (canonicalValue == null) {
return null;
} else {
return canonicalValue.toString().equals("MN") ? "Manual" : "Automatic";
}
}
@Override
public Object displayToCanonicalValue(Object displayValue) {
return displayValue.toString().equals("Manual") ? new PricingTypeBean("MN") : new PricingTypeBean("AT");
}
});
NatTableFixture natTableFixture = new NatTableFixture(new DefaultGridLayer(RowDataListFixture.getList(), RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap()), false);
natTableFixture.setConfigRegistry(configRegistry);
natTableFixture.configure();
int columnIndex = RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.PRICING_TYPE_PROP_NAME);
Object dataValue = natTableFixture.getDataValueByPosition(columnIndex + ROW_HEADER_COLUMN_COUNT, 2);
// Verify displayed value
ILayerCell cell = natTableFixture.getCellByPosition(columnIndex + ROW_HEADER_COLUMN_COUNT, 2);
TextPainter cellPainter = new TextPainter();
Assert.assertEquals("Automatic", cellPainter.convertDataType(cell, configRegistry));
// Assert that the display value is converted to an Object
Assert.assertTrue(dataValue instanceof PricingTypeBean);
}
Aggregations