use of org.geotools.filter.function.DefaultFunctionFactory in project sldeditor by robward-scisys.
the class FunctionManagerTest method testGetFunctionNameList.
/**
* Test method for
* {@link com.sldeditor.filter.v2.function.FunctionManager#getFunctionNameList(java.lang.Class)}.
*/
@Test
public void testGetFunctionNameList() {
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
List<FunctionName> functionNameList = functionFactory.getFunctionNames();
// CHECKSTYLE:OFF
Class<?>[] allowedNumberTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Object.class };
// CHECKSTYLE:ON
List<Class<?>> allowedNumberTypesList = Arrays.asList(allowedNumberTypes);
int count = 0;
for (FunctionName functionName : functionNameList) {
Class<?> type = functionName.getReturn().getType();
if (allowedNumberTypesList.contains(type)) {
count++;
}
}
List<FunctionNameFilterInterface> functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
functionNameFilterList.add(new FunctionNameFilterAll());
List<FunctionName> actualList = FunctionManager.getInstance().getFunctionNameList(Number.class, functionNameFilterList);
assertEquals(count, actualList.size());
// Try with null
actualList = FunctionManager.getInstance().getFunctionNameList(null, null);
assertEquals(functionNameList.size(), actualList.size());
// Try with non-matching class
actualList = FunctionManager.getInstance().getFunctionNameList(FunctionManagerTest.class, functionNameFilterList);
assertTrue(actualList.isEmpty());
}
use of org.geotools.filter.function.DefaultFunctionFactory in project sldeditor by robward-scisys.
the class FunctionManagerTest method testCreateExpression.
/**
* Test method for
* {@link com.sldeditor.filter.v2.function.FunctionManager#createExpression(org.opengis.filter.capability.FunctionName)}.
*/
@Test
public void testCreateExpression() {
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
List<FunctionName> functionNameList = functionFactory.getFunctionNames();
FunctionName functionName = null;
Expression expression = FunctionManager.getInstance().createExpression(functionName);
assertNull(expression);
functionName = functionNameList.get(0);
expression = FunctionManager.getInstance().createExpression(functionName);
assertNotNull(expression);
FunctionExpression funcExpression = (FunctionExpression) expression;
assertTrue(functionName.getName().compareTo(funcExpression.getName()) == 0);
}
Aggregations