use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testInteger.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateIntegerField(com.sldeditor.ui.detail.config.FieldId, java.lang.Integer)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getInteger(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getInteger(com.sldeditor.common.xml.ui.FieldIdEnum)}.
*/
@Test
public void testInteger() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigInteger intField = new FieldConfigInteger(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
intField.createUI();
fieldConfigManager.add(fieldId, intField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
int expectedValue = 1256;
obj.populateIntegerField(fieldId, expectedValue);
assertEquals(expectedValue, obj.getInteger(fieldId));
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertEquals(0, obj.getInteger(wrongFieldEnum));
// Try with null - should revert to default value (0.0)
obj.populateIntegerField(fieldId, null);
assertEquals(0, obj.getInteger(fieldId));
}
Aggregations