use of com.sldeditor.ui.detail.config.FieldConfigGeometry 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.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#generateExpression()}. Test method
* for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#populateField(java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#getStringValue()}.
*/
@Test
public void testGenerateExpression() {
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true), "button text");
field.createUI();
field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
field.populateField((String) null);
field.populateExpression((String) null);
String wktPoint = "POINT( 48.44 -123.37)";
field.populateField(wktPoint);
String actualValue = field.getStringValue();
assertTrue(wktPoint.compareTo(actualValue) == 0);
String wktPolygon = "POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))";
field.setTestValue(FieldIdEnum.UNKNOWN, wktPolygon);
actualValue = field.getStringValue();
assertTrue(wktPolygon.compareTo(actualValue) == 0);
String wktLine = "LINESTRING(0 2, 2 0, 8 6)";
field.populateExpression(wktLine);
actualValue = field.getStringValue();
assertTrue(wktLine.compareTo(actualValue) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testSetVisible.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#setVisible(boolean)}.
*/
@Test
public void testSetVisible() {
boolean valueOnly = true;
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
boolean expectedValue = true;
field.setVisible(expectedValue);
field.createUI();
field.setVisible(expectedValue);
expectedValue = false;
field.setVisible(expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testCreateCopy.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
*/
@Test
public void testCreateCopy() {
boolean valueOnly = true;
class TestFieldConfigGeometry extends FieldConfigGeometry {
public TestFieldConfigGeometry(FieldConfigCommonData commonData, String buttonText) {
super(commonData, buttonText);
}
public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
return createCopy(fieldConfigBase);
}
}
TestFieldConfigGeometry field = new TestFieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
FieldConfigGeometry copy = (TestFieldConfigGeometry) field.callCreateCopy(null);
assertNull(copy);
copy = (FieldConfigGeometry) field.callCreateCopy(field);
assertEquals(field.getFieldId(), copy.getFieldId());
assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
assertEquals(field.isValueOnly(), copy.isValueOnly());
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testRevertToDefaultValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#revertToDefaultValue()}. Test
* method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#setDefaultValue(java.lang.String)}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
field.revertToDefaultValue();
assertNull(field.getStringValue());
field.createUI();
field.createUI();
field.revertToDefaultValue();
String expectedDefaultValue = "default value";
assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) != 0);
field.setDefaultValue(expectedDefaultValue);
field.revertToDefaultValue();
assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) == 0);
}
Aggregations