use of com.sldeditor.ui.detail.config.FieldConfigGeometryField in project sldeditor by robward-scisys.
the class FieldConfigGeometryFieldTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
field.attributeSelection("field");
// Does nothing
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometryField in project sldeditor by robward-scisys.
the class FieldConfigGeometryFieldTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#internal_setEnabled(boolean)}.
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#isEnabled()}.
*/
@Test
public void testSetEnabled() {
FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
// Text field will not have been created
boolean expectedValue = true;
field.internal_setEnabled(expectedValue);
assertTrue(field.isEnabled());
// Create text field
field.createUI();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertTrue(field.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometryField in project sldeditor by robward-scisys.
the class FieldConfigGeometryFieldTest method testSetVisible.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#setVisible(boolean)}.
*/
@Test
public void testSetVisible() {
FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
boolean expectedValue = true;
field.setVisible(expectedValue);
expectedValue = false;
field.setVisible(expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometryField in project sldeditor by robward-scisys.
the class FieldConfigGeometryFieldTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#generateExpression()}. Test
* method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateExpression(java.lang.Object)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateField(java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#getStringValue()}.
*/
@Test
public void testGenerateExpression() {
class TestFieldConfigGeometryField extends FieldConfigGeometryField {
public TestFieldConfigGeometryField(FieldConfigCommonData commonData) {
super(commonData);
}
public Expression callGenerateExpression() {
return generateExpression();
}
}
TestFieldConfigGeometryField field = new TestFieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", false));
Expression actualExpression = field.callGenerateExpression();
assertNull(actualExpression);
field.createUI();
TestDataSource testDataSource = new TestDataSource();
@SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
String expectedValue = "";
field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
actualExpression = field.callGenerateExpression();
assertTrue(expectedValue.compareTo(actualExpression.toString()) == 0);
// Attribute expression
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Expression expectedExpression = ff.property(testDataSource.getDefaultGeometryField());
field.populateExpression(expectedExpression);
actualExpression = field.callGenerateExpression();
assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);
// Literal expression
expectedExpression = ff.literal(testDataSource.getDefaultGeometryField());
field.populateExpression(expectedExpression);
actualExpression = field.callGenerateExpression();
assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);
field.populateField((String) null);
String stringValue = field.getStringValue();
assertNull(stringValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometryField in project sldeditor by robward-scisys.
the class FieldConfigGeometryFieldTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#redoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#dataSourceLoaded(com.sldeditor.datasource.impl.GeometryTypeEnum, boolean)}.
*/
@Test
public void testUndoAction() {
FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.undoAction(null);
field.redoAction(null);
TestDataSource testDataSource = new TestDataSource();
@SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
String expectedTestValue = testDataSource.getDefaultGeometryField();
field.setTestValue(FieldIdEnum.UNKNOWN, expectedTestValue);
assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
String expectedUndoTestValue = "";
String expectedRedoTestValue = testDataSource.getDefaultGeometryField();
UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
field.undoAction(undoEvent);
assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
field.redoAction(undoEvent);
assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
}
Aggregations