You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by js...@apache.org on 2019/02/05 15:25:47 UTC
[sis] branch geoapi-4.0 updated: Feature : add
Add/Divide/Multiply/Subtract expressions
This is an automated email from the ASF dual-hosted git repository.
jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 99b224e Feature : add Add/Divide/Multiply/Subtract expressions
99b224e is described below
commit 99b224e31c95c70d6a275472105df5633068eb8a
Author: jsorel <jo...@geomatys.com>
AuthorDate: Tue Feb 5 17:25:11 2019 +0100
Feature : add Add/Divide/Multiply/Subtract expressions
---
.../sis/filter/AbstractBinaryExpression.java | 116 +++++++++++++++++++++
.../java/org/apache/sis/filter/DefaultAdd.java | 80 ++++++++++++++
.../java/org/apache/sis/filter/DefaultDivide.java | 80 ++++++++++++++
.../apache/sis/filter/DefaultFilterFactory.java | 8 +-
.../org/apache/sis/filter/DefaultMultiply.java | 80 ++++++++++++++
.../org/apache/sis/filter/DefaultSubtract.java | 81 ++++++++++++++
.../java/org/apache/sis/filter/DefaultAddTest.java | 63 +++++++++++
.../org/apache/sis/filter/DefaultDivideTest.java | 63 +++++++++++
.../org/apache/sis/filter/DefaultMultiplyTest.java | 63 +++++++++++
.../org/apache/sis/filter/DefaultSubtractTest.java | 63 +++++++++++
.../apache/sis/test/suite/FeatureTestSuite.java | 4 +
11 files changed, 697 insertions(+), 4 deletions(-)
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryExpression.java b/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryExpression.java
new file mode 100644
index 0000000..9cce5d6
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryExpression.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.io.Serializable;
+import org.opengis.filter.expression.BinaryExpression;
+import org.opengis.filter.expression.Expression;
+
+
+/**
+ * Base class for expressions performing operations on two values.
+ * The nature of the operation is dependent on the subclass.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+abstract class AbstractBinaryExpression extends AbstractExpression implements BinaryExpression, Serializable {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = -4430693449544064634L;
+
+ /**
+ * The first of the two expressions to be used by this operator.
+ *
+ * @see #getExpression1()
+ */
+ protected final Expression expression1;
+
+ /**
+ * The second of the two expressions to be used by this operator.
+ *
+ * @see #getExpression2()
+ */
+ protected final Expression expression2;
+
+ /**
+ * Creates a new binary operator.
+ * It is caller responsibility to ensure that no argument is null.
+ */
+ AbstractBinaryExpression(final Expression expression1, final Expression expression2) {
+ this.expression1 = expression1;
+ this.expression2 = expression2;
+ }
+
+ /**
+ * Returns the mathematical symbol for this binary operator.
+ * For comparison operators, the symbol should be one of the following:
+ * {@literal < > ≤ ≥ = ≠}.
+ */
+ protected abstract char symbol();
+
+ /**
+ * Returns the first of the two expressions to be used by this operator.
+ */
+ @Override
+ public final Expression getExpression1() {
+ return expression1;
+ }
+
+ /**
+ * Returns the second of the two expressions to be used by this operator.
+ */
+ @Override
+ public final Expression getExpression2() {
+ return expression2;
+ }
+
+ /**
+ * Returns a hash code value for this operator.
+ */
+ @Override
+ public int hashCode() {
+ // We use the symbol as a way to differentiate the subclasses.
+ return (31 * expression1.hashCode() + expression2.hashCode()) ^ symbol();
+ }
+
+ /**
+ * Compares this operator with the given object for equality.
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj != null && obj.getClass() == getClass()) {
+ final AbstractBinaryExpression other = (AbstractBinaryExpression) obj;
+ return expression1.equals(other.expression1) &&
+ expression2.equals(other.expression2);
+ }
+ return false;
+ }
+
+ /**
+ * Returns a string representation of this operator.
+ */
+ @Override
+ public String toString() {
+ return new StringBuilder(30).append(expression1).append(' ').append(symbol()).append(' ')
+ .append(expression2).toString();
+ }
+}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultAdd.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultAdd.java
new file mode 100644
index 0000000..b5d2c60
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultAdd.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.Collections;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.opengis.feature.AttributeType;
+import org.opengis.feature.FeatureType;
+import org.opengis.feature.PropertyType;
+import org.opengis.filter.expression.Add;
+import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.ExpressionVisitor;
+
+/**
+ * Addition expression.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+final class DefaultAdd extends AbstractBinaryExpression implements Add {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = 7251500772368619980L;
+
+ private static final AttributeType<Number> EXPECTED_TYPE = new DefaultAttributeType<>(
+ Collections.singletonMap(DefaultAttributeType.NAME_KEY, NAME),
+ Number.class, 1, 1, null, (AttributeType<?>[]) null);
+
+ public DefaultAdd(Expression expressoin1, Expression expression2) {
+ super(expressoin1, expression2);
+ }
+
+ /**
+ * Accepts a visitor.
+ */
+ @Override
+ public Object accept(ExpressionVisitor visitor, Object extraData) {
+ return visitor.visit(this, extraData);
+ }
+
+ @Override
+ protected char symbol() {
+ return '+';
+ }
+
+ @Override
+ public Object evaluate(Object object) {
+ final Double val1 = expression1.evaluate(object, Double.class);
+ final Double val2 = expression2.evaluate(object, Double.class);
+
+ if (val1 == null || val2 == null) {
+ return null;
+ }
+
+ return val1 + val2;
+ }
+
+ @Override
+ public PropertyType expectedType(FeatureType type) {
+ return EXPECTED_TYPE;
+ }
+
+}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultDivide.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultDivide.java
new file mode 100644
index 0000000..b184707
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultDivide.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.Collections;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.opengis.feature.AttributeType;
+import org.opengis.feature.FeatureType;
+import org.opengis.feature.PropertyType;
+import org.opengis.filter.expression.Divide;
+import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.ExpressionVisitor;
+
+/**
+ * Division expression.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+final class DefaultDivide extends AbstractBinaryExpression implements Divide {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = -3857311165395402436L;
+
+ private static final AttributeType<Number> EXPECTED_TYPE = new DefaultAttributeType<>(
+ Collections.singletonMap(DefaultAttributeType.NAME_KEY, NAME),
+ Number.class, 1, 1, null, (AttributeType<?>[]) null);
+
+ public DefaultDivide(Expression expressoin1, Expression expression2) {
+ super(expressoin1, expression2);
+ }
+
+ /**
+ * Accepts a visitor.
+ */
+ @Override
+ public Object accept(ExpressionVisitor visitor, Object extraData) {
+ return visitor.visit(this, extraData);
+ }
+
+ @Override
+ protected char symbol() {
+ return '/';
+ }
+
+ @Override
+ public Object evaluate(Object object) {
+ final Double val1 = expression1.evaluate(object, Double.class);
+ final Double val2 = expression2.evaluate(object, Double.class);
+
+ if (val1 == null || val2 == null) {
+ return null;
+ }
+
+ return val1 / val2;
+ }
+
+ @Override
+ public PropertyType expectedType(FeatureType type) {
+ return EXPECTED_TYPE;
+ }
+
+}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
index f3e553d..b9851d5 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
@@ -662,7 +662,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
*/
@Override
public Add add(final Expression expr1, final Expression expr2) {
- throw new UnsupportedOperationException("Not supported yet.");
+ return new DefaultAdd(expr1, expr2);
}
/**
@@ -670,7 +670,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
*/
@Override
public Divide divide(final Expression expr1, final Expression expr2) {
- throw new UnsupportedOperationException("Not supported yet.");
+ return new DefaultDivide(expr1, expr2);
}
/**
@@ -678,7 +678,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
*/
@Override
public Multiply multiply(final Expression expr1, final Expression expr2) {
- throw new UnsupportedOperationException("Not supported yet.");
+ return new DefaultMultiply(expr1, expr2);
}
/**
@@ -686,7 +686,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
*/
@Override
public Subtract subtract(final Expression expr1, final Expression expr2) {
- throw new UnsupportedOperationException("Not supported yet.");
+ return new DefaultSubtract(expr1, expr2);
}
/**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultMultiply.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultMultiply.java
new file mode 100644
index 0000000..1b088a4
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultMultiply.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.Collections;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.opengis.feature.AttributeType;
+import org.opengis.feature.FeatureType;
+import org.opengis.feature.PropertyType;
+import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.ExpressionVisitor;
+import org.opengis.filter.expression.Multiply;
+
+/**
+ * Multiply expression.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+final class DefaultMultiply extends AbstractBinaryExpression implements Multiply {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = 2082613762722323696L;
+
+ private static final AttributeType<Number> EXPECTED_TYPE = new DefaultAttributeType<>(
+ Collections.singletonMap(DefaultAttributeType.NAME_KEY, NAME),
+ Number.class, 1, 1, null, (AttributeType<?>[]) null);
+
+ public DefaultMultiply(Expression expressoin1, Expression expression2) {
+ super(expressoin1, expression2);
+ }
+
+ /**
+ * Accepts a visitor.
+ */
+ @Override
+ public Object accept(ExpressionVisitor visitor, Object extraData) {
+ return visitor.visit(this, extraData);
+ }
+
+ @Override
+ protected char symbol() {
+ return '*';
+ }
+
+ @Override
+ public Object evaluate(Object object) {
+ final Double val1 = expression1.evaluate(object, Double.class);
+ final Double val2 = expression2.evaluate(object, Double.class);
+
+ if (val1 == null || val2 == null) {
+ return null;
+ }
+
+ return val1 * val2;
+ }
+
+ @Override
+ public PropertyType expectedType(FeatureType type) {
+ return EXPECTED_TYPE;
+ }
+
+}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSubtract.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSubtract.java
new file mode 100644
index 0000000..f76d6b2
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSubtract.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.Collections;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.opengis.feature.AttributeType;
+import org.opengis.feature.FeatureType;
+import org.opengis.feature.PropertyType;
+import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.ExpressionVisitor;
+import org.opengis.filter.expression.Subtract;
+
+/**
+ * Subtraction expression.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+final class DefaultSubtract extends AbstractBinaryExpression implements Subtract {
+
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = -6691179262852420992L;
+
+ private static final AttributeType<Number> EXPECTED_TYPE = new DefaultAttributeType<>(
+ Collections.singletonMap(DefaultAttributeType.NAME_KEY, NAME),
+ Number.class, 1, 1, null, (AttributeType<?>[]) null);
+
+ public DefaultSubtract(Expression expressoin1, Expression expression2) {
+ super(expressoin1, expression2);
+ }
+
+ /**
+ * Accepts a visitor.
+ */
+ @Override
+ public Object accept(ExpressionVisitor visitor, Object extraData) {
+ return visitor.visit(this, extraData);
+ }
+
+ @Override
+ protected char symbol() {
+ return '-';
+ }
+
+ @Override
+ public Object evaluate(Object object) {
+ final Double val1 = expression1.evaluate(object, Double.class);
+ final Double val2 = expression2.evaluate(object, Double.class);
+
+ if (val1 == null || val2 == null) {
+ return null;
+ }
+
+ return val1 - val2;
+ }
+
+ @Override
+ public PropertyType expectedType(FeatureType type) {
+ return EXPECTED_TYPE;
+ }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultAddTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultAddTest.java
new file mode 100644
index 0000000..3a762f6
--- /dev/null
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultAddTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import static org.apache.sis.test.Assert.assertSerializedEquals;
+import org.apache.sis.test.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.opengis.filter.FilterFactory2;
+
+/**
+ * Tests {@link DefaultAdd}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+public class DefaultAddTest extends TestCase {
+ /**
+ * Test factory.
+ */
+ @Test
+ public void testConstructor() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertNotNull(factory.add(factory.literal(1), factory.literal(2)));
+ }
+
+ /**
+ * Tests evaluation.
+ */
+ @Test
+ public void testEvaluate() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+
+ assertEquals(30.0, new DefaultAdd(factory.literal(10), factory.literal(20)).evaluate(null));
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialize() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertSerializedEquals(new DefaultAdd(factory.literal(1), factory.literal(2)));
+ }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultDivideTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultDivideTest.java
new file mode 100644
index 0000000..a7a05de
--- /dev/null
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultDivideTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import static org.apache.sis.test.Assert.assertSerializedEquals;
+import org.apache.sis.test.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.opengis.filter.FilterFactory2;
+
+/**
+ * Tests {@link DefaultDivide}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+public class DefaultDivideTest extends TestCase {
+ /**
+ * Test factory.
+ */
+ @Test
+ public void testConstructor() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertNotNull(factory.divide(factory.literal(1), factory.literal(2)));
+ }
+
+ /**
+ * Tests evaluation.
+ */
+ @Test
+ public void testEvaluate() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+
+ assertEquals(0.5, new DefaultDivide(factory.literal(10), factory.literal(20)).evaluate(null));
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialize() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertSerializedEquals(new DefaultDivide(factory.literal(1), factory.literal(2)));
+ }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultMultiplyTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultMultiplyTest.java
new file mode 100644
index 0000000..7ed8593
--- /dev/null
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultMultiplyTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import static org.apache.sis.test.Assert.assertSerializedEquals;
+import org.apache.sis.test.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.opengis.filter.FilterFactory2;
+
+/**
+ * Tests {@link DefaultMultiply}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+public class DefaultMultiplyTest extends TestCase {
+ /**
+ * Test factory.
+ */
+ @Test
+ public void testConstructor() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertNotNull(factory.multiply(factory.literal(1), factory.literal(2)));
+ }
+
+ /**
+ * Tests evaluation.
+ */
+ @Test
+ public void testEvaluate() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+
+ assertEquals(200.0, new DefaultMultiply(factory.literal(10), factory.literal(20)).evaluate(null));
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialize() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertSerializedEquals(new DefaultMultiply(factory.literal(1), factory.literal(2)));
+ }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultSubtractTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultSubtractTest.java
new file mode 100644
index 0000000..3e85dd8
--- /dev/null
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultSubtractTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import static org.apache.sis.test.Assert.assertSerializedEquals;
+import org.apache.sis.test.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.opengis.filter.FilterFactory2;
+
+/**
+ * Tests {@link DefaultSubtract}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+public class DefaultSubtractTest extends TestCase {
+ /**
+ * Test factory.
+ */
+ @Test
+ public void testConstructor() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertNotNull(factory.subtract(factory.literal(1), factory.literal(2)));
+ }
+
+ /**
+ * Tests evaluation.
+ */
+ @Test
+ public void testEvaluate() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+
+ assertEquals(-10.0, new DefaultSubtract(factory.literal(10), factory.literal(20)).evaluate(null));
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialize() {
+ final FilterFactory2 factory = new DefaultFilterFactory();
+ assertSerializedEquals(new DefaultSubtract(factory.literal(1), factory.literal(2)));
+ }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
index 8445840..48a59a6 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
@@ -56,6 +56,10 @@ import org.junit.BeforeClass;
org.apache.sis.filter.DefaultNotTest.class,
org.apache.sis.filter.DefaultFeatureIdTest.class,
org.apache.sis.filter.DefaultIdTest.class,
+ org.apache.sis.filter.DefaultAddTest.class,
+ org.apache.sis.filter.DefaultDivideTest.class,
+ org.apache.sis.filter.DefaultMultiplyTest.class,
+ org.apache.sis.filter.DefaultSubtractTest.class,
org.apache.sis.internal.feature.AttributeConventionTest.class,
org.apache.sis.internal.feature.Java2DTest.class,
org.apache.sis.internal.feature.ESRITest.class,