ImageSizeHandler { public static ImageSize[] extractImageSizes(Document manifestDocument) { final NodeList nadirElements = manifestDocument.getElementsByTagName("slstr:nadirImageSize"); final NodeList obliqueElements = manifestDocument.getElementsByTagName("slstr:obliqueImageSize"); final ImageSize[] imageSizes = new ImageSize[nadirElements.getLength() + obliqueElements.getLength()]; for (int i = 0; i < nadirElements.getLength(); i++) { imageSizes[i] = extractImageSizeFromNode(nadirElements.item(i), "n"); } for (int i = 0; i < obliqueElements.getLength(); i++) { imageSizes[nadirElements.getLength() + i] = extractImageSizeFromNode(obliqueElements.item(i), "o"); } return imageSizes; }  static ImageSize createTargetImageSize(ImageSize[] imageSizes); static ImageSize[] extractImageSizes(Document manifestDocument); static ImageSize extractImageSizeFromNode(Node element, String idExtension);  }
@Test public void testExtractImageSizes() throws IOException, URISyntaxException { final ImageSize[] imageSizes1 = ImageSizeHandler.extractImageSizes(createXmlDocument(new FileInputStream(getFirstSlstrFile()))); assertEquals(2, imageSizes1.length); assertEquals(new ImageSize("tn", 21687, 64, 2000, 130), imageSizes1[0]); assertEquals(new ImageSize("to", 21687, 64, 2000, 130), imageSizes1[1]); final ImageSize[] imageSizes2 = ImageSizeHandler.extractImageSizes(createXmlDocument(new FileInputStream(getSecondSlstrFile()))); assertEquals(3, imageSizes2.length); assertEquals(new ImageSize("tn", 23687, 64, 2000, 130), imageSizes2[0]); assertEquals(new ImageSize("io", 23687, 450, 2000, 900), imageSizes2[1]); assertEquals(new ImageSize("to", 23687, 64, 2000, 130), imageSizes2[2]); final ImageSize[] imageSizes3 = ImageSizeHandler.extractImageSizes(createXmlDocument(new FileInputStream(getThirdSlstrFile()))); assertEquals(2, imageSizes3.length); assertEquals(new ImageSize("tn", 25687, 64, 2000, 130), imageSizes3[0]); assertEquals(new ImageSize("to", 25687, 64, 2000, 130), imageSizes3[1]); }