use of org.n52.svalbard.decode.Decoder in project arctic-sea by 52North.
the class InsertSensorRequestDecoderTest method setUp.
@Before
public void setUp() throws DecodingException, IOException {
DecoderRepository decoderRepository = new DecoderRepository();
this.decoder = new InsertSensorRequestDecoder();
this.decoder.setDecoderRepository(decoderRepository);
SensorMLDecoderV101 sensorMLDecoder = new SensorMLDecoderV101();
sensorMLDecoder.setXmlOptions(XmlOptions::new);
sensorMLDecoder.setDecoderRepository(decoderRepository);
SweCommonDecoderV101 sweCommonDecoder = new SweCommonDecoderV101();
sweCommonDecoder.setXmlOptions(XmlOptions::new);
sweCommonDecoder.setDecoderRepository(decoderRepository);
GmlDecoderv311 gmlDecoderv311 = new GmlDecoderv311();
decoderRepository.setDecoders(Arrays.asList(decoder, sensorMLDecoder, sweCommonDecoder, gmlDecoderv311));
decoderRepository.init();
final JsonNode json = JsonLoader.fromResource("/examples/sos/InsertSensorRequest.json");
this.req = decoder.decode(json);
assertThat(req, is(notNullValue()));
}
use of org.n52.svalbard.decode.Decoder in project arctic-sea by 52North.
the class GetResultTemplateResponseEncoder method encodeResultEncoding.
private void encodeResultEncoding(GetResultTemplateResponse t, ObjectNode json) throws EncodingException {
ObjectNode jre = json.putObject(JSONConstants.RESULT_ENCODING);
SweAbstractEncoding encoding = null;
SosResultEncoding re = t.getResultEncoding();
if (re.isDecoded()) {
encoding = t.getResultEncoding().get().get();
} else {
try {
XmlNamespaceDecoderKey key = new XmlNamespaceDecoderKey(SweConstants.NS_SWE_20, SweAbstractEncoding.class);
Decoder<SweAbstractEncoding, XmlObject> decoder = this.decoderRepository.getDecoder(key);
if (decoder == null) {
throw new NoDecoderForKeyException(key);
}
encoding = decoder.decode(XmlObject.Factory.parse(re.getXml().get()));
} catch (XmlException | DecodingException ex) {
throw new EncodingException(ex);
}
}
if (encoding instanceof SweTextEncoding) {
encodeSweTextEncoding(encoding, jre);
} else {
LOG.warn("Unsupported encoding: {}", encoding == null ? null : encoding.getClass());
}
}
use of org.n52.svalbard.decode.Decoder in project arctic-sea by 52North.
the class AbstractCapabilitiesBaseTypeDecoderTest method shouldNotThrowNullPointerExceptionWhenServiceIdentificationIsMissing.
@Test
public void shouldNotThrowNullPointerExceptionWhenServiceIdentificationIsMissing() throws DecodingException {
AbstractCapabilitiesBaseTypeDecoder<CapabilitiesBaseType, OwsCapabilities> decoder = new TestSeam();
CapabilitiesBaseType cbt = CapabilitiesBaseType.Factory.newInstance();
cbt.setVersion("2.0.0");
cbt.setUpdateSequence("nothing-to-see-here");
Assert.assertThat(decoder.parseCapabilitiesBaseType("SOS", cbt).getServiceIdentification().isPresent(), Is.is(false));
}
Aggregations