package org.oskari.service.wfs.client;

import static org.junit.Assert.assertEquals;

import org.geotools.factory.CommonFactoryFinder;
import org.junit.Test;
import org.opengis.filter.Filter;
import org.opengis.filter.FilterFactory;

public class OskariWFS110ClientTest {

    @Test
    public void testGetFilter() {
        FilterFactory ff = CommonFactoryFinder.getFilterFactory();
        Filter f = ff.equals(ff.property("bar"), ff.literal("foo"));
        String actual = OskariWFS110Client.getFilter(f);
        String expected = "<ogc:Filter xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:ogc=\"http://www.opengis.net/ogc\">"
                + "<ogc:PropertyIsEqualTo matchCase=\"true\">"
                + "<ogc:PropertyName>bar</ogc:PropertyName>"
                + "<ogc:Literal>foo</ogc:Literal>"
                + "</ogc:PropertyIsEqualTo>"
                + "</ogc:Filter>";
        assertEquals(expected, actual);
    }

}

@@ -124,24 +124,61 @@
 toryFinder;%0A
+import org.geotools.referencing.CRS;%0A
 import org.j
@@ -188,16 +188,16 @@
 t.Test;%0A
-
 import o
@@ -264,16 +264,42 @@
 ctory;%0A%0A
+import java.util.Arrays;%0A%0A
 public c
@@ -955,16 +955,16 @@
 ualTo%3E%22%0A
-
         
@@ -1037,10 +1037,1176 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testGetFilterWitbBBox() throws Exception %7B%0A        FilterFactory ff = CommonFactoryFinder.getFilterFactory();%0A        Filter f = ff.equals(ff.property(%22bar%22), ff.literal(%22foo%22));%0A%0A        Filter bboxFilter = ff.bbox(%22geometry%22,%0A                382056, 6670472,%0A                388896, 6674196,%0A                CRS.toSRS(CRS.decode(%22EPSG:3067%22)));%0A%0A        String actual = OskariWFS110Client.getFilter(ff.and(Arrays.asList(f, bboxFilter)));%0A        String expected = %22%3Cogc:Filter xmlns:xs=%5C%22http://www.w3.org/2001/XMLSchema%5C%22 xmlns:gml=%5C%22http://www.opengis.net/gml%5C%22 xmlns:ogc=%5C%22http://www.opengis.net/ogc%5C%22%3E%22 +%0A                %22%3Cogc:And%3E%3Cogc:PropertyIsEqualTo matchCase=%5C%22true%5C%22%3E%3Cogc:PropertyName%3Ebar%3C/ogc:PropertyName%3E%3Cogc:Literal%3Efoo%3C/ogc:Literal%3E%3C/ogc:PropertyIsEqualTo%3E%22 +%0A                %22%3Cogc:BBOX%3E%3Cogc:PropertyName%3Egeometry%3C/ogc:PropertyName%3E%3Cgml:Envelope srsDimension=%5C%222%5C%22 srsName=%5C%22urn:x-ogc:def:crs:EPSG:3067%5C%22%3E%22 +%0A                %22%3Cgml:lowerCorner%3E382056 6670472%3C/gml:lowerCorner%3E%3Cgml:upperCorner%3E388896 6674196%3C/gml:upperCorner%3E%3C/gml:Envelope%3E%3C/ogc:BBOX%3E%3C/ogc:And%3E%3C/ogc:Filter%3E%22;%0A        assertEquals(expected, actual);%0A    %7D%0A%0A
 %7D%0A

Add test for WFS 1.1.0 filter