Search in sources :

Example 6 with BooleanType

use of org.geotoolkit.swe.xml.v100.BooleanType in project arctic-sea by 52North.

the class InsertObservationRequestEncoderTest method shouldEncodeExtensions.

@Test
public void shouldEncodeExtensions() throws InvalidSridException, ParseException, EncodingException, DecodingException {
    String definition = Sos2Constants.Extensions.SplitDataArrayIntoObservations.name();
    boolean value = true;
    SweBoolean sweBoolean = new SweBoolean();
    sweBoolean.setValue(value);
    sweBoolean.setDefinition(definition);
    SwesExtension<SweBoolean> swesExtension = new SwesExtension<>();
    swesExtension.setValue(sweBoolean);
    InsertObservationRequest request = createInsertObservationRequest();
    request.addExtension(swesExtension);
    XmlObject encodedRequest = encoder.create(request);
    encodedRequest.xmlText();
    XmlHelper.validateDocument(encodedRequest);
    InsertObservationType insertObservation = ((InsertObservationDocument) encodedRequest).getInsertObservation();
    assertThat(insertObservation.sizeOfExtensionArray(), Is.is(1));
    XmlObject xbExtension = insertObservation.getExtensionArray(0);
    assertThat(xbExtension, Matchers.instanceOf(BooleanPropertyType.class));
    BooleanType xbBoolean = ((BooleanPropertyType) xbExtension).getBoolean();
    assertThat(xbBoolean.getDefinition(), Is.is(definition));
    assertThat(xbBoolean.getValue(), Is.is(value));
// no check for observation values, because that MUST be part of OmEncoderv20Test
}
Also used : InsertObservationDocument(net.opengis.sos.x20.InsertObservationDocument) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) BooleanType(net.opengis.swe.x20.BooleanType) XmlObject(org.apache.xmlbeans.XmlObject) SwesExtension(org.n52.shetland.ogc.swes.SwesExtension) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) InsertObservationType(net.opengis.sos.x20.InsertObservationType) Test(org.junit.jupiter.api.Test)

Example 7 with BooleanType

use of org.geotoolkit.swe.xml.v100.BooleanType 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));
    assertThat(sosBoolean.getQuality(), nullValue());
}
Also used : BooleanType(net.opengis.swe.x20.BooleanType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.jupiter.api.Test)

Example 8 with BooleanType

use of org.geotoolkit.swe.xml.v100.BooleanType 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);
    MatcherAssert.assertThat(encodedObject, Matchers.instanceOf(BooleanPropertyType.class));
    BooleanType xbBoolean = ((BooleanPropertyType) encodedObject).getBoolean();
    MatcherAssert.assertThat(xbBoolean.getDefinition(), Is.is(definition));
    MatcherAssert.assertThat(xbBoolean.getIdentifier(), Is.is(identifier));
    MatcherAssert.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.jupiter.api.Test)

Example 9 with BooleanType

use of org.geotoolkit.swe.xml.v100.BooleanType in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method marshallMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void marshallMarshalingTest() throws Exception {
    ObjectFactory factory = new ObjectFactory();
    List<DataComponentPropertyType> fields = new ArrayList<DataComponentPropertyType>();
    TimeType time = new TimeType("urn:x-ogc:def:phenomenon:observationTime", new UomPropertyType(null, "urn:x-ogc:def:unit:ISO8601"));
    fields.add(new DataComponentPropertyType("time", null, time));
    QuantityType q = new QuantityType("urn:x-ogc:def:phenomenon:OGC:depth", new UomPropertyType("m", null), null);
    fields.add(new DataComponentPropertyType("depth", null, q));
    BooleanType b = new BooleanType("urn:x-ogc:def:phenomenon:BRGM:validity", null);
    fields.add(new DataComponentPropertyType("validity", null, b));
    DataRecordType outRecord = new DataRecordType(null, fields);
    IoComponentPropertyType io2 = new IoComponentPropertyType("piezoMeasurements", swe100Factory.createDataRecord(outRecord));
    OutputList outputList = new OutputList(Arrays.asList(io2));
    Outputs outputs = new Outputs(outputList);
    Marshaller marshaller = SensorMLMarshallerPool.getInstance().acquireMarshaller();
    StringWriter sw = new StringWriter();
    marshaller.marshal(outputs, sw);
    String result = sw.toString();
    // System.out.println("result:" + result);
    ComponentType component = new ComponentType();
    ProcessMethodType process = new ProcessMethodType();
    component.setMethod(new MethodPropertyType(process));
    List<ComponentPropertyType> cpl = new ArrayList<ComponentPropertyType>();
    ComponentList cl = new ComponentList(cpl);
    sw = new StringWriter();
    marshaller.marshal(factory.createComponent(component), sw);
    result = sw.toString();
    // System.out.println("result:" + result);
    SensorMLMarshallerPool.getInstance().recycle(marshaller);
}
Also used : DataRecordType(org.geotoolkit.swe.xml.v100.DataRecordType) AbstractDataRecordType(org.geotoolkit.swe.xml.v100.AbstractDataRecordType) Marshaller(javax.xml.bind.Marshaller) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) ComponentPropertyType(org.geotoolkit.sml.xml.v100.ComponentPropertyType) ArrayList(java.util.ArrayList) BooleanType(org.geotoolkit.swe.xml.v100.BooleanType) ComponentList(org.geotoolkit.sml.xml.v100.ComponentList) ProcessMethodType(org.geotoolkit.sml.xml.v100.ProcessMethodType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) MethodPropertyType(org.geotoolkit.sml.xml.v100.MethodPropertyType) TimeType(org.geotoolkit.swe.xml.v100.TimeType) UomPropertyType(org.geotoolkit.swe.xml.v100.UomPropertyType) ObjectFactory(org.geotoolkit.sml.xml.v100.ObjectFactory) StringWriter(java.io.StringWriter) QuantityType(org.geotoolkit.swe.xml.v100.QuantityType) Outputs(org.geotoolkit.sml.xml.v100.Outputs) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) OutputList(org.geotoolkit.sml.xml.v100.OutputList)

Aggregations

BooleanType (net.opengis.swe.x20.BooleanType)7 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)4 CategoryType (net.opengis.swe.x20.CategoryType)3 CountRangeType (net.opengis.swe.x20.CountRangeType)3 CountType (net.opengis.swe.x20.CountType)3 DataArrayType (net.opengis.swe.x20.DataArrayType)3 DataRecordType (net.opengis.swe.x20.DataRecordType)3 QuantityRangeType (net.opengis.swe.x20.QuantityRangeType)3 QuantityType (net.opengis.swe.x20.QuantityType)3 TextType (net.opengis.swe.x20.TextType)3 TimeRangeType (net.opengis.swe.x20.TimeRangeType)3 TimeType (net.opengis.swe.x20.TimeType)3 VectorType (net.opengis.swe.x20.VectorType)3 Test (org.junit.jupiter.api.Test)3 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)3 ArrayList (java.util.ArrayList)2 InsertObservationDocument (net.opengis.sos.x20.InsertObservationDocument)2 InsertObservationType (net.opengis.sos.x20.InsertObservationType)2 CategoryRangeType (net.opengis.swe.x20.CategoryRangeType)2 DataArrayDocument (net.opengis.swe.x20.DataArrayDocument)2