use of com.sldeditor.ui.detail.config.FieldConfigPopulate in project sldeditor by robward-scisys.
the class PanelFieldTest method testGetField.
/**
* Test method for
* {@link com.sldeditor.filter.v2.expression.PanelField#getField(java.lang.Class, java.lang.String, java.lang.Class, java.util.List)}.
*/
@Test
public void testGetField() {
Class<?> classType = ExpressionPanelv2.class;
String valueTextLocalisation = "ExpressionSubPanel.value";
Map<Class<?>, Class<?>> expectedValueMap = new HashMap<Class<?>, Class<?>>();
expectedValueMap.put(Float.class, FieldConfigDouble.class);
expectedValueMap.put(Geometry.class, FieldConfigGeometry.class);
expectedValueMap.put(Date.class, FieldConfigDate.class);
expectedValueMap.put(ReferencedEnvelope.class, FieldConfigBoundingBox.class);
expectedValueMap.put(String.class, FieldConfigString.class);
expectedValueMap.put(Object.class, FieldConfigString.class);
expectedValueMap.put(Boolean.class, FieldConfigBoolean.class);
expectedValueMap.put(Integer.class, FieldConfigInteger.class);
expectedValueMap.put(Double.class, FieldConfigDouble.class);
expectedValueMap.put(Unit.class, FieldConfigMapUnits.class);
for (Class<?> nodeType : expectedValueMap.keySet()) {
FieldConfigPopulate fieldConfig = PanelField.getField(classType, valueTextLocalisation, nodeType);
Class<?> expected = expectedValueMap.get(nodeType);
Class<?> actual = (fieldConfig == null) ? null : fieldConfig.getClass();
assertEquals(nodeType.getName(), expected, actual);
}
// Special case
// Number.class
FieldConfigPopulate fieldConfig = PanelField.getField(classType, valueTextLocalisation, Number.class);
Class<?> expected = FieldConfigInteger.class;
Class<?> actual = fieldConfig.getClass();
assertEquals(Number.class.getName(), expected, actual);
TypeManager.getInstance().reset();
TypeManager.getInstance().setDataType(Float.class);
fieldConfig = PanelField.getField(classType, valueTextLocalisation, Number.class);
expected = FieldConfigDouble.class;
actual = fieldConfig.getClass();
assertEquals(Number.class.getName() + "/" + Float.class.getName(), expected, actual);
TypeManager.getInstance().reset();
TypeManager.getInstance().setDataType(Double.class);
fieldConfig = PanelField.getField(classType, valueTextLocalisation, Number.class);
expected = FieldConfigDouble.class;
actual = fieldConfig.getClass();
assertEquals(Number.class.getName() + "/" + Double.class.getName(), expected, actual);
TypeManager.getInstance().reset();
TypeManager.getInstance().setDataType(String.class);
fieldConfig = PanelField.getField(classType, valueTextLocalisation, Number.class);
expected = FieldConfigInteger.class;
actual = fieldConfig.getClass();
assertEquals(Number.class.getName(), expected, actual);
TypeManager.getInstance().reset();
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulate in project sldeditor by robward-scisys.
the class FilterManagerTest method checkFieldType.
/**
* Check field type.
*
* @param fieldIndex the field index
* @param fieldList the field list
* @param functionName the function name
* @param argList the arg list
*/
private void checkFieldType(int fieldIndex, List<FieldConfigBase> fieldList, FunctionName functionName, List<String> argList) {
int adjustedIndex = (fieldIndex >= functionName.getArgumentNames().size()) ? functionName.getArgumentNames().size() - 1 : fieldIndex;
String label = functionName.getArgumentNames().get(adjustedIndex);
String debugMessage = String.format("%s/%d %s", functionName.getName(), fieldIndex, label);
FieldConfigPopulate field = fieldList.get(fieldIndex);
assertNotNull(debugMessage, field);
Parameter<?> parameterType = functionName.getArguments().get(adjustedIndex);
Class<?> actual = typeMap.get(parameterType.getType());
assertEquals(debugMessage, field.getClass(), actual);
assertTrue(debugMessage, field.getLabel().compareTo(label) == 0);
argList.add(parameterType.getType().getSimpleName());
}
Aggregations