sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jso...@apache.org
Subject [sis] branch geoapi-4.0 updated: Feature : add Not/Id/FeatureId filters
Date Tue, 05 Feb 2019 14:22:33 GMT
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 a83fe5a  Feature : add Not/Id/FeatureId filters
a83fe5a is described below

commit a83fe5a3570b5976bcad643e526cfcbdde647485
Author: jsorel <johann.sorel@geomatys.com>
AuthorDate: Tue Feb 5 16:21:55 2019 +0100

    Feature : add Not/Id/FeatureId filters
---
 .../org/apache/sis/filter/DefaultFeatureId.java    |  92 +++++++++++++++
 .../apache/sis/filter/DefaultFilterFactory.java    |   8 +-
 .../main/java/org/apache/sis/filter/DefaultId.java | 131 +++++++++++++++++++++
 .../java/org/apache/sis/filter/DefaultNot.java     |  91 ++++++++++++++
 .../java/org/apache/sis/filter/DefaultAndTest.java |   2 +-
 .../apache/sis/filter/DefaultFeatureIdTest.java    |  94 +++++++++++++++
 .../java/org/apache/sis/filter/DefaultIdTest.java  |  93 +++++++++++++++
 .../{DefaultOrTest.java => DefaultNotTest.java}    |  39 ++----
 .../java/org/apache/sis/filter/DefaultOrTest.java  |   2 +-
 .../apache/sis/test/suite/FeatureTestSuite.java    |   3 +
 10 files changed, 517 insertions(+), 38 deletions(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFeatureId.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFeatureId.java
new file mode 100644
index 0000000..368fc17
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFeatureId.java
@@ -0,0 +1,92 @@
+/*
+ * 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 java.util.Objects;
+import org.apache.sis.internal.feature.AttributeConvention;
+import org.apache.sis.util.ArgumentChecks;
+import org.opengis.feature.Feature;
+import org.opengis.feature.PropertyNotFoundException;
+import org.opengis.filter.identity.FeatureId;
+import org.opengis.filter.identity.GmlObjectId;
+
+/**
+ * Filter feature id.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+final class DefaultFeatureId implements FeatureId, GmlObjectId, Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -2877500277700165269L;
+
+    private final String id;
+
+    public DefaultFeatureId(String id) {
+        ArgumentChecks.ensureNonNull("id", id);
+        this.id = id;
+    }
+
+    @Override
+    public String getID() {
+        return id;
+    }
+
+    @Override
+    public boolean matches(Object feature) {
+        if (feature instanceof Feature) {
+            final Feature f = (Feature) feature;
+            try {
+                Object id = f.getPropertyValue(AttributeConvention.IDENTIFIER);
+                return this.id.equals(String.valueOf(id));
+            } catch (PropertyNotFoundException ex) {
+                //normal
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final DefaultFeatureId other = (DefaultFeatureId) obj;
+        return Objects.equals(this.id, other.id);
+    }
+
+    @Override
+    public int hashCode() {
+        return 31 * id.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return "Id:" + id;
+    }
+}
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 f3a37ba..f3e553d 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
@@ -297,7 +297,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public FeatureId featureId(final String id) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new DefaultFeatureId(id);
     }
 
     /**
@@ -305,7 +305,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public GmlObjectId gmlObjectId(final String id) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new DefaultFeatureId(id);
     }
 
     // FILTERS /////////////////////////////////////////////////////////////////
@@ -351,7 +351,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public Not not(final Filter filter) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new DefaultNot(filter);
     }
 
     /**
@@ -359,7 +359,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public Id id(final Set<? extends Identifier> ids) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new DefaultId(ids);
     }
 
     /**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultId.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultId.java
new file mode 100644
index 0000000..204337e
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultId.java
@@ -0,0 +1,131 @@
+/*
+ * 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 java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+import org.apache.sis.internal.feature.AttributeConvention;
+import org.opengis.feature.Feature;
+import org.opengis.feature.PropertyNotFoundException;
+import org.opengis.filter.FilterVisitor;
+import org.opengis.filter.Id;
+import org.opengis.filter.identity.Identifier;
+
+/**
+ * Filter features using a list of predefined ids and discarding those not in the list.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+final class DefaultId implements Id, Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = 1404452049863376235L;
+
+    private final DualKeyMap keys = new DualKeyMap();
+
+    public DefaultId( final Set<? extends Identifier> ids ) {
+        for (Identifier id : ids) {
+            keys.put(id.getID(), id);
+        }
+    }
+
+    @Override
+    public Set<Object> getIDs() {
+        return Collections.unmodifiableSet(keys.keySet());
+    }
+
+    @Override
+    public Set<Identifier> getIdentifiers() {
+        return new HashSet<>(keys.values());
+    }
+
+    @Override
+    public boolean evaluate(Object object) {
+        if (object instanceof Feature) {
+            final Feature f = (Feature) object;
+            try {
+                Object id = f.getPropertyValue(AttributeConvention.IDENTIFIER);
+                if (id == null) {
+                   return false;
+                } else if (id instanceof String) {
+                    return keys.containsKey(id);
+                } else {
+                    //it often happens like in web services that keys are sent as Strings
+                    //but the real type might be different
+                    return keys.containsKey(id) || keys.containsKey(String.valueOf(id));
+                }
+            } catch (PropertyNotFoundException ex) {
+                //normal
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Accepts a visitor.
+     */
+    @Override
+    public Object accept(FilterVisitor visitor, Object extraData) {
+        return visitor.visit(this, extraData);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final DefaultId other = (DefaultId) obj;
+        return Objects.equals(this.keys, other.keys);
+    }
+
+    @Override
+    public int hashCode() {
+        return keys.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return AbstractExpression.toStringTree("Ids", keys.keySet());
+    }
+
+    private static class DualKeyMap extends HashMap<Object,Identifier> {
+
+        @Override
+        public boolean containsValue(final Object value) {
+            if (value instanceof Identifier) {
+                Identifier ident = (Identifier) value;
+                return containsKey(ident.getID());
+            } else {
+                return false;
+            }
+        }
+    }
+}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultNot.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultNot.java
new file mode 100644
index 0000000..88fc8e4
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultNot.java
@@ -0,0 +1,91 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.Objects;
+import org.apache.sis.util.ArgumentChecks;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterVisitor;
+import org.opengis.filter.Not;
+
+/**
+ * Negation filter.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+final class DefaultNot implements Not, Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -1216799270370223357L;
+
+    private final Filter filter;
+
+    public DefaultNot(Filter filter) {
+        ArgumentChecks.ensureNonNull("filter", filter);
+        this.filter = filter;
+    }
+
+    @Override
+    public Filter getFilter() {
+        return filter;
+    }
+
+    @Override
+    public boolean evaluate(Object object) {
+        return !filter.evaluate(object);
+    }
+
+    /**
+     * Accepts a visitor.
+     */
+    @Override
+    public Object accept(FilterVisitor visitor, Object extraData) {
+        return visitor.visit(this, extraData);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final DefaultNot other = (DefaultNot) obj;
+        return Objects.equals(this.filter, other.filter);
+    }
+
+    @Override
+    public int hashCode() {
+        return 32 * filter.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return AbstractExpression.toStringTree("Not", Arrays.asList(filter));
+    }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultAndTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultAndTest.java
index f054e3a..4db8227 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultAndTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultAndTest.java
@@ -81,7 +81,7 @@ public class DefaultAndTest extends TestCase {
         final Filter filterTrue = factory.isNull(literalNull);
         final Filter filterFalse = factory.isNull(literalNotNull);
 
-        final Map<String,String> feature = new HashMap();
+        final Map<String,String> feature = new HashMap<>();
         feature.put("attNotNull", "text");
 
         assertEquals(true, new DefaultAnd(Arrays.asList(filterTrue, filterTrue)).evaluate(feature));
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultFeatureIdTest.java
b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultFeatureIdTest.java
new file mode 100644
index 0000000..c10cb70
--- /dev/null
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultFeatureIdTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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 org.apache.sis.feature.builder.AttributeRole;
+import org.apache.sis.feature.builder.FeatureTypeBuilder;
+import static org.apache.sis.test.Assert.assertSerializedEquals;
+import org.apache.sis.test.TestCase;
+import org.junit.Assert;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.opengis.feature.Feature;
+import org.opengis.feature.FeatureType;
+import org.opengis.filter.FilterFactory2;
+
+/**
+ * Tests {@link DefaultFeatureId}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public class DefaultFeatureIdTest extends TestCase {
+    /**
+     * Test factory.
+     */
+    @Test
+    public void testConstructor() {
+        final FilterFactory2 factory = new DefaultFilterFactory();
+        assertNotNull(factory.featureId("abc"));
+        assertNotNull(factory.gmlObjectId("abc"));
+    }
+
+    /**
+     * Tests evaluation.
+     */
+    @Test
+    public void testEvaluate() {
+        final DefaultFeatureId fid = new DefaultFeatureId("123");
+
+        // a feature type with a string identifier
+        final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
+        ftb.setName("type1");
+        ftb.addAttribute(String.class).setName("att").addRole(AttributeRole.IDENTIFIER_COMPONENT);
+        final FeatureType typeString = ftb.build();
+
+        // a feature type with an integer identifier
+        ftb.clear();
+        ftb.setName("type2");
+        ftb.addAttribute(Integer.class).setName("att").addRole(AttributeRole.IDENTIFIER_COMPONENT);
+        final FeatureType typeInt = ftb.build();
+
+        // a feature type with no identifier
+        ftb.clear();
+        ftb.setName("type3");
+        final FeatureType typeNone = ftb.build();
+
+        final Feature feature1 = typeString.newInstance();
+        feature1.setPropertyValue("att", "123");
+
+        final Feature feature2 = typeInt.newInstance();
+        feature2.setPropertyValue("att", 123);
+
+        final Feature feature3 = typeNone.newInstance();
+
+        Assert.assertTrue(fid.matches(feature1));
+        Assert.assertTrue(fid.matches(feature2));
+        Assert.assertFalse(fid.matches(feature3));
+    }
+
+    /**
+     * Tests serialization.
+     */
+    @Test
+    public void testSerialize() {
+        assertSerializedEquals(new DefaultFeatureId("abc"));
+    }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultIdTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultIdTest.java
new file mode 100644
index 0000000..87d6dc6
--- /dev/null
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultIdTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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 java.util.HashSet;
+import java.util.Set;
+import org.apache.sis.feature.builder.AttributeRole;
+import org.apache.sis.feature.builder.FeatureTypeBuilder;
+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.feature.Feature;
+import org.opengis.feature.FeatureType;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.identity.Identifier;
+
+/**
+ * Tests {@link DefaultId}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public class DefaultIdTest extends TestCase {
+    /**
+     * Test factory.
+     */
+    @Test
+    public void testConstructor() {
+        final FilterFactory2 factory = new DefaultFilterFactory();
+        assertNotNull(factory.id(Collections.singleton(factory.featureId("abc"))));
+    }
+
+    /**
+     * Tests evaluation.
+     */
+    @Test
+    public void testEvaluate() {
+        final FilterFactory2 factory = new DefaultFilterFactory();
+
+        final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
+        ftb.setName("type");
+        ftb.addAttribute(String.class).setName("att").addRole(AttributeRole.IDENTIFIER_COMPONENT);
+        final FeatureType type = ftb.build();
+
+
+        final Feature feature1 = type.newInstance();
+        feature1.setPropertyValue("att", "123");
+
+        final Feature feature2 = type.newInstance();
+        feature2.setPropertyValue("att", "abc");
+
+        final Feature feature3 = type.newInstance();
+        feature3.setPropertyValue("att", "abc123");
+
+        final Set<Identifier> ids = new HashSet<>();
+        ids.add(factory.featureId("abc"));
+        ids.add(factory.featureId("123"));
+        final DefaultId id = new DefaultId(ids);
+
+        assertEquals(true, id.evaluate(feature1));
+        assertEquals(true, id.evaluate(feature2));
+        assertEquals(false, id.evaluate(feature3));
+    }
+
+    /**
+     * Tests serialization.
+     */
+    @Test
+    public void testSerialize() {
+        final FilterFactory2 factory = new DefaultFilterFactory();
+        assertSerializedEquals(new DefaultId(Collections.singleton(factory.featureId("abc"))));
+    }
+
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultOrTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultNotTest.java
similarity index 60%
copy from core/sis-feature/src/test/java/org/apache/sis/filter/DefaultOrTest.java
copy to core/sis-feature/src/test/java/org/apache/sis/filter/DefaultNotTest.java
index d51ebe0..06bb5d5 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultOrTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultNotTest.java
@@ -16,12 +16,10 @@
  */
 package org.apache.sis.filter;
 
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import static org.apache.sis.test.Assert.assertSerializedEquals;
 import org.apache.sis.test.TestCase;
-import org.junit.Assert;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import org.junit.Test;
@@ -31,14 +29,14 @@ import org.opengis.filter.expression.Literal;
 import org.opengis.filter.expression.PropertyName;
 
 /**
- * Tests {@link DefaultOr}.
+ * Tests {@link DefaultNot}.
  *
  * @author Johann Sorel (Geomatys)
  * @version 1.0
  * @since   1.0
  * @module
  */
-public class DefaultOrTest extends TestCase {
+public class DefaultNotTest extends TestCase {
     /**
      * Test factory.
      */
@@ -47,27 +45,7 @@ public class DefaultOrTest extends TestCase {
         final FilterFactory2 factory = new DefaultFilterFactory();
         final Literal literal = factory.literal("text");
         final Filter filter = factory.isNull(literal);
-
-        assertNotNull(factory.or(filter, filter));
-        assertNotNull(factory.or(Arrays.asList(filter, filter, filter)));
-
-        try {
-            factory.or(null, null);
-            Assert.fail("Creation of an OR with a null child filter must raise an exception");
-        } catch (Exception ex) {}
-        try {
-            factory.or(filter, null);
-            Assert.fail("Creation of an OR with a null child filter must raise an exception");
-        } catch (Exception ex) {}
-        try {
-            factory.or(null, filter);
-            Assert.fail("Creation of an OR with a null child filter must raise an exception");
-        } catch (Exception ex) {}
-        try {
-            factory.or(Arrays.asList(filter));
-            Assert.fail("Creation of an OR with less then two children filters must raise
an exception");
-        } catch (Exception ex) {}
-
+        assertNotNull(factory.not(filter));
     }
 
     /**
@@ -80,14 +58,11 @@ public class DefaultOrTest extends TestCase {
         final PropertyName literalNull = factory.property("attNull");
         final Filter filterTrue = factory.isNull(literalNull);
         final Filter filterFalse = factory.isNull(literalNotNull);
-
-        final Map<String,String> feature = new HashMap();
+        final Map<String,String> feature = new HashMap<>();
         feature.put("attNotNull", "text");
 
-        assertEquals(true, new DefaultOr(Arrays.asList(filterTrue, filterTrue)).evaluate(feature));
-        assertEquals(true, new DefaultOr(Arrays.asList(filterFalse, filterTrue)).evaluate(feature));
-        assertEquals(true, new DefaultOr(Arrays.asList(filterTrue, filterFalse)).evaluate(feature));
-        assertEquals(false, new DefaultOr(Arrays.asList(filterFalse, filterFalse)).evaluate(feature));
+        assertEquals(false, new DefaultNot(filterTrue).evaluate(feature));
+        assertEquals(true, new DefaultNot(filterFalse).evaluate(feature));
     }
 
     /**
@@ -98,7 +73,7 @@ public class DefaultOrTest extends TestCase {
         final FilterFactory2 factory = new DefaultFilterFactory();
         final Literal literal = factory.literal("text");
         final Filter filter = factory.isNull(literal);
-        assertSerializedEquals(new DefaultOr(Arrays.asList(filter,filter)));
+        assertSerializedEquals(new DefaultNot(filter));
     }
 
 }
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultOrTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultOrTest.java
index d51ebe0..09537ef 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultOrTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultOrTest.java
@@ -81,7 +81,7 @@ public class DefaultOrTest extends TestCase {
         final Filter filterTrue = factory.isNull(literalNull);
         final Filter filterFalse = factory.isNull(literalNotNull);
 
-        final Map<String,String> feature = new HashMap();
+        final Map<String,String> feature = new HashMap<>();
         feature.put("attNotNull", "text");
 
         assertEquals(true, new DefaultOr(Arrays.asList(filterTrue, filterTrue)).evaluate(feature));
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 408d9e2..8445840 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
@@ -53,6 +53,9 @@ import org.junit.BeforeClass;
     org.apache.sis.filter.DefaultPropertyNameTest.class,
     org.apache.sis.filter.DefaultAndTest.class,
     org.apache.sis.filter.DefaultOrTest.class,
+    org.apache.sis.filter.DefaultNotTest.class,
+    org.apache.sis.filter.DefaultFeatureIdTest.class,
+    org.apache.sis.filter.DefaultIdTest.class,
     org.apache.sis.internal.feature.AttributeConventionTest.class,
     org.apache.sis.internal.feature.Java2DTest.class,
     org.apache.sis.internal.feature.ESRITest.class,


Mime
View raw message