Search in sources :

Example 11 with InsertObservationRequest

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

the class InsertObservationRequestEncoderTest method shouldThrowExceptionIfVersionIsMissing.

@Test
public void shouldThrowExceptionIfVersionIsMissing() throws EncodingException {
    thrown.expect(UnsupportedEncoderInputException.class);
    thrown.expectMessage(Is.is("Encoder " + InsertObservationRequestEncoder.class.getSimpleName() + " can not encode 'missing version'"));
    encoder.create(new InsertObservationRequest("SOS", ""));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) Test(org.junit.Test)

Example 12 with InsertObservationRequest

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

the class InsertObservationRequestEncoderTest method shouldEncodeInsertObservationRequest.

@Test
public void shouldEncodeInsertObservationRequest() throws EncodingException, InvalidSridException, ParseException, DecodingException {
    InsertObservationRequest request = createInsertObservationRequest();
    XmlObject encodedRequest = encoder.create(request);
    XmlHelper.validateDocument(encodedRequest);
    Assert.assertThat(encodedRequest, Matchers.notNullValue());
    Assert.assertThat(encodedRequest, Matchers.instanceOf(InsertObservationDocument.class));
    InsertObservationType insertObservation = ((InsertObservationDocument) encodedRequest).getInsertObservation();
    Assert.assertThat(insertObservation.getOfferingArray(), Matchers.notNullValue());
    Assert.assertThat(insertObservation.getOfferingArray().length, Is.is(1));
    Assert.assertThat(insertObservation.getOfferingArray(0), Is.is(OFFERING_ID));
    Assert.assertThat(insertObservation.getObservationArray(), Matchers.notNullValue());
    Assert.assertThat(insertObservation.getObservationArray().length, Is.is(1));
// no check for observation values, because that MUST be part of OmEncoderv20Test
}
Also used : InsertObservationDocument(net.opengis.sos.x20.InsertObservationDocument) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) XmlObject(org.apache.xmlbeans.XmlObject) InsertObservationType(net.opengis.sos.x20.InsertObservationType) Test(org.junit.Test)

Example 13 with InsertObservationRequest

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

the class InsertObservationRequestEncoderTest method shouldThrowExceptionIfVersionIsNot200Missing.

@Test
public void shouldThrowExceptionIfVersionIsNot200Missing() throws EncodingException {
    thrown.expect(UnsupportedEncoderInputException.class);
    thrown.expectMessage(Is.is("Encoder " + InsertObservationRequestEncoder.class.getSimpleName() + " can not encode 'SOS 1.0.0 insert observation request'"));
    encoder.create(new InsertObservationRequest("SOS", "1.0.0"));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) Test(org.junit.Test)

Example 14 with InsertObservationRequest

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

the class InsertObservationRequestEncoderTest method createInsertObservationRequest.

private InsertObservationRequest createInsertObservationRequest() throws InvalidSridException, ParseException {
    SamplingFeature samplingFeature = new SamplingFeature(new CodeWithAuthority("test-feature-uri"));
    samplingFeature.setName(new CodeType("test-feature-name"));
    samplingFeature.setSampledFeatures(Arrays.asList(new SamplingFeature(new CodeWithAuthority("test-parent-feature-uri"))));
    samplingFeature.setGeometry(JTSHelper.createGeometryFromWKT("POINT(52.0 42.0)", 4326));
    PhysicalSystem procedure = new PhysicalSystem();
    procedure.setIdentifier("test-procedure");
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setGmlId("o1");
    observationConstellation.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    observationConstellation.setObservableProperty(new OmObservableProperty("test-property"));
    observationConstellation.setFeatureOfInterest(samplingFeature);
    observationConstellation.setProcedure(procedure);
    TimeInstant time = new TimeInstant(new Date(0));
    QuantityValue quantity = new QuantityValue(23.0, "test-uom");
    ObservationValue<?> value = new SingleObservationValue<>(time, quantity);
    OmObservation omObservation = new OmObservation();
    omObservation.setObservationConstellation(observationConstellation);
    omObservation.setResultTime(time);
    omObservation.setValue(value);
    InsertObservationRequest request = new InsertObservationRequest("SOS", "2.0.0");
    request.setOfferings(Arrays.asList(OFFERING_ID));
    request.addObservation(omObservation);
    return request;
}
Also used : PhysicalSystem(org.n52.shetland.ogc.sensorML.v20.PhysicalSystem) OmObservation(org.n52.shetland.ogc.om.OmObservation) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Date(java.util.Date) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) CodeType(org.n52.shetland.ogc.gml.CodeType) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

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