use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldQuantity.
@Test
public void should_encode_Datarecord_with_fieldQuantity() throws EncodingException {
final String field1Name = "test-name";
final double field1Value = 52.0;
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweQuantity().setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(xbDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetQuantity(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getQuantity().getValue(), is(field1Value));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldText.
@Test
public void should_encode_simpleDatarecord_with_fieldText() throws EncodingException {
final String field1Name = "field-1";
final String field1Value = "field-1-value";
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name, new SweText().setValue(field1Value))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetText(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getText().getValue(), is(field1Value));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldCount.
@Test
public void should_encode_simpleDatarecord_with_fieldCount() throws EncodingException {
final String name = "field-1";
final int value = 42;
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweCount().setValue(value))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
assertThat(field1.getName(), is(name));
assertThat(field1.isSetCount(), is(TRUE));
assertThat(field1.getCount().getValue().intValue(), is(value));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCategory.
@Test
public void should_encode_Datarecord_with_fieldCategory() throws EncodingException {
final String field1Name = "test-name";
final String field1Value = "test-value";
final String codeSpace = "test-codespace";
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCategory().setCodeSpace(codeSpace).setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(xbDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetCategory(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getCategory().getValue(), is(field1Value));
assertThat(field1.getCategory().getCodeSpace().getHref(), is(codeSpace));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldTimeRange.
@Test
public void should_encode_Datarecord_with_fieldTimeRange() throws EncodingException {
final String field1Name = "test-name";
final RangeValue<DateTime> field1Value = new RangeValue<DateTime>();
final long now = System.currentTimeMillis();
final DateTime rangeStart = new DateTime(now - 1000);
final DateTime rangeEnd = new DateTime(now + 1000);
field1Value.setRangeStart(rangeStart);
field1Value.setRangeEnd(rangeEnd);
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweTimeRange().setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
assertThat(xbDataRecord.getFieldArray().length, is(1));
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(field1.isSetTimeRange(), is(TRUE));
final DateTime xbTimeRangeStart = new DateTime(((XmlCalendar) field1.getTimeRange().getValue().get(0)).getTimeInMillis());
final DateTime xbTimeRangeEnd = new DateTime(((XmlCalendar) field1.getTimeRange().getValue().get(1)).getTimeInMillis());
assertThat(field1.getName(), is(field1Name));
assertThat(xbTimeRangeStart, is(field1Value.getRangeStart()));
assertThat(xbTimeRangeEnd, is(field1Value.getRangeEnd()));
}
Aggregations