Search in sources :

Example 96 with EncodingException

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

the class InsertObservationRequestEncoderTest method shouldThrowExceptionIfOfferingsAreMissing.

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

Example 97 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException 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 98 with EncodingException

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

the class InsertObservationRequestEncoderTest method shouldEncodeSwesExtensions.

@Test
public void shouldEncodeSwesExtensions() throws InvalidSridException, ParseException, EncodingException, DecodingException {
    String definition = Sos2Constants.Extensions.SplitDataArrayIntoObservations.name();
    boolean value = true;
    SweBoolean sweBoolean = new SweBoolean();
    sweBoolean.setValue(value);
    sweBoolean.setDefinition(definition);
    SwesExtension<SweBoolean> swesExtension = new SwesExtension<>();
    swesExtension.setValue(sweBoolean);
    InsertObservationRequest request = createInsertObservationRequest();
    request.addExtension(swesExtension);
    XmlObject encodedRequest = encoder.create(request);
    encodedRequest.xmlText();
    XmlHelper.validateDocument(encodedRequest);
    InsertObservationType insertObservation = ((InsertObservationDocument) encodedRequest).getInsertObservation();
    Assert.assertThat(insertObservation.sizeOfExtensionArray(), Is.is(1));
    XmlObject xbExtension = insertObservation.getExtensionArray(0);
    Assert.assertThat(xbExtension, Matchers.instanceOf(BooleanPropertyType.class));
    BooleanType xbBoolean = ((BooleanPropertyType) xbExtension).getBoolean();
    Assert.assertThat(xbBoolean.getDefinition(), Is.is(definition));
    Assert.assertThat(xbBoolean.getValue(), Is.is(value));
// 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) BooleanType(net.opengis.swe.x20.BooleanType) XmlObject(org.apache.xmlbeans.XmlObject) SwesExtension(org.n52.shetland.ogc.swes.SwesExtension) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) InsertObservationType(net.opengis.sos.x20.InsertObservationType) Test(org.junit.Test)

Example 99 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException 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 100 with EncodingException

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

the class InsertResultRequestEncoderTest method shouldEncodeInsertResultRequest.

@Test
public void shouldEncodeInsertResultRequest() throws EncodingException {
    String version = Sos2Constants.SERVICEVERSION;
    String service = SosConstants.SOS;
    String templateIdentifier = "test-template-identifier";
    String resultValues = "test-result-values";
    InsertResultRequest request = new InsertResultRequest(service, version);
    request.setTemplateIdentifier(templateIdentifier);
    request.setResultValues(resultValues);
    XmlObject encodedRequest = encoder.create(request);
    Assert.assertThat(encodedRequest, Matchers.instanceOf(InsertResultDocument.class));
    Assert.assertThat(((InsertResultDocument) encodedRequest).getInsertResult(), Matchers.notNullValue());
    InsertResultType xbRequest = ((InsertResultDocument) encodedRequest).getInsertResult();
    Assert.assertThat(xbRequest.getService(), Is.is(service));
    Assert.assertThat(xbRequest.getVersion(), Is.is(version));
    Assert.assertThat(xbRequest.getTemplate(), Is.is(templateIdentifier));
    Assert.assertThat(xbRequest.getResultValues(), Matchers.instanceOf(XmlString.class));
    Assert.assertThat(((XmlString) xbRequest.getResultValues()).getStringValue(), Is.is(resultValues));
}
Also used : InsertResultRequest(org.n52.shetland.ogc.sos.request.InsertResultRequest) XmlString(org.apache.xmlbeans.XmlString) XmlObject(org.apache.xmlbeans.XmlObject) XmlString(org.apache.xmlbeans.XmlString) InsertResultType(net.opengis.sos.x20.InsertResultType) InsertResultDocument(net.opengis.sos.x20.InsertResultDocument) Test(org.junit.Test)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)124 Test (org.junit.Test)93 EncodingException (org.n52.svalbard.encode.exception.EncodingException)60 SweField (org.n52.shetland.ogc.swe.SweField)29 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)29 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)22 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)21 XmlException (org.apache.xmlbeans.XmlException)20 DateTime (org.joda.time.DateTime)19 OmObservation (org.n52.shetland.ogc.om.OmObservation)19 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)17 Time (org.n52.shetland.ogc.gml.time.Time)15 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)15 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)13 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)13 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)12 SystemType (net.opengis.sensorML.x101.SystemType)11 DataRecordType (net.opengis.swe.x101.DataRecordType)11