use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SwesExtensionsTest method isBooleanExtensionSet_should_return_true_if_set_to_true.
@Test
public void isBooleanExtensionSet_should_return_true_if_set_to_true() {
final Extensions extensions = new Extensions();
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1).setValue(new SweBoolean().setValue(TRUE)));
assertThat(extensions.getBooleanExtension(DEFINITION_1), is(TRUE));
}
use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SwesExtensionsTest method isEmpty_should_return_false_if_at_least_one_extension_is_set.
@Test
public void isEmpty_should_return_false_if_at_least_one_extension_is_set() {
final Extensions extensions = new Extensions();
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1));
assertThat(extensions.isEmpty(), is(FALSE));
}
use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SwesExtensionsTest method getExtension_for_enum_created_with_string_schould_return_true.
@Test
public void getExtension_for_enum_created_with_string_schould_return_true() {
final Extensions extensions = new Extensions();
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1).setValue(VALUE_1));
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_2).setValue(VALUE_2));
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_3).setValue(VALUE_3));
assertThat(extensions.getExtension(DEFINITION_1).orElse(null).getValue(), instanceOf(VALUE_1.getClass()));
assertThat(extensions.getExtension(DEFINITION_2).orElse(null).getValue(), instanceOf(VALUE_2.getClass()));
assertThat(extensions.getExtension(DEFINITION_3).orElse(null).getValue(), instanceOf(VALUE_3.getClass()));
}
use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SwesExtensionDecoderv20 method decode.
@Override
public SwesExtension<?> decode(XmlObject xmlObject) throws DecodingException, UnsupportedDecoderInputException {
if (isSwesExtension(xmlObject)) {
XmlObject[] children = xmlObject.selectPath("./*");
if (children.length == 1) {
Object xmlObj = decodeXmlElement(children[0]);
if (xmlObj instanceof SweAbstractDataComponent) {
SwesExtension<SweAbstractDataComponent> extension = new SwesExtension<>();
extension.setValue((SweAbstractDataComponent) xmlObj);
return extension;
}
}
}
throw new UnsupportedDecoderXmlInputException(this, xmlObject);
}
use of org.n52.shetland.ogc.swes.SwesExtension 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));
}
Aggregations