use of com.sldeditor.filter.v2.function.temporal.TimePeriod 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.filter.v2.function.temporal.TimePeriod 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.filter.v2.function.temporal.TimePeriod in project sldeditor by robward-scisys.
the class FieldConfigTimePeriod method redoAction.
/**
* Redo action.
*
* @param undoRedoObject the undo/redo object
*/
@Override
public void redoAction(UndoInterface undoRedoObject) {
if (undoRedoObject != null) {
if (undoRedoObject.getNewValue() instanceof TimePeriod) {
TimePeriod newValue = (TimePeriod) undoRedoObject.getNewValue();
populateDuration(start, newValue.getStart());
populateDuration(end, newValue.getEnd());
}
}
}
use of com.sldeditor.filter.v2.function.temporal.TimePeriod in project sldeditor by robward-scisys.
the class FieldConfigTimePeriod method getStringValue.
/**
* Gets the string value.
*
* @return the string value
*/
@Override
public String getStringValue() {
TimePeriod timePeriod = new TimePeriod();
timePeriod.setStart(getDuration(start));
timePeriod.setEnd(getDuration(end));
return timePeriod.getString();
}
use of com.sldeditor.filter.v2.function.temporal.TimePeriod in project sldeditor by robward-scisys.
the class FieldConfigTimePeriod method revertToDefaultValue.
/**
* Revert to default value.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#revertToDefaultValue()
*/
@Override
public void revertToDefaultValue() {
TimePeriod timePeriod = new TimePeriod();
populateField(timePeriod);
}
Aggregations