use of org.geotoolkit.swe.xml.v101.SimpleDataRecordType in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method encodeSimpleDataRecord.
private SimpleDataRecordType encodeSimpleDataRecord(final SystemType xbSystem, final String capName, final int fields) {
assertThat(xbSystem.getCapabilitiesArray().length, is(1));
final Capabilities xbCapabilities = xbSystem.getCapabilitiesArray()[0];
assertThat(xbCapabilities.getName(), is(capName));
assertThat(xbCapabilities.getAbstractDataRecord(), notNullValue());
assertThat(xbCapabilities.getAbstractDataRecord(), instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.getAbstractDataRecord();
assertThat(xbSimpleDataRecord.getFieldArray().length, is(fields));
return xbSimpleDataRecord;
}
use of org.geotoolkit.swe.xml.v101.SimpleDataRecordType 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.geotoolkit.swe.xml.v101.SimpleDataRecordType 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.geotoolkit.swe.xml.v101.SimpleDataRecordType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_quantities.
@Test
public void should_encode_simpleDatarecord_with_quantities() throws EncodingException {
final String name = "field-1";
final String unit = "m";
final Double value = 1.1;
final String name2 = "field-2";
final String unit2 = "urn:ogc:def:uom:UCUM::m";
final Double value2 = 1.2;
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweQuantity().setUom(unit).setValue(value))).addField(new SweField(name2, new SweQuantity().setUom(unit2).setValue(value2))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
assertThat(xbSimpleDataRecord.getFieldArray().length, is(2));
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
final AnyScalarPropertyType field2 = xbSimpleDataRecord.getFieldArray(1);
// unit in code
assertThat(field1.getName(), is(name));
assertThat(field1.isSetQuantity(), is(TRUE));
assertThat(field1.getQuantity().getValue(), is(value));
assertThat(field1.getQuantity().getUom().getCode(), is(unit));
// unit in href
assertThat(field2.getName(), is(name2));
assertThat(field2.isSetQuantity(), is(TRUE));
assertThat(field2.getQuantity().getValue(), is(value2));
assertThat(field2.getQuantity().getUom().getHref(), is(unit2));
}
use of org.geotoolkit.swe.xml.v101.SimpleDataRecordType 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