Search in sources :

Example 66 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class SosDecoderv20Test method should_decode_text_swesExtensions.

@Test
public void should_decode_text_swesExtensions() throws XmlException, OwsExceptionReport, DecodingException {
    final GetObservationDocument doc = GetObservationDocument.Factory.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sos:GetObservation service=\"SOS\" version=\"2.0.0\"\n" + "    xmlns:sos=\"http://www.opengis.net/sos/2.0\"\n" + "    xmlns:swe=\"http://www.opengis.net/swe/2.0\"\n" + "    xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" + "    xmlns:swes=\"http://www.opengis.net/swes/2.0\"\n" + "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/sos/2.0 http://schemas.opengis.net/sos/2.0/sos.xsd\">\n" + "    <swes:extension>\n" + "        <swe:Text definition=\"my-text-extension\">\n" + "            <swe:value>true</swe:value>\n" + "        </swe:Text>\n" + "    </swes:extension>\n" + "</sos:GetObservation>");
    final OwsServiceCommunicationObject decodedObject = decoder.decode(doc);
    assertThat(decodedObject, instanceOf(GetObservationRequest.class));
    final GetObservationRequest request = (GetObservationRequest) decodedObject;
    assertThat(request.getExtension("my-text-extension").map(e -> e.getValue()).map(v -> (SweText) v).map(v -> v.getValue()).orElse(null), is("true"));
}
Also used : OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) Arrays(java.util.Arrays) DecodingException(org.n52.svalbard.decode.exception.DecodingException) IsInstanceOf.instanceOf(org.hamcrest.core.IsInstanceOf.instanceOf) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) Test(org.junit.Test) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) GetObservationDocument(net.opengis.sos.x20.GetObservationDocument) Assert.assertThat(org.junit.Assert.assertThat) XmlException(org.apache.xmlbeans.XmlException) XmlOptions(org.apache.xmlbeans.XmlOptions) After(org.junit.After) Matchers.is(org.hamcrest.Matchers.is) TRUE(java.lang.Boolean.TRUE) Producer(org.n52.janmayen.Producer) Before(org.junit.Before) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) GetObservationDocument(net.opengis.sos.x20.GetObservationDocument) Test(org.junit.Test)

Example 67 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport 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

OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)27 EncodingException (org.n52.svalbard.encode.exception.EncodingException)14 Test (org.junit.Test)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)9 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)8 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)8 XmlObject (org.apache.xmlbeans.XmlObject)7 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)7 IOException (java.io.IOException)6 DateTime (org.joda.time.DateTime)6 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)6 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)5 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)5 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)5 LinkedList (java.util.LinkedList)4 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)4 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)4 CodedException (org.n52.shetland.ogc.ows.exception.CodedException)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3