ExporterUtils { static MetadataElement getSpecificProductHeader(Product product) { final MetadataElement metadataRoot = product.getMetadataRoot(); final MetadataElement variableHeader = metadataRoot.getElement("Variable_Header"); if (variableHeader == null) { return null; } final MetadataElement specificProductHeader = variableHeader.getElement("Specific_Product_Header"); if (specificProductHeader == null) { return null; } return specificProductHeader; }    }
@Test public void testGetSpecificProductHeader_noVariableHeader() { final Product product = new Product("hic", "haec", 2, 2); assertNull(ExporterUtils.getSpecificProductHeader(product)); }
@Test public void testGetSpecificProductHeader_noSpecificHeader() { final Product product = new Product("helge", "schneider", 2, 2); final MetadataElement metadataRoot = product.getMetadataRoot(); metadataRoot.addElement(new MetadataElement("Variable_Header")); assertNull(ExporterUtils.getSpecificProductHeader(product)); }
@Test public void testGetSpecificProductHeader() { final Product product = new Product("nasen", "mann", 2, 2); final MetadataElement metadataRoot = product.getMetadataRoot(); final MetadataElement variable_header = new MetadataElement("Variable_Header"); final MetadataElement sph = new MetadataElement("Specific_Product_Header"); variable_header.addElement(sph); metadataRoot.addElement(variable_header); final MetadataElement specificProductHeader = ExporterUtils.getSpecificProductHeader(product); assertSame(sph, specificProductHeader); }