use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class FieldDecoderTest method testBoolean.
@Test
public void testBoolean() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.BOOLEAN_TYPE);
SweField field = checkCommon(json, false);
assertThat(field.getElement(), is(instanceOf(SweBoolean.class)));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class FieldDecoderTest method testQuantityRangeWithValue.
@Test
public void testQuantityRangeWithValue() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_RANGE_TYPE).put(JSONConstants.UOM, UOM);
json.putArray(JSONConstants.VALUE).add(QUANTITY_VALUE_START).add(QUANTITY_VALUE_END);
SweField field = checkCommon(json, true);
assertThat(field.getElement(), is(instanceOf(SweQuantityRange.class)));
SweQuantityRange swe = (SweQuantityRange) field.getElement();
errors.checkThat(swe.getUom(), is(UOM));
errors.checkThat(swe.getValue(), is(notNullValue()));
errors.checkThat(swe.getValue().getRangeStart().doubleValue(), is(QUANTITY_VALUE_START));
errors.checkThat(swe.getValue().getRangeEnd().doubleValue(), is(QUANTITY_VALUE_END));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class FieldDecoderTest method checkCommon.
protected SweField checkCommon(ObjectNode json, boolean withValue) throws DecodingException {
SweField field = validateWithValueAndDecode(json, withValue);
assertThat(field, is(notNullValue()));
errors.checkThat(field.getName().getValue(), is(NAME));
assertThat(field.getElement(), is(notNullValue()));
errors.checkThat(field.getElement().getDefinition(), is(DEFINITION));
errors.checkThat(field.getElement().getDescription(), is(DESCRIPTION));
errors.checkThat(field.getElement().getIdentifier(), is(IDENTIFIER));
errors.checkThat(field.getElement().getLabel(), is(LABEL));
return field;
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class InsertResultTemplateRequestDecoderTest method resultStructure.
@Test
public void resultStructure() throws IOException, DecodingException {
InsertResultTemplateRequest req = load();
assertThat(req.getResultStructure(), is(notNullValue()));
assertThat(req.getResultStructure().isDecoded(), is(true));
assertThat(req.getResultStructure().isEncoded(), is(false));
assertThat(req.getResultStructure().get().get(), is(instanceOf(SweDataRecord.class)));
SweDataRecord structure = (SweDataRecord) req.getResultStructure().get().get();
assertThat(structure.getFields(), is(notNullValue()));
assertThat(structure.getFields(), hasSize(3));
SweField field1 = structure.getFields().get(0);
assertThat(field1, is(notNullValue()));
errors.checkThat(field1.getName().getValue(), is("phenomenonTime"));
assertThat(field1.getElement(), is(instanceOf(SweTimeRange.class)));
SweTimeRange phenomenonTime = (SweTimeRange) field1.getElement();
errors.checkThat(phenomenonTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/PhenomenonTime"));
errors.checkThat(phenomenonTime.getUom(), is("http://www.opengis.net/def/uom/ISO-8601/0/Gregorian"));
SweField field2 = structure.getFields().get(1);
assertThat(field2, is(notNullValue()));
errors.checkThat(field2.getName().getValue(), is("resultTime"));
assertThat(field2.getElement(), is(instanceOf(SweTime.class)));
SweTime resultTime = (SweTime) field2.getElement();
errors.checkThat(resultTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/ResultTime"));
errors.checkThat(resultTime.getUom(), is("testunit1"));
SweField field3 = structure.getFields().get(2);
assertThat(field3, is(notNullValue()));
errors.checkThat(field3.getName().getValue(), is("observable_property_6"));
assertThat(field3.getElement(), is(instanceOf(SweQuantity.class)));
SweQuantity quantity = (SweQuantity) field3.getElement();
errors.checkThat(quantity.getDefinition(), is("http://www.52north.org/test/observableProperty/6"));
errors.checkThat(quantity.getUom(), is("test_unit_6"));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class FieldEncoder method encodeSweCountRangeField.
private ObjectNode encodeSweCountRangeField(SweField field) {
ObjectNode jfield = createField(field);
jfield.put(JSONConstants.TYPE, JSONConstants.COUNT_RANGE_TYPE);
SweCountRange sweCountRange = (SweCountRange) field.getElement();
if (sweCountRange.isSetValue()) {
ArrayNode av = jfield.putArray(JSONConstants.VALUE);
av.add(sweCountRange.getValue().getRangeStart());
av.add(sweCountRange.getValue().getRangeEnd());
}
return jfield;
}
Aggregations