Search in sources :

Example 6 with DefaultFunctionFactory

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());
}
Also used : FunctionNameFilterAll(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterAll) ArrayList(java.util.ArrayList) FunctionName(org.opengis.filter.capability.FunctionName) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) FunctionNameFilterInterface(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface) Test(org.junit.Test)

Example 7 with DefaultFunctionFactory

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);
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) FunctionExpression(org.geotools.filter.FunctionExpression) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) Expression(org.opengis.filter.expression.Expression) FunctionExpression(org.geotools.filter.FunctionExpression) Test(org.junit.Test)

Aggregations

DefaultFunctionFactory (org.geotools.filter.function.DefaultFunctionFactory)7 Test (org.junit.Test)7 FunctionName (org.opengis.filter.capability.FunctionName)6 Expression (org.opengis.filter.expression.Expression)5 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)3 ArrayList (java.util.ArrayList)3 FilterFactory (org.opengis.filter.FilterFactory)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 FunctionExpression (org.geotools.filter.FunctionExpression)2 ExpressionNode (com.sldeditor.filter.v2.expression.ExpressionNode)1 FunctionNameFilterAll (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterAll)1 FunctionNameFilterInterface (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface)1 AttributeSelection (com.sldeditor.ui.attribute.AttributeSelection)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)1 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)1 LineString (com.vividsolutions.jts.geom.LineString)1 NameImpl (org.geotools.feature.NameImpl)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1