use of org.n52.shetland.ogc.om.features.samplingFeatures.InvalidSridException 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
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.InvalidSridException 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;
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.InvalidSridException in project arctic-sea by 52North.
the class OmEncoderv20Test method shouldEncodeFeatureInObservationTemplate.
@Test
public void shouldEncodeFeatureInObservationTemplate() throws EncodingException, InvalidSridException, ParseException, XmlException, IOException {
//
SamplingFeature featureOfInterest = new SamplingFeature(new CodeWithAuthority(featureIdentifier));
featureOfInterest.setIdentifier(featureIdentifier);
featureOfInterest.setName(new CodeType(featureName));
featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT (30 10)", 4326));
//
SensorML procedure = new SensorML();
procedure.setIdentifier(procedureIdentifier);
//
OmObservationConstellation observationTemplate = new OmObservationConstellation();
observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
observationTemplate.setProcedure(procedure);
observationTemplate.setFeatureOfInterest(featureOfInterest);
//
OMObservationType omObservation = (OMObservationType) omEncoderv20.encode(observationTemplate);
//
Assert.assertThat(omObservation.getType().getHref(), Is.is(OmConstants.OBS_TYPE_MEASUREMENT));
Assert.assertThat(omObservation.getPhenomenonTime().isNil(), Is.is(false));
Assert.assertThat(omObservation.getPhenomenonTime().isSetNilReason(), Is.is(true));
Assert.assertThat(omObservation.getPhenomenonTime().getNilReason(), Is.is("template"));
Assert.assertThat(omObservation.getResultTime().isNil(), Is.is(false));
Assert.assertThat(omObservation.getResultTime().isSetNilReason(), Is.is(true));
Assert.assertThat(omObservation.getResultTime().getNilReason(), Is.is("template"));
Assert.assertThat(omObservation.getProcedure().isNil(), Is.is(false));
Assert.assertThat(omObservation.getProcedure().getHref(), Is.is(procedureIdentifier));
Assert.assertThat(omObservation.getObservedProperty().isNil(), Is.is(false));
Assert.assertThat(omObservation.getObservedProperty().getHref(), Is.is(observedProperty));
Assert.assertThat(omObservation.getFeatureOfInterest(), Matchers.notNullValue());
XmlObject xmlObject = XmlObject.Factory.parse(omObservation.getFeatureOfInterest().newInputStream());
Assert.assertThat(xmlObject, Matchers.instanceOf(SFSamplingFeatureDocument.class));
SFSamplingFeatureType feature = ((SFSamplingFeatureDocument) xmlObject).getSFSamplingFeature();
Assert.assertThat(feature.getIdentifier().getStringValue(), Is.is(featureIdentifier));
Assert.assertThat(feature.getNameArray().length, Is.is(1));
Assert.assertThat(feature.getNameArray(0).getStringValue(), Is.is(featureName));
}
Aggregations