Search in sources :

Example 36 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class FesDecoderV20Test method should_parse_PropertyIsEqualTo_Filter.

/**
 * Test PropertyIsEqualTo filter decoding
 *
 * @throws OwsExceptionReport
 */
@Test
public void should_parse_PropertyIsEqualTo_Filter() throws DecodingException {
    PropertyIsEqualToDocument propertyIsEqualToDoc = PropertyIsEqualToDocument.Factory.newInstance();
    BinaryComparisonOpType propertyIsEqualToType = propertyIsEqualToDoc.addNewPropertyIsEqualTo();
    // valueReference
    XmlString valueReference = (XmlString) propertyIsEqualToType.addNewExpression().substitute(FilterConstants.QN_VALUE_REFERENCE, XmlString.type);
    valueReference.setStringValue(TEST_VALUE_REFERENCE);
    // literal
    LiteralType literalType = (LiteralType) propertyIsEqualToType.addNewExpression().substitute(FilterConstants.QN_LITERAL, LiteralType.type);
    XmlString newInstance = XmlString.Factory.newInstance();
    newInstance.setStringValue(TEST_LITERAL);
    literalType.set(newInstance);
    // create document
    FilterDocument filterDoc = FilterDocument.Factory.newInstance();
    FilterType filterType = filterDoc.addNewFilter();
    filterType.setComparisonOps(propertyIsEqualToType);
    filterType.getComparisonOps().substitute(FilterConstants.QN_PROPERTY_IS_EQUAL_TO, BinaryComparisonOpType.type);
    ComparisonFilter comparisonFilter = (ComparisonFilter) decoder.decode(filterDoc);
    // test
    assertThat(comparisonFilter.getOperator(), is(FilterConstants.ComparisonOperator.PropertyIsEqualTo));
    assertThat(comparisonFilter.getValueReference(), is(TEST_VALUE_REFERENCE));
    assertThat(comparisonFilter.getValue(), is(TEST_LITERAL));
}
Also used : PropertyIsEqualToDocument(net.opengis.fes.x20.PropertyIsEqualToDocument) FilterType(net.opengis.fes.x20.FilterType) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) XmlString(org.apache.xmlbeans.XmlString) LiteralType(net.opengis.fes.x20.LiteralType) FilterDocument(net.opengis.fes.x20.FilterDocument) BinaryComparisonOpType(net.opengis.fes.x20.BinaryComparisonOpType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 SpatialFilter (org.n52.shetland.ogc.filter.SpatialFilter)10 XmlObject (org.apache.xmlbeans.XmlObject)9 ComparisonFilter (org.n52.shetland.ogc.filter.ComparisonFilter)9 XmlException (org.apache.xmlbeans.XmlException)6 DecodingException (org.n52.svalbard.decode.exception.DecodingException)6 URI (java.net.URI)3 Objects (java.util.Objects)3 Set (java.util.Set)3 BinaryTemporalOpType (net.opengis.fes.x20.BinaryTemporalOpType)3 XmlCursor (org.apache.xmlbeans.XmlCursor)3 LocalizedString (org.n52.janmayen.i18n.LocalizedString)3 MultilingualString (org.n52.janmayen.i18n.MultilingualString)3 TimeOperator (org.n52.shetland.ogc.filter.FilterConstants.TimeOperator)3 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)3 OwsDomain (org.n52.shetland.ogc.ows.OwsDomain)3 OwsLanguageString (org.n52.shetland.ogc.ows.OwsLanguageString)3 OwsMetadata (org.n52.shetland.ogc.ows.OwsMetadata)3 Strings (com.google.common.base.Strings)2 Arrays (java.util.Arrays)2