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"));
}
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());
}
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
}
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"));
}
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));
}
Aggregations