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