Search in sources :

Example 6 with SweCount

use of org.n52.shetland.ogc.swe.simpleType.SweCount in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldCount.

@Test
public void should_encode_simpleDatarecord_with_fieldCount() throws EncodingException {
    final String name = "field-1";
    final int value = 42;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweCount().setValue(value))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    assertThat(field1.getName(), is(name));
    assertThat(field1.isSetCount(), is(TRUE));
    assertThat(field1.getCount().getValue().intValue(), is(value));
}
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) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 7 with SweCount

use of org.n52.shetland.ogc.swe.simpleType.SweCount in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_count_with_quality_Quantity.

@Test
public void should_encode_count_with_quality_Quantity() throws EncodingException {
    final double qualityQuantityValue = 42.0;
    final SweCount sosCount = (SweCount) new SweCount().setQuality(Lists.newArrayList((SweQuality) new SweQuantity().setValue(qualityQuantityValue)));
    final XmlObject encode = sweCommonEncoderv101.encode(sosCount);
    assertThat(encode, instanceOf(Count.class));
    final Count xbCount = (Count) encode;
    assertThat(xbCount.getQualityArray(), is(not(nullValue())));
    assertThat(xbCount.getQualityArray().length, is(1));
    assertThat(xbCount.getQualityArray(0).isSetQuantity(), is(true));
    assertThat(xbCount.getQualityArray(0).getQuantity().getValue(), is(qualityQuantityValue));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Count(net.opengis.swe.x101.CountDocument.Count) Test(org.junit.Test)

Example 8 with SweCount

use of org.n52.shetland.ogc.swe.simpleType.SweCount in project arctic-sea by 52North.

the class SweCommonEncoderv20Test method shouldEncodeDataRecordWithSweTextField.

@Test
public void shouldEncodeDataRecordWithSweTextField() throws OwsExceptionReport, EncodingException {
    final SweDataRecord record = new SweDataRecord();
    record.addField(new SweField("text", new SweText().setValue("textValue").setDefinition("textDef")));
    record.addField(new SweField("count", new SweCount().setValue(2).setDefinition("countDef")));
    final XmlObject encoded = sweCommonEncoderv20.encode(record);
    // validateDocument throws exceptions if the document is invalid
    XmlHelper.validateDocument(encoded, EncodingException::new);
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) EncodingException(org.n52.svalbard.encode.exception.EncodingException) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Example 9 with SweCount

use of org.n52.shetland.ogc.swe.simpleType.SweCount in project arctic-sea by 52North.

the class SweCommonDecoderV101Test method should_decode_Count_with_Quality_Text.

@Test
public void should_decode_Count_with_Quality_Text() throws DecodingException {
    final CountDocument xbCount = CountDocument.Factory.newInstance();
    final String textValue = "quality-text";
    xbCount.addNewCount().addNewQuality().addNewText().setValue(textValue);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbCount);
    assertThat(decodedObject, is(instanceOf(SweCount.class)));
    final SweCount sweCount = (SweCount) decodedObject;
    assertThat(sweCount.isSetQuality(), is(true));
    assertThat(sweCount.getQuality().size(), is(1));
    assertThat(sweCount.getQuality().iterator().next(), is(instanceOf(SweText.class)));
    assertThat(((SweText) sweCount.getQuality().iterator().next()).getValue(), is(textValue));
}
Also used : CountDocument(net.opengis.swe.x101.CountDocument) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Test(org.junit.Test)

Example 10 with SweCount

use of org.n52.shetland.ogc.swe.simpleType.SweCount in project arctic-sea by 52North.

the class FieldDecoderTest method testCountWithValue.

@Test
public void testCountWithValue() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.COUNT_TYPE).put(JSONConstants.VALUE, COUNT_VALUE_START);
    SweField field = checkCommon(json, true);
    assertThat(field.getElement(), is(instanceOf(SweCount.class)));
    SweCount swe = (SweCount) field.getElement();
    errors.checkThat(swe.getValue(), is(COUNT_VALUE_START));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Test(org.junit.Test)

Aggregations

SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)17 XmlObject (org.apache.xmlbeans.XmlObject)12 Test (org.junit.Test)9 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)9 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)8 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)8 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)6 SweField (org.n52.shetland.ogc.swe.SweField)6 EncodingException (org.n52.svalbard.encode.exception.EncodingException)5 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)5 Count (net.opengis.swe.x101.CountDocument.Count)4 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)4 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)3 DataRecordType (net.opengis.swe.x101.DataRecordType)3 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 BigDecimal (java.math.BigDecimal)2