Search in sources :

Example 16 with SweBoolean

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));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 17 with SweBoolean

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));
}
Also used : SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 18 with SweBoolean

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));
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 19 with SweBoolean

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));
}
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)

Example 20 with SweBoolean

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

Aggregations

SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)22 Test (org.junit.Test)13 XmlObject (org.apache.xmlbeans.XmlObject)10 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)8 SweField (org.n52.shetland.ogc.swe.SweField)7 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)7 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)7 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)7 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)5 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)5 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)5 EncodingException (org.n52.svalbard.encode.exception.EncodingException)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)3 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)3 DataRecordType (net.opengis.swe.x101.DataRecordType)3 BooleanType (net.opengis.swe.x20.BooleanType)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3 BigDecimal (java.math.BigDecimal)2