Ejemplo n.º 1
0
 private ObjectNode encodeSweBooleanField(SweField field) {
   ObjectNode jfield = createField(field);
   jfield.put(JSONConstants.TYPE, JSONConstants.BOOLEAN_TYPE);
   SweBoolean sweBoolean = (SweBoolean) field.getElement();
   if (sweBoolean.isSetValue()) {
     jfield.put(JSONConstants.VALUE, sweBoolean.getValue());
   }
   return jfield;
 }
  @Test
  public void should_encode_xbBoolean_into_SosSweBoolean_with_correct_value_and_definition()
      throws OwsExceptionReport {
    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));
  }