use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldBoolean.
@Test
public void should_encode_Datarecord_with_fieldBoolean() throws EncodingException {
final String field1Name = "test-name";
final boolean field1Value = true;
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweBoolean().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.isSetBoolean(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getBoolean().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_fieldBoolean.
@Test
public void should_encode_simpleDatarecord_with_fieldBoolean() throws EncodingException {
final String field1Name = "field-1";
final Boolean field1Value = Boolean.TRUE;
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name, new SweBoolean().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.isSetBoolean(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getBoolean().getValue(), is(field1Value));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCount.
@Test
public void should_encode_Datarecord_with_fieldCount() throws EncodingException {
final String field1Name = "test-name";
final int field1Value = 52;
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCount().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.isSetCount(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getCount().getValue(), is(BigInteger.valueOf(field1Value)));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldCategory.
@Test
public void should_encode_simpleDatarecord_with_fieldCategory() throws EncodingException {
final String name = "field-1";
final String value = "field-1-value";
final String codeSpace = "field-1-codespace";
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweCategory().setValue(value).setCodeSpace(codeSpace))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetCategory(), is(TRUE));
assertThat(field1.getName(), is(name));
assertThat(field1.getCategory().getValue(), is(value));
assertThat(field1.getCategory().isSetCodeSpace(), is(TRUE));
assertThat(field1.getCategory().getCodeSpace().isSetHref(), is(TRUE));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldTime.
@Test
public void should_encode_simpleDatarecord_with_fieldTime() throws EncodingException {
final String name = "field-1";
final DateTime value = new DateTime(DateTimeZone.UTC);
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweTime().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.isSetTime(), is(TRUE));
assertThat(DateTimeHelper.parseIsoString2DateTime(field1.getTime().getValue().toString()).toString(), is(value.toString()));
}
Aggregations