Search in sources :

Example 41 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class InsertObservationRequestDecoderTest method multipleObservation.

@Test
public void multipleObservation() throws IOException, DecodingException {
    final JsonNode json = JsonLoader.fromResource("/examples/sos/InsertObservationRequest-multiple-observations.json");
    final InsertObservationRequest req = decoder.decodeJSON(json, true);
    assertThat(req, is(notNullValue()));
    errors.checkThat(req.getService(), is(equalTo("SOS")));
    errors.checkThat(req.getVersion(), is(equalTo("2.0.0")));
    errors.checkThat(req.getOperationName(), is(equalTo("InsertObservation")));
    assertThat(req.getOfferings(), is(notNullValue()));
    errors.checkThat(req.getOfferings(), hasSize(2));
    assertThat(req.getOfferings().get(0), is(equalTo("offering1")));
    assertThat(req.getOfferings().get(1), is(equalTo("offering2")));
    assertThat(req.getObservations(), is(notNullValue()));
    assertThat(req.getObservations(), hasSize(2));
    assertThat(req.getObservations().get(0), is(notNullValue()));
    assertThat(req.getObservations().get(0).getValue().getValue(), is(instanceOf(TextValue.class)));
    assertThat(req.getObservations().get(1), is(notNullValue()));
    assertThat(req.getObservations().get(1).getValue().getValue(), is(instanceOf(TextValue.class)));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 42 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class InsertObservationRequestDecoderTest method multipleOfferings.

@Test
public void multipleOfferings() throws IOException, DecodingException {
    final JsonNode json = JsonLoader.fromResource("/examples/sos/InsertObservationRequest-multiple-offerings.json");
    final InsertObservationRequest req = decoder.decodeJSON(json, true);
    assertThat(req, is(notNullValue()));
    errors.checkThat(req.getService(), is(equalTo("SOS")));
    errors.checkThat(req.getVersion(), is(equalTo("2.0.0")));
    errors.checkThat(req.getOperationName(), is(equalTo("InsertObservation")));
    assertThat(req.getOfferings(), is(notNullValue()));
    errors.checkThat(req.getOfferings(), hasSize(2));
    assertThat(req.getOfferings().get(0), is(equalTo("offering1")));
    assertThat(req.getOfferings().get(1), is(equalTo("offering2")));
    assertThat(req.getObservations(), is(notNullValue()));
    assertThat(req.getObservations(), hasSize(1));
    assertThat(req.getObservations().get(0), is(notNullValue()));
    assertThat(req.getObservations().get(0).getValue().getValue(), is(instanceOf(TextValue.class)));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 43 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class InsertObservationRequestDecoderTest method singleOffering.

@Test
public void singleOffering() throws IOException, DecodingException {
    final JsonNode json = JsonLoader.fromResource("/examples/sos/InsertObservationRequest-single-offering.json");
    final InsertObservationRequest req = decoder.decodeJSON(json, true);
    errors.checkThat(req.getService(), is(equalTo("SOS")));
    errors.checkThat(req.getVersion(), is(equalTo("2.0.0")));
    errors.checkThat(req.getOperationName(), is(equalTo("InsertObservation")));
    assertThat(req.getOfferings(), is(notNullValue()));
    errors.checkThat(req.getOfferings(), hasSize(1));
    assertThat(req.getOfferings().get(0), is(equalTo("offering2")));
    assertThat(req.getObservations(), is(notNullValue()));
    assertThat(req.getObservations(), hasSize(1));
    assertThat(req.getObservations().get(0), is(notNullValue()));
    assertThat(req.getObservations().get(0).getValue().getValue(), is(instanceOf(TextValue.class)));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 44 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class InsertObservationRequestDecoderTest method singleObservation.

@Test
public void singleObservation() throws IOException, DecodingException {
    final JsonNode json = JsonLoader.fromResource("/examples/sos/InsertObservationRequest-single-observation.json");
    final InsertObservationRequest req = decoder.decodeJSON(json, true);
    errors.checkThat(req.getService(), is(equalTo("SOS")));
    errors.checkThat(req.getVersion(), is(equalTo("2.0.0")));
    errors.checkThat(req.getOperationName(), is(equalTo("InsertObservation")));
    assertThat(req.getOfferings(), is(notNullValue()));
    errors.checkThat(req.getOfferings(), hasSize(1));
    assertThat(req.getOfferings().get(0), is(equalTo("offering2")));
    assertThat(req.getObservations(), is(notNullValue()));
    assertThat(req.getObservations(), hasSize(1));
    assertThat(req.getObservations().get(0), is(notNullValue()));
    assertThat(req.getObservations().get(0).getValue().getValue(), is(instanceOf(TextValue.class)));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 45 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class InsertResultTemplateRequestDecoderTest method resultEncoding.

@Test
public void resultEncoding() throws IOException, DecodingException {
    InsertResultTemplateRequest req = load();
    assertThat(req.getResultEncoding(), is(notNullValue()));
    assertThat(req.getResultEncoding().isDecoded(), is(true));
    assertThat(req.getResultEncoding().isEncoded(), is(false));
    assertThat(req.getResultEncoding().get().get(), is(instanceOf(SweTextEncoding.class)));
    SweTextEncoding encoding = (SweTextEncoding) req.getResultEncoding().get().get();
    errors.checkThat(encoding.getTokenSeparator(), is(","));
    errors.checkThat(encoding.getBlockSeparator(), is("#"));
}
Also used : SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)92 DecodingException (org.n52.svalbard.decode.exception.DecodingException)63 XmlObject (org.apache.xmlbeans.XmlObject)52 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 SweField (org.n52.shetland.ogc.swe.SweField)25 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)23 XmlException (org.apache.xmlbeans.XmlException)23 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)22 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)21 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 SystemType (net.opengis.sensorML.x101.SystemType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 Before (org.junit.Before)11 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)11 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)10 DateTime (org.joda.time.DateTime)10 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)10 XmlString (org.apache.xmlbeans.XmlString)9 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)8 Geometry (org.locationtech.jts.geom.Geometry)8