Search in sources :

Example 6 with SweCommonDecoderV101

use of org.n52.svalbard.decode.SweCommonDecoderV101 in project arctic-sea by 52North.

the class SweCommonDecoderV101Test method should_decode_Count_with_Quality_Text.

@Test
public void should_decode_Count_with_Quality_Text() throws DecodingException {
    final CountDocument xbCount = CountDocument.Factory.newInstance();
    final String textValue = "quality-text";
    xbCount.addNewCount().addNewQuality().addNewText().setValue(textValue);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbCount);
    assertThat(decodedObject, is(instanceOf(SweCount.class)));
    final SweCount sweCount = (SweCount) decodedObject;
    assertThat(sweCount.isSetQuality(), is(true));
    assertThat(sweCount.getQuality().size(), is(1));
    assertThat(sweCount.getQuality().iterator().next(), is(instanceOf(SweText.class)));
    assertThat(((SweText) sweCount.getQuality().iterator().next()).getValue(), is(textValue));
}
Also used : CountDocument(net.opengis.swe.x101.CountDocument) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Test(org.junit.Test)

Example 7 with SweCommonDecoderV101

use of org.n52.svalbard.decode.SweCommonDecoderV101 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()));
}
Also used : SensorMLDecoderV101(org.n52.svalbard.decode.SensorMLDecoderV101) SweCommonDecoderV101(org.n52.svalbard.decode.SweCommonDecoderV101) XmlOptions(org.apache.xmlbeans.XmlOptions) InsertSensorRequestDecoder(org.n52.svalbard.decode.json.InsertSensorRequestDecoder) JsonNode(com.fasterxml.jackson.databind.JsonNode) DecoderRepository(org.n52.svalbard.decode.DecoderRepository) GmlDecoderv311(org.n52.svalbard.decode.GmlDecoderv311) Before(org.junit.Before)

Example 8 with SweCommonDecoderV101

use of org.n52.svalbard.decode.SweCommonDecoderV101 in project arctic-sea by 52North.

the class SweCommonDecoderV101Test method should_decode_QuantityRange.

@Test
public void should_decode_QuantityRange() throws DecodingException {
    final QuantityRangeDocument xbQuantityRange = QuantityRangeDocument.Factory.newInstance();
    final ArrayList<BigDecimal> values = Lists.newArrayList(BigDecimal.valueOf(1.0), BigDecimal.valueOf(2.0));
    final QuantityRange xbQuantityRangeType = xbQuantityRange.addNewQuantityRange();
    xbQuantityRangeType.setValue(values);
    final String definition = "definition";
    xbQuantityRangeType.setDefinition(definition);
    final String axisId = "axis-id";
    xbQuantityRangeType.setAxisID(axisId);
    final String description = "description";
    xbQuantityRangeType.addNewDescription().setStringValue(description);
    final UomPropertyType xbUom = xbQuantityRangeType.addNewUom();
    final String uomCode = "uom-code";
    xbUom.setCode(uomCode);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbQuantityRange);
    assertThat(decodedObject, is(instanceOf(SweQuantityRange.class)));
    final SweQuantityRange sweQuantityRange = (SweQuantityRange) decodedObject;
    assertThat(sweQuantityRange.isSetDefinition(), is(true));
    assertThat(sweQuantityRange.getDefinition(), is(definition));
    assertThat(sweQuantityRange.isSetUom(), is(true));
    assertThat(sweQuantityRange.getUom(), is(uomCode));
    assertThat(sweQuantityRange.isSetAxisID(), is(true));
    assertThat(sweQuantityRange.getAxisID(), is(axisId));
    assertThat(sweQuantityRange.isSetDescription(), is(true));
    assertThat(sweQuantityRange.getDescription(), is(description));
    assertThat(sweQuantityRange.isSetValue(), is(true));
    assertThat(sweQuantityRange.getValue().getRangeStart(), is(values.get(0)));
    assertThat(sweQuantityRange.getValue().getRangeEnd(), is(values.get(1)));
}
Also used : UomPropertyType(net.opengis.swe.x101.UomPropertyType) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) QuantityRangeDocument(net.opengis.swe.x101.QuantityRangeDocument) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) QuantityRange(net.opengis.swe.x101.QuantityRangeDocument.QuantityRange) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 BigDecimal (java.math.BigDecimal)3 XmlOptions (org.apache.xmlbeans.XmlOptions)2 Before (org.junit.Before)2 DecoderRepository (org.n52.svalbard.decode.DecoderRepository)2 GmlDecoderv311 (org.n52.svalbard.decode.GmlDecoderv311)2 SensorMLDecoderV101 (org.n52.svalbard.decode.SensorMLDecoderV101)2 SweCommonDecoderV101 (org.n52.svalbard.decode.SweCommonDecoderV101)2 InsertSensorRequestDecoder (org.n52.svalbard.decode.json.InsertSensorRequestDecoder)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 BooleanDocument (net.opengis.swe.x101.BooleanDocument)1 CategoryDocument (net.opengis.swe.x101.CategoryDocument)1 CountDocument (net.opengis.swe.x101.CountDocument)1 QuantityDocument (net.opengis.swe.x101.QuantityDocument)1 QuantityRangeDocument (net.opengis.swe.x101.QuantityRangeDocument)1 QuantityRange (net.opengis.swe.x101.QuantityRangeDocument.QuantityRange)1 TimeRangeDocument (net.opengis.swe.x101.TimeRangeDocument)1 TimeRange (net.opengis.swe.x101.TimeRangeDocument.TimeRange)1 UomPropertyType (net.opengis.swe.x101.UomPropertyType)1 DateTime (org.joda.time.DateTime)1