use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class ExtractGeometryFieldTest method testGetGeometryField.
/**
* Test method for {@link com.sldeditor.ui.detail.ExtractGeometryField#getGeometryField(com.sldeditor.ui.detail.config.FieldConfigPopulation)}.
*/
@Test
public void testGetGeometryField() {
assertNull(ExtractGeometryField.getGeometryField(null));
FieldIdEnum fieldId = FieldIdEnum.GEOMETRY;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(Geometry.class);
FieldConfigGeometry geometryField = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button");
geometryField.createUI();
fieldConfigManager.add(fieldId, geometryField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
// Try valid geometry field name
geometryField.populateField("ValidTestField");
Expression actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNotNull(actualExpression);
// Try invalid geometry field name
geometryField.populateField("");
actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNull(actualExpression);
// Try invalid geometry field name
geometryField.populateField(" ");
actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNull(actualExpression);
// Try when there is no geometry field
obj = new FieldConfigPopulation(fieldConfigManager);
actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNull(actualExpression);
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.common.xml.ui.FieldIdEnum, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.common.xml.ui.FieldIdEnum)}.
*/
@Test
public void testExpression() {
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;
StyleBuilder styleBuilder = new StyleBuilder();
Expression expression = styleBuilder.literalExpression(expectedValue);
obj.populateField(fieldId, expression);
LiteralExpressionImpl actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
obj.populateField(wrongFieldEnum, expression);
assertNull(obj.getExpression(wrongFieldEnum));
// Try with null
obj.populateField(fieldId, null);
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testBoolean.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.ui.detail.config.FieldId, java.lang.Boolean)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.Boolean)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.common.xml.ui.FieldIdEnum)}.
*/
@Test
public void testBoolean() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigBoolean booleanField = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
booleanField.createUI();
fieldConfigManager.add(fieldId, booleanField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
Boolean expectedValue = Boolean.TRUE;
obj.populateBooleanField(fieldId, expectedValue);
assertEquals(expectedValue.booleanValue(), obj.getBoolean(fieldId));
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertFalse(obj.getBoolean(wrongFieldEnum));
// Try with null - should revert to default value (false)
obj.populateBooleanField(fieldId, null);
assertFalse(obj.getBoolean(fieldId));
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testComboBox.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.common.xml.ui.FieldIdEnum)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.ui.detail.config.FieldId)}.
*/
@Test
public void testComboBox() {
SymbolTypeConfig s1 = new SymbolTypeConfig(null);
s1.addOption("key1", "Value 1");
s1.addOption("key2", "Value 2");
s1.addOption("key3", "Value 3");
s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
configList.add(s1);
FieldConfigEnum enumField = new FieldConfigEnum(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
enumField.addConfig(configList);
enumField.createUI();
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
fieldConfigManager.add(fieldId, enumField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
String expectedValue = "key2";
obj.populateComboBoxField(fieldId, expectedValue);
assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertNull(obj.getComboBox(wrongFieldEnum));
// Try with null - should revert to default value (first enum item)
obj.populateComboBoxField(fieldId, null);
expectedValue = "key1";
assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testGetFieldConfig.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getFieldConfig(com.sldeditor.ui.detail.config.FieldId)}.
*/
@Test
public void testGetFieldConfig() {
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);
assertNotNull(obj.getFieldConfig(fieldId));
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertNull(obj.getFieldConfig(wrongFieldEnum));
}
Aggregations