use of com.sldeditor.ui.detail.config.FieldConfigDate in project sldeditor by robward-scisys.
the class FieldConfigDateTest method testRevertToDefaultValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDate#revertToDefaultValue()}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigDate field = new FieldConfigDate(new FieldConfigCommonData(Date.class, FieldIdEnum.NAME, "label", valueOnly));
field.revertToDefaultValue();
assertNull(field.getStringValue());
field.createUI();
field.revertToDefaultValue();
String expectedDefaultValue = "default value";
assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) != 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigDate in project sldeditor by robward-scisys.
the class FieldConfigDateTest method testGenerateExpression.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigDate#generateExpression()}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDate#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDate#populateField(java.util.Date)}. Test
* method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDate#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigDate#getStringValue()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
class TestFieldConfigDate extends FieldConfigDate {
public TestFieldConfigDate(FieldConfigCommonData commonData) {
super(commonData);
}
public Expression callGenerateExpression() {
return generateExpression();
}
}
TestFieldConfigDate field = new TestFieldConfigDate(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
Expression actualExpression = field.callGenerateExpression();
assertNull(actualExpression);
// Try string values - erroneous
field.createUI();
field.populateExpression("");
SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String dateString = "10-01-2012 23:13:26";
Date dateTime1 = null;
try {
dateTime1 = f.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
field.populateExpression(dateTime1);
actualExpression = field.callGenerateExpression();
DateFormat df = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
DateFormat tf = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH);
String dateFormat1String = String.format("%sT%sZ", df.format(dateTime1), tf.format(dateTime1));
assertTrue(dateFormat1String.compareTo(actualExpression.toString()) == 0);
field.populateExpression(dateString);
actualExpression = field.callGenerateExpression();
String dateFormat1aString = String.format("%sT%sZ", df.format(dateTime1), tf.format(dateTime1));
assertTrue(dateFormat1aString.compareTo(actualExpression.toString()) == 0);
String dateTime2 = "23-05-2015 11:56:47";
field.setTestValue(FieldIdEnum.UNKNOWN, dateTime2);
Date dateTime21 = null;
try {
dateTime21 = f.parse(dateTime2);
} catch (ParseException e) {
e.printStackTrace();
}
String dateFormat2String = String.format("%sT%sZ", df.format(dateTime21), tf.format(dateTime21));
actualExpression = field.callGenerateExpression();
assertTrue(dateFormat2String.compareTo(actualExpression.toString()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigDate in project sldeditor by robward-scisys.
the class FieldConfigDateTest method testCreateCopy.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDate#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
*/
@Test
public void testCreateCopy() {
boolean valueOnly = true;
class TestFieldConfigDate extends FieldConfigDate {
public TestFieldConfigDate(FieldConfigCommonData commonData) {
super(commonData);
}
public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
return createCopy(fieldConfigBase);
}
}
TestFieldConfigDate field = new TestFieldConfigDate(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
FieldConfigDate copy = (FieldConfigDate) field.callCreateCopy(null);
assertNull(copy);
copy = (FieldConfigDate) field.callCreateCopy(field);
assertEquals(field.getFieldId(), copy.getFieldId());
assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Aggregations