use of com.sldeditor.filter.v2.expression.ExpressionNode in project sldeditor by robward-scisys.
the class ExpressionNodeTest method testSetExpression.
/**
* Test method for
* {@link com.sldeditor.filter.v2.expression.ExpressionNode#setExpression(org.opengis.filter.expression.Expression)}.
*/
@Test
public void testSetExpression() {
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
ExpressionNode node = new ExpressionNode();
// Test literal expression
String expressionString = "Literalexpression";
Expression literal = ff.literal(expressionString);
node.setExpression(literal);
String expected = Localisation.getField(ExpressionPanelv2.class, "ExpressionPanelv2.literal") + " " + expressionString;
String actual = node.toString();
assertTrue(actual.compareTo(expected) == 0);
// Test attribute expression
String propertyName = "testproperty";
Expression attribute = ff.property(propertyName);
node.setExpression(attribute);
expected = Localisation.getField(ExpressionPanelv2.class, "ExpressionPanelv2.attribute") + " [" + attribute + "]";
actual = node.toString();
assertTrue(actual.compareTo(expected) == 0);
// Test attribute expression
literal = ff.literal(ff.property(propertyName));
node.setExpression(literal);
expected = Localisation.getField(ExpressionPanelv2.class, "ExpressionPanelv2.attribute") + " [" + attribute + "]";
actual = node.toString();
assertTrue(actual.compareTo(expected) == 0);
// Test math expression
Expression maths = ff.multiply(ff.literal(6), ff.literal(7));
node.setExpression(maths);
expected = "*";
actual = node.toString();
assertTrue(actual.compareTo(expected) == 0);
// Test function
FunctionImpl function = new ConcatenateFunction();
List<Expression> params = new ArrayList<Expression>();
params.add(ff.literal("world"));
params.add(ff.literal("dog"));
function.setParameters(params);
node.setExpression(function);
expected = "Concatenate([world], [dog])";
actual = node.toString();
assertTrue(actual.compareTo(expected) == 0);
// Test function expression
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
String name = "strConcat";
List<Expression> parameters = new ArrayList<Expression>();
parameters.add(ff.literal("cat"));
parameters.add(ff.literal("dog"));
Function functionExpression = functionFactory.function(name, parameters, null);
node.setExpression(functionExpression);
expected = "strConcat([cat], [dog])";
actual = node.toString();
assertTrue(actual.compareTo(expected) == 0);
// Test environment function
EnvFunction envExpression = (EnvFunction) ff.function("env", ff.literal("foo"), ff.literal(0));
node.setExpression(envExpression);
expected = "env([foo], [0])";
actual = node.toString();
assertTrue(actual.compareTo(expected) == 0);
}
use of com.sldeditor.filter.v2.expression.ExpressionNode in project sldeditor by robward-scisys.
the class ExpressionNodeTest method testExpressionNode.
/**
* Test method for {@link com.sldeditor.filter.v2.expression.ExpressionNode#ExpressionNode()}.
* Test method for {@link com.sldeditor.filter.v2.expression.ExpressionNode#toString()}. Test
* method for {@link com.sldeditor.filter.v2.expression.ExpressionNode#isValueOnly()}. Test
* method for {@link com.sldeditor.filter.v2.expression.ExpressionNode#setValueOnly(boolean)}.
*/
@Test
public void testExpressionNode() {
ExpressionNode node = new ExpressionNode();
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expressionNotSet")) == 0);
Class<?> type = String.class;
node.setType(type);
assertEquals(type, node.getType());
boolean isValueOnly = true;
node.setValueOnly(isValueOnly);
assertEquals(isValueOnly, node.isValueOnly());
}
use of com.sldeditor.filter.v2.expression.ExpressionNode in project sldeditor by robward-scisys.
the class ExpressionNodeTest method testSetName.
/**
* Test method for
* {@link com.sldeditor.filter.v2.expression.ExpressionNode#setName(java.lang.String)}.
*/
@Test
public void testSetName() {
String expectedName = "test";
ExpressionNode node = new ExpressionNode();
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expressionNotSet")) == 0);
node.setName(expectedName);
assertTrue(node.toString().compareTo(expectedName + " : " + Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expressionNotSet")) == 0);
}
use of com.sldeditor.filter.v2.expression.ExpressionNode in project sldeditor by robward-scisys.
the class ExpressionNodeTest method testSetExpressionType.
/**
* Test method for
* {@link com.sldeditor.filter.v2.expression.ExpressionNode#setExpressionType(com.sldeditor.filter.v2.expression.ExpressionTypeEnum)}.
* Test method for
* {@link com.sldeditor.filter.v2.expression.ExpressionNode#getExpressionType()}.
*/
@Test
public void testSetExpressionType() {
ExpressionNode node = new ExpressionNode();
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expressionNotSet")) == 0);
node.setExpressionType(ExpressionTypeEnum.LITERAL);
assertEquals(ExpressionTypeEnum.LITERAL, node.getExpressionType());
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.literalNotSet")) == 0);
node.setExpressionType(ExpressionTypeEnum.PROPERTY);
assertEquals(ExpressionTypeEnum.PROPERTY, node.getExpressionType());
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.propertyNotSet")) == 0);
assertNull(node.getExpression());
}
Aggregations