Search in sources :

Example 1 with InsertObservationRequest

use of org.n52.shetland.ogc.sos.request.InsertObservationRequest 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 2 with InsertObservationRequest

use of org.n52.shetland.ogc.sos.request.InsertObservationRequest 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 3 with InsertObservationRequest

use of org.n52.shetland.ogc.sos.request.InsertObservationRequest 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 4 with InsertObservationRequest

use of org.n52.shetland.ogc.sos.request.InsertObservationRequest 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 5 with InsertObservationRequest

use of org.n52.shetland.ogc.sos.request.InsertObservationRequest in project arctic-sea by 52North.

the class InsertObservationRequestDecoder method decodeRequest.

@Override
public InsertObservationRequest decodeRequest(JsonNode node) throws DecodingException {
    InsertObservationRequest r = new InsertObservationRequest();
    r.setObservation(decodeJsonToObjectList(node.path(JSONConstants.OBSERVATION), OmObservation.class));
    r.setOfferings(parseStringOrStringList(node.path(JSONConstants.OFFERING)));
    return r;
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) OmObservation(org.n52.shetland.ogc.om.OmObservation)

Aggregations

InsertObservationRequest (org.n52.shetland.ogc.sos.request.InsertObservationRequest)14 Test (org.junit.Test)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 InsertObservationType (net.opengis.sos.x20.InsertObservationType)3 XmlObject (org.apache.xmlbeans.XmlObject)3 OmObservation (org.n52.shetland.ogc.om.OmObservation)3 InsertObservationDocument (net.opengis.sos.x20.InsertObservationDocument)2 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Observation (net.opengis.sos.x20.InsertObservationType.Observation)1 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)1 BooleanType (net.opengis.swe.x20.BooleanType)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlString (org.apache.xmlbeans.XmlString)1 CompositeException (org.n52.janmayen.exception.CompositeException)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 Time (org.n52.shetland.ogc.gml.time.Time)1