use of org.n52.shetland.ogc.swe.simpleType.SweBoolean 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.simpleType.SweBoolean 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.simpleType.SweBoolean in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDataRecordWithFields.
@Test
public void should_encode_simpleDataRecordWithFields() throws EncodingException {
final String field0Value = "field-0-value";
final String field0Name = "field-0";
final String field1Name = "field-1";
final Boolean field1Value = Boolean.TRUE;
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field0Name, new SweText().setValue(field0Value))).addField(new SweField(field1Name, new SweBoolean().setValue(field1Value))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field0 = xbSimpleDataRecord.getFieldArray(0);
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(1);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(2));
assertThat(field0.isSetText(), is(TRUE));
assertThat(field0.getName(), is(field0Name));
assertThat(field0.getText().getValue(), is(field0Value));
assertThat(field1.isSetBoolean(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getBoolean().getValue(), is(field1Value));
}
use of org.n52.shetland.ogc.swe.simpleType.SweBoolean in project arctic-sea by 52North.
the class SwesExtensionEncoderv20Test method shouldEncodeSweTypeBoolean.
@Test
public void shouldEncodeSweTypeBoolean() throws EncodingException {
String identifier = "test-identifier";
String definition = "test-definition";
Boolean value = Boolean.TRUE;
SweBoolean sweBoolean = new SweBoolean();
sweBoolean.setDefinition(definition);
sweBoolean.setIdentifier(identifier);
sweBoolean.setValue(value);
SwesExtension<SweBoolean> extension = new SwesExtension<>();
extension.setValue(sweBoolean);
XmlObject encodedObject = encoder.encode(extension);
Assert.assertThat(encodedObject, Matchers.instanceOf(BooleanPropertyType.class));
BooleanType xbBoolean = ((BooleanPropertyType) encodedObject).getBoolean();
Assert.assertThat(xbBoolean.getDefinition(), Is.is(definition));
Assert.assertThat(xbBoolean.getIdentifier(), Is.is(identifier));
Assert.assertThat(xbBoolean.getValue(), Is.is(value));
}
use of org.n52.shetland.ogc.swe.simpleType.SweBoolean in project arctic-sea by 52North.
the class SweCommonDecoderV20Test method should_encode_xbBoolean_into_SosSweBoolean_with_correct_value_and_definition.
@Test
public void should_encode_xbBoolean_into_SosSweBoolean_with_correct_value_and_definition() throws DecodingException {
BooleanType xbBoolean = BooleanType.Factory.newInstance();
final boolean value = true;
xbBoolean.setValue(value);
xbBoolean.setDefinition(definition);
Object decodedObject = decoder.decode(xbBoolean);
assertThat(decodedObject.getClass().getName(), is(SweBoolean.class.getName()));
SweBoolean sosBoolean = (SweBoolean) decodedObject;
assertThat(sosBoolean.getValue(), is(value));
assertThat(sosBoolean.getDefinition(), is(definition));
}
Aggregations