/*******************************************************************************
 * Copyright 2014, 2017 gwt-ol3
 *
 * Licensed 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 ol.format.filter;

import ol.GwtOL3BaseTestCase;
import ol.OLFactory;

/**
 * Test for filters.
 * 
 * @author Tino Desjardins
 *
 */
public class FilterTest extends GwtOL3BaseTestCase {
   
    public void testAnd() {        
        injectUrlAndTest(() -> {
            
            EqualTo equalTo = new EqualTo("attribute", "value");
            EqualTo equalTo2 = new EqualTo("attribute2", 1);
            
            And andFilter = new And(equalTo, equalTo2);
            assertNotNull(andFilter);

        });
    }
    
    public void testBbox() {        
        injectUrlAndTest(() -> {
            
            Bbox bboxFilter = new Bbox("geometryName", OLFactory.createExtent(0, 0, 1, 1), "EPSG:3857");
            assertNotNull(bboxFilter);
            
            bboxFilter.setExtent(OLFactory.createExtent(1, 1, 2, 2));
            bboxFilter.setGeometryName("geometryAttribute");
            bboxFilter.setSrsName("EPSG:4326");

        });
    }
    
    public void testEqualTo() {        
        injectUrlAndTest(() -> {
            
            EqualTo equalTo = new EqualTo("attribute", "value");
            assertNotNull(equalTo);
            
            EqualTo equalToInteger = new EqualTo("attribute", 1);
            assertNotNull(equalToInteger);
            
            EqualTo equalToDouble = new EqualTo("attribute", 1.25);
            assertNotNull(equalToDouble);

        });
    }
    
    public void testGreaterThan() {        
        injectUrlAndTest(() -> {
            
            GreaterThan greaterThan = new GreaterThan("attribute", 5);
            assertNotNull(greaterThan);

        });
    }
    
    public void testGreaterThanOrEqualTo() {        
        injectUrlAndTest(() -> {
            
            GreaterThanOrEqualTo greaterThanOrEqualTo = new GreaterThanOrEqualTo("attribute", 5);
            assertNotNull(greaterThanOrEqualTo);

        });
    }
    
    public void testIsBetween() {        
        injectUrlAndTest(() -> {
            
            IsBetween isBetween = new IsBetween("attribute", 5, 10);
            assertNotNull(isBetween);

        });
    }
    
    public void testIsLike() {        
        injectUrlAndTest(() -> {
            
            IsLike isLike = new IsLike("attribute", "value");
            assertNotNull(isLike);

        });
    }
    
    public void testIsNull() {        
        injectUrlAndTest(() -> {
            
            IsNull isNull = new IsNull("attribute");
            assertNotNull(isNull);

        });
    }
    
    public void testLessThan() {        
        injectUrlAndTest(() -> {
            
            LessThan lessThan = new LessThan("attribute", 5);
            assertNotNull(lessThan);

        });
    }
    
    public void testLessThanOrEqualTo() {        
        injectUrlAndTest(() -> {
            
            LessThanOrEqualTo lessThanOrEqualTo = new LessThanOrEqualTo("attribute", 5);
            assertNotNull(lessThanOrEqualTo);

        });
    }
    
    public void testNotEqualTo() {        
        injectUrlAndTest(() -> {
            
            NotEqualTo notEqualTo = new NotEqualTo("attribute", "value");
            assertNotNull(notEqualTo);
            
            NotEqualTo notEqualToInteger = new NotEqualTo("attribute", 1);
            assertNotNull(notEqualToInteger);
            
            NotEqualTo notEqualToDouble = new NotEqualTo("attribute", 1.25);
            assertNotNull(notEqualToDouble);

        });
    }
    
}

@@ -772,16 +772,38 @@
 ilter;%0A%0A
+import ol.Coordinate;%0A
 import o
@@ -844,16 +844,39 @@
 Factory;
+%0Aimport ol.geom.Circle;
 %0A%0A/**%0A *
@@ -2534,36 +2534,24 @@
 est(() -%3E %7B%0A
-            
 %0A           
@@ -2679,32 +2679,293 @@
 hanOrEqualTo);%0A%0A
+        %7D);%0A    %7D%0A%0A    public void testIntersects() %7B%0A        injectUrlAndTest(() -%3E %7B%0A%0A            Intersects intersectsFilter = new Intersects(%22geometryName%22, new Circle(Coordinate.create(0, 0), 2), %22EPSG:3857%22);%0A            assertNotNull(intersectsFilter);%0A%0A
         %7D);%0A    
@@ -4548,15 +4548,260 @@
 ;%0A    %7D%0A
+%0A
     
+public void testWithin() %7B        %0A        injectUrlAndTest(() -%3E %7B%0A            %0A            Within within = new Within(%22geometryName%22, new Circle(Coordinate.create(5, 5), 5), %22EPSG:3857%22);%0A            assertNotNull(within);%0A%0A        %7D);%0A    %7D%0A
 %0A%7D%0A

Add tests for spatial filters