Search in sources :

Example 1 with SweCommonDecoderV101

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

the class BatchRequestDecodingTest method before.

@Before
public void before() throws DecodingException {
    DecoderRepository decoderRepository = new DecoderRepository();
    this.decoder = new BatchRequestDecoder();
    this.decoder.setDecoderRepository(decoderRepository);
    InsertSensorRequestDecoder insertSensorRequestDecoder = new InsertSensorRequestDecoder();
    insertSensorRequestDecoder.setDecoderRepository(decoderRepository);
    InsertObservationRequestDecoder insertObservationRequestDecoder = new InsertObservationRequestDecoder();
    insertObservationRequestDecoder.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();
    ObservationDecoder observationDecoder = new ObservationDecoder();
    observationDecoder.setDecoderRepository(decoderRepository);
    InsertResultTemplateRequestDecoder insertResultTemplateRequestDecoder = new InsertResultTemplateRequestDecoder();
    insertResultTemplateRequestDecoder.setDecoderRepository(decoderRepository);
    InsertResultRequestDecoder insertResultRequestDecoder = new InsertResultRequestDecoder();
    insertResultRequestDecoder.setDecoderRepository(decoderRepository);
    FieldDecoder fieldDecoder = new FieldDecoder();
    fieldDecoder.setDecoderRepository(decoderRepository);
    decoderRepository.setDecoders(Arrays.asList(decoder, insertSensorRequestDecoder, insertObservationRequestDecoder, insertResultTemplateRequestDecoder, insertResultRequestDecoder, sensorMLDecoder, sweCommonDecoder, observationDecoder, fieldDecoder, gmlDecoderv311));
    decoderRepository.init();
    this.request = decoder.decodeJSON(json, true);
}
Also used : InsertResultTemplateRequestDecoder(org.n52.svalbard.decode.json.InsertResultTemplateRequestDecoder) SensorMLDecoderV101(org.n52.svalbard.decode.SensorMLDecoderV101) BatchRequestDecoder(org.n52.svalbard.decode.json.BatchRequestDecoder) SweCommonDecoderV101(org.n52.svalbard.decode.SweCommonDecoderV101) InsertResultRequestDecoder(org.n52.svalbard.decode.json.InsertResultRequestDecoder) XmlOptions(org.apache.xmlbeans.XmlOptions) ObservationDecoder(org.n52.svalbard.decode.json.ObservationDecoder) InsertSensorRequestDecoder(org.n52.svalbard.decode.json.InsertSensorRequestDecoder) InsertObservationRequestDecoder(org.n52.svalbard.decode.json.InsertObservationRequestDecoder) DecoderRepository(org.n52.svalbard.decode.DecoderRepository) FieldDecoder(org.n52.svalbard.decode.json.FieldDecoder) GmlDecoderv311(org.n52.svalbard.decode.GmlDecoderv311) Before(org.junit.Before)

Example 2 with SweCommonDecoderV101

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

the class SweCommonDecoderV101Test method should_decode_Boolean_with_Quality_Quantity.

@Test
public void should_decode_Boolean_with_Quality_Quantity() throws DecodingException {
    final BooleanDocument xbBoolean = BooleanDocument.Factory.newInstance();
    final BigDecimal quantityValue = BigDecimal.valueOf(42.5);
    xbBoolean.addNewBoolean().addNewQuality().addNewQuantity().setValue(quantityValue.doubleValue());
    final Object decodedObject = new SweCommonDecoderV101().decode(xbBoolean);
    assertThat(decodedObject, is(instanceOf(SweBoolean.class)));
    final SweBoolean sweBoolean = (SweBoolean) decodedObject;
    assertThat(sweBoolean.isSetQuality(), is(true));
    assertThat(sweBoolean.getQuality().size(), is(1));
    assertThat(sweBoolean.getQuality().iterator().next(), is(instanceOf(SweQuantity.class)));
    assertThat(((SweQuantity) sweBoolean.getQuality().iterator().next()).getValue(), is(quantityValue));
}
Also used : BooleanDocument(net.opengis.swe.x101.BooleanDocument) BigDecimal(java.math.BigDecimal) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 3 with SweCommonDecoderV101

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

the class SweCommonDecoderV101Test method should_decode_Quantity_with_Quality_Category.

@Test
public void should_decode_Quantity_with_Quality_Category() throws DecodingException {
    final QuantityDocument xbQuantity = QuantityDocument.Factory.newInstance();
    final String categoryValue = "quality-category";
    xbQuantity.addNewQuantity().addNewQuality().addNewCategory().setValue(categoryValue);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbQuantity);
    assertThat(decodedObject, is(instanceOf(SweQuantity.class)));
    final SweQuantity sweQuantity = (SweQuantity) decodedObject;
    assertThat(sweQuantity.isSetQuality(), is(true));
    assertThat(sweQuantity.getQuality().size(), is(1));
    assertThat(sweQuantity.getQuality().iterator().next(), is(instanceOf(SweCategory.class)));
    assertThat(((SweCategory) sweQuantity.getQuality().iterator().next()).getValue(), is(categoryValue));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) QuantityDocument(net.opengis.swe.x101.QuantityDocument) Test(org.junit.Test)

Example 4 with SweCommonDecoderV101

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

the class SweCommonDecoderV101Test method should_decode_Category_with_Quality_QuantityRange.

@Test
public void should_decode_Category_with_Quality_QuantityRange() throws DecodingException {
    final CategoryDocument xbQuantity = CategoryDocument.Factory.newInstance();
    final BigDecimal rangeStart = BigDecimal.valueOf(1.0);
    final BigDecimal rangeEnd = BigDecimal.valueOf(2.0);
    final ArrayList<BigDecimal> categoryValue = Lists.newArrayList(rangeStart, rangeEnd);
    xbQuantity.addNewCategory().addNewQuality().addNewQuantityRange().setValue(categoryValue);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbQuantity);
    assertThat(decodedObject, is(instanceOf(SweCategory.class)));
    final SweCategory sweCategory = (SweCategory) decodedObject;
    assertThat(sweCategory.isSetQuality(), is(true));
    assertThat(sweCategory.getQuality().size(), is(1));
    assertThat(sweCategory.getQuality().iterator().next(), is(instanceOf(SweQuantityRange.class)));
    assertThat(((SweQuantityRange) sweCategory.getQuality().iterator().next()).getValue(), is(new RangeValue<BigDecimal>(rangeStart, rangeEnd)));
}
Also used : CategoryDocument(net.opengis.swe.x101.CategoryDocument) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) BigDecimal(java.math.BigDecimal) RangeValue(org.n52.shetland.ogc.swe.RangeValue) Test(org.junit.Test)

Example 5 with SweCommonDecoderV101

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

the class SweCommonDecoderV101Test method should_decode_TimeRange.

@Test
public void should_decode_TimeRange() throws DecodingException {
    final TimeRangeDocument xbTimeRangeDoc = TimeRangeDocument.Factory.newInstance();
    TimeRange xbTimeRange = xbTimeRangeDoc.addNewTimeRange();
    final DateTime startDate = new DateTime(1970, 1, 1, 0, 0, DateTimeZone.UTC);
    final DateTime endDate = new DateTime(2013, 12, 31, 23, 59, DateTimeZone.UTC);
    final List<String> values = Lists.newArrayList(startDate.toString(), endDate.toString());
    xbTimeRange.setValue(values);
    final String iso8601Uom = "urn:ogc:def:unit:ISO:8601";
    xbTimeRange.addNewUom().setHref(iso8601Uom);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbTimeRange);
    assertThat(decodedObject, is(instanceOf(SweTimeRange.class)));
    final SweTimeRange sweTimeRange = (SweTimeRange) decodedObject;
    assertThat(sweTimeRange.isSetUom(), is(true));
    assertThat(sweTimeRange.getUom(), is(iso8601Uom));
    assertThat(sweTimeRange.isSetValue(), is(true));
    assertThat(sweTimeRange.getValue().getRangeStart(), is(startDate));
    assertThat(sweTimeRange.getValue().getRangeEnd(), is(endDate));
}
Also used : SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) TimeRange(net.opengis.swe.x101.TimeRangeDocument.TimeRange) TimeRangeDocument(net.opengis.swe.x101.TimeRangeDocument) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) 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