Search in sources :

Example 1 with SweCommonDecoderV20

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

the class SweCommonDecoderV20Test method should_decode_TimeRange.

@Test
public void should_decode_TimeRange() throws DecodingException {
    final TimeRangeDocument xbTimeRangeDoc = TimeRangeDocument.Factory.newInstance();
    TimeRangeType 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 SweCommonDecoderV20().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 : TimeRangeType(net.opengis.swe.x20.TimeRangeType) SweCommonDecoderV20(org.n52.svalbard.decode.SweCommonDecoderV20) TimeRangeDocument(net.opengis.swe.x20.TimeRangeDocument) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

TimeRangeDocument (net.opengis.swe.x20.TimeRangeDocument)1 TimeRangeType (net.opengis.swe.x20.TimeRangeType)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)1 SweCommonDecoderV20 (org.n52.svalbard.decode.SweCommonDecoderV20)1