public void testCreateXmlFromObject() {
    final GeneralFilterBand gfb =
        new GeneralFilterBand("filteredBand", _source, 2, GeneralFilterBand.MAX);
    gfb.setDescription("somehow explainig");
    gfb.setUnit("someUnit");
    _product.addBand(gfb);

    final Element xmlElement = _generalFilterBandPersistable.createXmlFromObject(gfb);

    assertNotNull(xmlElement);
    assertEquals(DimapProductConstants.TAG_SPECTRAL_BAND_INFO, xmlElement.getName());
    assertEquals(14, xmlElement.getChildren().size());
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_BAND_INDEX) != null);
    assertEquals(
        gfb.getProduct().getBandIndex(gfb.getName()),
        Integer.parseInt(xmlElement.getChildTextTrim(DimapProductConstants.TAG_BAND_INDEX)));
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_BAND_NAME) != null);
    assertEquals(gfb.getName(), xmlElement.getChildTextTrim(DimapProductConstants.TAG_BAND_NAME));
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_BAND_DESCRIPTION) != null);
    assertEquals(
        gfb.getDescription(),
        xmlElement.getChildTextTrim(DimapProductConstants.TAG_BAND_DESCRIPTION));
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_DATA_TYPE) != null);
    assertEquals(
        ProductData.getTypeString(gfb.getDataType()),
        xmlElement.getChildTextTrim(DimapProductConstants.TAG_DATA_TYPE));
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_PHYSICAL_UNIT) != null);
    assertEquals(
        gfb.getUnit(), xmlElement.getChildTextTrim(DimapProductConstants.TAG_PHYSICAL_UNIT));
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_SOLAR_FLUX) != null);
    assertEquals(
        gfb.getSolarFlux(),
        Float.parseFloat(xmlElement.getChildTextTrim(DimapProductConstants.TAG_SOLAR_FLUX)),
        EPS);
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_BAND_WAVELEN) != null);
    assertEquals(
        gfb.getSpectralWavelength(),
        Float.parseFloat(xmlElement.getChildTextTrim(DimapProductConstants.TAG_BAND_WAVELEN)),
        EPS);
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_BANDWIDTH) != null);
    assertEquals(
        gfb.getSpectralBandwidth(),
        Float.parseFloat(xmlElement.getChildTextTrim(DimapProductConstants.TAG_BANDWIDTH)),
        EPS);
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_SCALING_FACTOR) != null);
    assertEquals(
        gfb.getScalingFactor(),
        Double.parseDouble(xmlElement.getChildTextTrim(DimapProductConstants.TAG_SCALING_FACTOR)),
        EPS);
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_SCALING_OFFSET) != null);
    assertEquals(
        gfb.getScalingOffset(),
        Double.parseDouble(xmlElement.getChildTextTrim(DimapProductConstants.TAG_SCALING_OFFSET)),
        EPS);
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_SCALING_LOG_10) != null);
    assertEquals(
        gfb.isLog10Scaled(),
        Boolean.parseBoolean(
            xmlElement.getChildTextTrim(DimapProductConstants.TAG_SCALING_LOG_10)));
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_NO_DATA_VALUE_USED) != null);
    assertEquals(
        gfb.isNoDataValueUsed(),
        Boolean.parseBoolean(
            xmlElement.getChildTextTrim(DimapProductConstants.TAG_NO_DATA_VALUE_USED)));
    assertTrue(xmlElement.getChild(DimapProductConstants.TAG_NO_DATA_VALUE) != null);
    assertEquals(
        gfb.getNoDataValue(),
        Double.parseDouble(xmlElement.getChildTextTrim(DimapProductConstants.TAG_NO_DATA_VALUE)),
        EPS);

    final Element filterInfo = xmlElement.getChild(DimapProductConstants.TAG_FILTER_BAND_INFO);
    assertNotNull(filterInfo);
    assertEquals(
        GeneralFilterBandPersistable.GENERAL_FILTER_BAND_TYPE,
        filterInfo.getAttributeValue(GeneralFilterBandPersistable.ATTRIBUTE_BAND_TYPE));
    assertEquals(
        GeneralFilterBandPersistable.VERSION_1_1,
        filterInfo.getAttributeValue(GeneralFilterBandPersistable.ATTRIBUTE_VERSION));
    assertEquals(3, filterInfo.getChildren().size());
    assertTrue(filterInfo.getChild(DimapProductConstants.TAG_FILTER_SOURCE) != null);
    assertEquals(
        gfb.getSource().getName(),
        filterInfo.getChildTextTrim(DimapProductConstants.TAG_FILTER_SOURCE));
    assertTrue(filterInfo.getChild(DimapProductConstants.TAG_FILTER_SUB_WINDOW_SIZE) != null);
    assertEquals(
        gfb.getSubWindowSize(),
        Integer.parseInt(
            filterInfo.getChildTextTrim(DimapProductConstants.TAG_FILTER_SUB_WINDOW_SIZE)));
    assertTrue(filterInfo.getChild(DimapProductConstants.TAG_FILTER_OPERATOR_CLASS_NAME) != null);
    assertEquals(
        gfb.getOperator().getClass().getName(),
        filterInfo.getChildTextTrim(DimapProductConstants.TAG_FILTER_OPERATOR_CLASS_NAME));
  }
  private void assertCreateRightGeneralFilterBand(Element xmlElement) {
    final Object object = _generalFilterBandPersistable.createObjectFromXml(xmlElement, _product);
    _product.addBand((Band) object);

    assertNotNull(object);
    assertTrue(object instanceof GeneralFilterBand);
    final GeneralFilterBand gfb = (GeneralFilterBand) object;
    assertEquals(1, _product.getBandIndex(gfb.getName()));
    assertEquals(-1, gfb.getSpectralBandIndex());
    assertEquals("filtered_coffee", gfb.getName());
    assertEquals("with milk & sugar", gfb.getDescription());
    assertEquals(_source.getGeophysicalDataType(), gfb.getDataType());
    assertEquals("l", gfb.getUnit());
    assertEquals(0.0, gfb.getSolarFlux(), EPS);
    assertEquals(0.0, gfb.getSpectralWavelength(), EPS);
    assertEquals(0.0, gfb.getSpectralBandwidth(), EPS);
    assertEquals(1.0, gfb.getScalingFactor(), EPS);
    assertEquals(0.0, gfb.getScalingOffset(), EPS);
    assertFalse(gfb.isLog10Scaled());
    assertEquals(gfb.getSource().getName(), _source.getName());
    assertEquals(5, gfb.getSubWindowSize());
    assertEquals(5, gfb.getSubWindowWidth());
    assertEquals(5, gfb.getSubWindowHeight());
    assertTrue(gfb.getOperator() instanceof GeneralFilterBand.Mean);
  }