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