use of org.n52.shetland.ogc.om.OmObservationConstellation in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method setup.
@Before
public void setup() throws InvalidSridException, ParseException {
SensorML procedure = new SensorML();
procedure.setIdentifier(procedureIdentifier);
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));
observationTemplate = new OmObservationConstellation();
observationTemplate.addOffering(offering);
observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
observationTemplate.setProcedure(procedure);
observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
observationTemplate.setFeatureOfInterest(featureOfInterest);
SweTextEncoding textEncoding = new SweTextEncoding();
textEncoding.setBlockSeparator(blockSeparator);
textEncoding.setTokenSeparator(tokenSeparator);
SweDataRecord resultStructure = new SweDataRecord();
SweTime sweTime = new SweTime();
sweTime.setDefinition(field1Definition);
sweTime.setUom(field1Uom);
resultStructure.addField(new SweField(field1Name, sweTime));
request = new InsertResultTemplateRequest(SosConstants.SOS, Sos2Constants.SERVICEVERSION, Sos2Constants.Operations.InsertResultTemplate.name());
request.setResultEncoding(new SosResultEncoding(textEncoding));
request.setResultStructure(new SosResultStructure(resultStructure));
request.setIdentifier(templateIdentifier);
request.setObservationTemplate(observationTemplate);
Supplier<XmlOptions> xmlOptions = () -> new XmlOptions();
encoder = new InsertResultTemplateRequestEncoder();
encoder.setXmlOptions(xmlOptions);
OmEncoderv20 omEncoder = new OmEncoderv20();
omEncoder.setXmlOptions(xmlOptions);
SamplingEncoderv20 samsEncoder = new SamplingEncoderv20();
samsEncoder.setXmlOptions(xmlOptions);
GmlEncoderv321 gml32Encoder = new GmlEncoderv321();
gml32Encoder.setXmlOptions(xmlOptions);
SweCommonEncoderv20 sweEncoderv20 = new SweCommonEncoderv20();
sweEncoderv20.setXmlOptions(xmlOptions);
EncoderRepository encoderRepository = new EncoderRepository();
encoderRepository.setEncoders(Arrays.asList(encoder, omEncoder, samsEncoder, gml32Encoder, sweEncoderv20));
encoderRepository.init();
encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
use of org.n52.shetland.ogc.om.OmObservationConstellation in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method shouldThrowExceptionWhenResultStructureIsMissing.
@Test
public void shouldThrowExceptionWhenResultStructureIsMissing() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + InsertResultTemplateRequestEncoder.class.getSimpleName() + " can not encode 'missing resultStructure'"));
request = new InsertResultTemplateRequest("service", "version");
request.setObservationTemplate(new OmObservationConstellation());
OmObservationConstellation observationTemplate = new OmObservationConstellation();
observationTemplate.addOffering(offering);
request.setObservationTemplate(observationTemplate);
encoder.create(request);
}
use of org.n52.shetland.ogc.om.OmObservationConstellation in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method shouldThrowExceptionWhenResultEncodingIsMissing.
@Test
public void shouldThrowExceptionWhenResultEncodingIsMissing() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + InsertResultTemplateRequestEncoder.class.getSimpleName() + " can not encode 'missing resultEncoding'"));
request = new InsertResultTemplateRequest("service", "version");
request.setObservationTemplate(new OmObservationConstellation());
request.setResultStructure(new SosResultStructure(new SweDataRecord()));
OmObservationConstellation observationTemplate = new OmObservationConstellation();
observationTemplate.addOffering(offering);
request.setObservationTemplate(observationTemplate);
encoder.create(request);
}
use of org.n52.shetland.ogc.om.OmObservationConstellation in project arctic-sea by 52North.
the class OmEncoderv20Test method shouldEncodeObservationTypeInObservationTemplate.
@Test
public void shouldEncodeObservationTypeInObservationTemplate() throws EncodingException {
OmObservationConstellation observationTemplate = new OmObservationConstellation();
String observationType = OmConstants.OBS_TYPE_MEASUREMENT;
observationTemplate.setObservationType(observationType);
observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
OMObservationType encodedObservationTemplate = (OMObservationType) omEncoderv20.encode(observationTemplate);
Assert.assertThat(encodedObservationTemplate.getType().getHref(), Is.is(observationType));
}
use of org.n52.shetland.ogc.om.OmObservationConstellation in project arctic-sea by 52North.
the class OmEncoderv20Test method shouldEncodeFeatureWithNilWhenMissingInObservationTemplate.
@Test
public void shouldEncodeFeatureWithNilWhenMissingInObservationTemplate() throws EncodingException {
OmObservationConstellation observationTemplate = new OmObservationConstellation();
String observationType = OmConstants.OBS_TYPE_MEASUREMENT;
observationTemplate.setObservationType(observationType);
observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
OMObservationType encodedObservationTemplate = (OMObservationType) omEncoderv20.encode(observationTemplate);
Assert.assertThat(encodedObservationTemplate.getFeatureOfInterest().isNil(), Is.is(false));
Assert.assertThat(encodedObservationTemplate.getFeatureOfInterest().isSetNilReason(), Is.is(true));
Assert.assertThat(encodedObservationTemplate.getFeatureOfInterest().getNilReason(), Is.is("template"));
}
Aggregations