GlobalMetadata { public MetadataElement asMetadataElement() { final MetadataElement processingGraph = new MetadataElement("Processing_Graph"); final MetadataElement node_0 = new MetadataElement("node.0"); final MetadataElement parameters = new MetadataElement("parameters"); for (final String name : metaProperties.keySet()) { final String value = metaProperties.get(name); parameters.addAttribute(new MetadataAttribute(name, ProductData.createInstance(value), true)); } ProductData processingTime = ProductData.createInstance(DATETIME_OUTPUT_FORMAT.format(new Date())); node_0.addAttribute(new MetadataAttribute("processingTime", processingTime, false)); node_0.addElement(parameters); processingGraph.addElement(node_0); return processingGraph; } GlobalMetadata(); static GlobalMetadata create(BinningOp operator); static GlobalMetadata create(BinningConfig config); void processMetadataTemplates(File metadataTemplateDir, BinningOp operator, Product targetProduct, Logger logger); SortedMap<String, String> asSortedMap(); MetadataElement asMetadataElement(); void load(File propertiesFile, Logger logger);  }
@Test public void testAsMetadataElement() throws ParseException { final BinningOp binningOp = createBinningOp(); final GlobalMetadata globalMetadata = GlobalMetadata.create(binningOp); final MetadataElement processingGraphElement = globalMetadata.asMetadataElement(); assertNotNull(processingGraphElement); assertEquals("Processing_Graph", processingGraphElement.getName()); final MetadataElement node_0_Element = processingGraphElement.getElement("node.0"); assertNotNull(node_0_Element); final MetadataElement parameterElement = node_0_Element.getElement("parameters"); assertEquals(11, parameterElement.getNumAttributes()); final MetadataAttribute software_qualified_name = parameterElement.getAttribute("software_qualified_name"); assertNotNull(software_qualified_name); assertEquals("org.esa.beam.binning.operator.BinningOp", software_qualified_name.getData().getElemString()); }
@Test public void testAsMetadataElement_noMetadataContained() { final GlobalMetadata globalMetadata = new GlobalMetadata(); final MetadataElement metadataElement = globalMetadata.asMetadataElement(); assertNotNull(metadataElement); assertEquals("Processing_Graph", metadataElement.getName()); assertEquals(0, metadataElement.getNumAttributes()); }