Search in sources :

Example 16 with Encoder

use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.

the class InsertObservationRequestEncoderTest method shouldThrowExceptionIfServiceIsMissing.

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

Example 17 with Encoder

use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.

the class InsertResultRequestEncoderTest method shouldThrowExceptionIfTemplateIdIsMissing.

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

Example 18 with Encoder

use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.

the class InsertResultRequestEncoderTest method shouldThrowExceptionIfVersionIsMissing.

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

Example 19 with Encoder

use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.

the class InsertResultTemplateRequestEncoderTest method shouldThrowExceptionWhenObservationTemplateIsMissing.

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

Example 20 with Encoder

use of org.n52.svalbard.encode.Encoder 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));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) XmlOptions(org.apache.xmlbeans.XmlOptions) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) CodeType(org.n52.shetland.ogc.gml.CodeType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)28 XmlObject (org.apache.xmlbeans.XmlObject)19 EncodingException (org.n52.svalbard.encode.exception.EncodingException)17 XmlOptions (org.apache.xmlbeans.XmlOptions)7 InsertResultTemplateRequest (org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest)7 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)7 Before (org.junit.Before)6 OmObservation (org.n52.shetland.ogc.om.OmObservation)5 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)5 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)5 OwsOperationKey (org.n52.shetland.ogc.ows.service.OwsOperationKey)5 InsertObservationRequest (org.n52.shetland.ogc.sos.request.InsertObservationRequest)5 NoEncoderForKeyException (org.n52.svalbard.encode.exception.NoEncoderForKeyException)5 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)4 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)4 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)4 InsertResultRequest (org.n52.shetland.ogc.sos.request.InsertResultRequest)4 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)4 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)4 CodeType (org.n52.shetland.ogc.gml.CodeType)3