Search in sources :

Example 11 with SwesExtension

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));
}
Also used : Extensions(org.n52.shetland.ogc.ows.extension.Extensions) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 12 with SwesExtension

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));
}
Also used : Extensions(org.n52.shetland.ogc.ows.extension.Extensions) Test(org.junit.Test)

Example 13 with SwesExtension

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()));
}
Also used : Extensions(org.n52.shetland.ogc.ows.extension.Extensions) Test(org.junit.Test)

Example 14 with SwesExtension

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);
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) SwesExtension(org.n52.shetland.ogc.swes.SwesExtension)

Example 15 with SwesExtension

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));
}
Also used : BooleanType(net.opengis.swe.x20.BooleanType) XmlObject(org.apache.xmlbeans.XmlObject) SwesExtension(org.n52.shetland.ogc.swes.SwesExtension) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 Extensions (org.n52.shetland.ogc.ows.extension.Extensions)10 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)4 XmlObject (org.apache.xmlbeans.XmlObject)3 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)3 SwesExtension (org.n52.shetland.ogc.swes.SwesExtension)3 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)2 BooleanType (net.opengis.swe.x20.BooleanType)2 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)2 GetFeatureOfInterestType (net.opengis.sos.x20.GetFeatureOfInterestType)1 InsertObservationDocument (net.opengis.sos.x20.InsertObservationDocument)1 InsertObservationType (net.opengis.sos.x20.InsertObservationType)1 GetFeatureOfInterestRequest (org.n52.shetland.ogc.sos.request.GetFeatureOfInterestRequest)1 InsertObservationRequest (org.n52.shetland.ogc.sos.request.InsertObservationRequest)1 UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)1