use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigTimePeriodTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#generateExpression()}. Test
* method for
* {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#populateField(com.sldeditor.filter.v2.function.temporal.TimePeriod)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
class TestFieldConfigTimePeriod extends FieldConfigTimePeriod {
public TestFieldConfigTimePeriod(FieldConfigCommonData commonData) {
super(commonData);
}
public Expression callGenerateExpression() {
return generateExpression();
}
}
TestFieldConfigTimePeriod field = new TestFieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, valueOnly));
Expression actualExpression = field.callGenerateExpression();
assertNotNull(actualExpression);
// Try string values - erroneous
field.createUI();
field.createUI();
String expectedValue = "test string value";
field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
actualExpression = field.callGenerateExpression();
assertNotNull(actualExpression);
expectedValue = "test string value as expression";
field.populateExpression(expectedValue);
actualExpression = field.callGenerateExpression();
assertNotNull(actualExpression);
// Time period values
String timePeriod = "07-07-2016T17:42:27Z / 08-07-2016T17:42:27Z";
field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
field.setTestValue(FieldIdEnum.UNKNOWN, timePeriod);
actualExpression = field.callGenerateExpression();
assertTrue(timePeriod.compareTo(actualExpression.toString()) == 0);
TimePeriod period = new TimePeriod();
Duration start = new Duration();
start.setDuration(0, 0, 1, 0, 32, 9);
period.setStart(start);
field.populateField((TimePeriod) null);
field.populateField(period);
actualExpression = field.callGenerateExpression();
String expectedPeriod = period.getString();
assertTrue(expectedPeriod.compareTo(actualExpression.toString()) == 0);
TimePeriod timePeriodObj = new TimePeriod();
timePeriodObj.decode(timePeriod);
DefaultPeriod defaultPeriod = new DefaultPeriod(new DefaultInstant(new DefaultPosition(timePeriodObj.getStart().getDate())), new DefaultInstant(new DefaultPosition(timePeriodObj.getEnd().getDate())));
field.populateExpression(defaultPeriod);
actualExpression = field.callGenerateExpression();
assertTrue(timePeriod.compareTo(actualExpression.toString()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigTimePeriodTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
boolean valueOnly = true;
FieldConfigTimePeriod field = new FieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, valueOnly));
field.attributeSelection(null);
// Does nothing
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigTimePeriodTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigTimePeriod field = new FieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, true));
field.undoAction(null);
field.redoAction(null);
field.createUI();
// Time period values
String timePeriod1 = "07-07-2016T17:42:27Z / 07-07-2016T17:42:27Z";
TimePeriod period1 = new TimePeriod();
period1.decode(timePeriod1);
// CHECKSTYLE:OFF
String expectedPeriod1 = period1.getString();
// CHECKSTYLE:ON
field.populateField(period1);
String timePeriod2 = "P 1 D 32 M 9 S / 08-07-2016T09:42:06Z";
TimePeriod period2 = new TimePeriod();
period2.decode(timePeriod2);
// CHECKSTYLE:OFF
String expectedPeriod2 = period2.getString();
// CHECKSTYLE:ON
field.populateField(period2);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(expectedPeriod1) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(actualValue.replace(" ", "").compareTo(expectedPeriod2.replace(" ", "")) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigVendorOptionTest method testAddToOptionBox.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigVendorOption#addToOptionBox(javax.swing.Box)}.
*/
@Test
public void testAddToOptionBox() {
FieldConfigVendorOption field = new FieldConfigVendorOption(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", false), null);
field.addToOptionBox(null);
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigVendorOptionTest method testVendorOptionsUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigVendorOption#vendorOptionsUpdated(java.util.List)}.
*/
@Test
public void testVendorOptionsUpdated() {
RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
VendorOptionRasterFactory vendorOptionRasterFactory = new VendorOptionRasterFactory(getClass(), panel);
// CHECKSTYLE:OFF
List<VendorOptionInterface> veList = vendorOptionRasterFactory.getVendorOptionList("com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeOverall");
for (VendorOptionInterface extension : veList) {
extension.setParentPanel(panel);
}
FieldConfigVendorOption field = new FieldConfigVendorOption(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", false), veList);
field.vendorOptionsUpdated(null);
field.createUI();
List<VersionData> vendorOptionVersionsList = new ArrayList<VersionData>();
vendorOptionVersionsList.add(VersionData.getLatestVersion(GeoServerVendorOption.class));
field.vendorOptionsUpdated(vendorOptionVersionsList);
}
Aggregations