@Test public void testValidateOrbitReference_UpdatedOrbitReference() throws ParserConfigurationException, IOException, SAXException { String orbitRef = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + " <sentinel-safe:orbitReference>\n" + " <sentinel-safe:orbitNumber groundTrackDirection=\"descending\" type=\"start\">30480</sentinel-safe:orbitNumber>\n" + " <sentinel-safe:orbitNumber groundTrackDirection=\"descending\" type=\"stop\">30480</sentinel-safe:orbitNumber>\n" + " <sentinel-safe:relativeOrbitNumber groundTrackDirection=\"descending\" type=\"start\">366</sentinel-safe:relativeOrbitNumber>\n" + " <sentinel-safe:relativeOrbitNumber groundTrackDirection=\"descending\" type=\"stop\">366</sentinel-safe:relativeOrbitNumber>\n" + " <sentinel-safe:passNumber groundTrackDirection=\"descending\" type=\"start\">60960</sentinel-safe:passNumber>\n" + " <sentinel-safe:passNumber groundTrackDirection=\"descending\" type=\"stop\">60960</sentinel-safe:passNumber>\n" + " <sentinel-safe:relativePassNumber groundTrackDirection=\"descending\" type=\"start\">732</sentinel-safe:relativePassNumber>\n" + " <sentinel-safe:relativePassNumber groundTrackDirection=\"descending\" type=\"stop\">732</sentinel-safe:relativePassNumber>\n" + " <sentinel-safe:cycleNumber>64</sentinel-safe:cycleNumber>\n" + " <sentinel-safe:phaseIdentifier>2</sentinel-safe:phaseIdentifier>\n" + " <sentinel-safe:elementSet>\n" + " <sentinel-safe:ephemeris>\n" + " <sentinel-safe:epoch type=\"UTC\">2007-12-29T09:58:03.535647Z</sentinel-safe:epoch>\n" + " <sentinel-safe:epoch type=\"UT1\">2007-12-29T09:58:04.146807</sentinel-safe:epoch>\n" + " <sentinel-safe:epoch type=\"TAI\">2007-12-29T09:57:31.535647</sentinel-safe:epoch>\n" + " <sentinel-safe:position>\n" + " <sentinel-safe:x>-7165034.298974</sentinel-safe:x>\n" + " <sentinel-safe:y>-61030.468280</sentinel-safe:y>\n" + " <sentinel-safe:z>-0.002899</sentinel-safe:z>\n" + " </sentinel-safe:position>\n" + " <sentinel-safe:velocity>\n" + " <sentinel-safe:x>-5.201120</sentinel-safe:x>\n" + " <sentinel-safe:y>1630.872964</sentinel-safe:y>\n" + " <sentinel-safe:z>7377.385722</sentinel-safe:z>\n" + " </sentinel-safe:velocity>\n" + " </sentinel-safe:ephemeris>\n" + " <sentinel-safe:ephemeris>\n" + " <sentinel-safe:epoch type=\"UTC\">2007-12-29T11:38:39.463791Z</sentinel-safe:epoch>\n" + " <sentinel-safe:epoch type=\"UT1\">2007-12-29T11:38:40.074951</sentinel-safe:epoch>\n" + " <sentinel-safe:epoch type=\"TAI\">2007-12-29T11:38:07.463791</sentinel-safe:epoch>\n" + " <sentinel-safe:position>\n" + " <sentinel-safe:x>-6511729.587356</sentinel-safe:x>\n" + " <sentinel-safe:y>2989785.779058</sentinel-safe:y>\n" + " <sentinel-safe:z>-0.000870</sentinel-safe:z>\n" + " </sentinel-safe:position>\n" + " <sentinel-safe:velocity>\n" + " <sentinel-safe:x>688.388148</sentinel-safe:x>\n" + " <sentinel-safe:y>1478.477404</sentinel-safe:y>\n" + " <sentinel-safe:z>7377.385722</sentinel-safe:z>\n" + " </sentinel-safe:velocity>\n" + " </sentinel-safe:ephemeris>\n" + " </sentinel-safe:elementSet>\n" + " </sentinel-safe:orbitReference>"; Document[] manifests = new Document[2]; final DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); manifests[0] = documentBuilder.parse(new InputSource(new ByteArrayInputStream(orbitRef.getBytes("utf-8")))); manifests[1] = documentBuilder.parse(new InputSource(new ByteArrayInputStream(orbitRef.getBytes("utf-8")))); try { Validator.validateOrbitReference(manifests); } catch (PDUStitchingException e) { fail("No exception expected"); } }
static void validateOrbitReference(Document[] manifests) throws PDUStitchingException { if (manifests.length < 2) { return; } String[] tagNames = new String[]{"sentinel-safe:orbitNumber", "sentinel-safe:relativeOrbitNumber", "sentinel-safe:passNumber", "sentinel-safe:relativePassNumber", "sentinel-safe:cycleNumber", "sentinel-safe:phaseIdentifier", "sentinel-safe:epoch", "sentinel-safe:x", "sentinel-safe:y", "sentinel-safe:z" }; for (String tagName : tagNames) { final NodeList referenceNodes = manifests[0].getElementsByTagName(tagName); for (int j = 1; j < manifests.length; j++) { final NodeList testNodes = manifests[j].getElementsByTagName(tagName); if (referenceNodes.getLength() != testNodes.getLength()) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } for (int k = 0; k < referenceNodes.getLength(); k++) { referenceNodes.item(k).normalize(); testNodes.item(k).normalize(); if (!referenceNodes.item(k).isEqualNode(testNodes.item(k))) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } } } } }
Validator { static void validateOrbitReference(Document[] manifests) throws PDUStitchingException { if (manifests.length < 2) { return; } String[] tagNames = new String[]{"sentinel-safe:orbitNumber", "sentinel-safe:relativeOrbitNumber", "sentinel-safe:passNumber", "sentinel-safe:relativePassNumber", "sentinel-safe:cycleNumber", "sentinel-safe:phaseIdentifier", "sentinel-safe:epoch", "sentinel-safe:x", "sentinel-safe:y", "sentinel-safe:z" }; for (String tagName : tagNames) { final NodeList referenceNodes = manifests[0].getElementsByTagName(tagName); for (int j = 1; j < manifests.length; j++) { final NodeList testNodes = manifests[j].getElementsByTagName(tagName); if (referenceNodes.getLength() != testNodes.getLength()) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } for (int k = 0; k < referenceNodes.getLength(); k++) { referenceNodes.item(k).normalize(); testNodes.item(k).normalize(); if (!referenceNodes.item(k).isEqualNode(testNodes.item(k))) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } } } } } }
Validator { static void validateOrbitReference(Document[] manifests) throws PDUStitchingException { if (manifests.length < 2) { return; } String[] tagNames = new String[]{"sentinel-safe:orbitNumber", "sentinel-safe:relativeOrbitNumber", "sentinel-safe:passNumber", "sentinel-safe:relativePassNumber", "sentinel-safe:cycleNumber", "sentinel-safe:phaseIdentifier", "sentinel-safe:epoch", "sentinel-safe:x", "sentinel-safe:y", "sentinel-safe:z" }; for (String tagName : tagNames) { final NodeList referenceNodes = manifests[0].getElementsByTagName(tagName); for (int j = 1; j < manifests.length; j++) { final NodeList testNodes = manifests[j].getElementsByTagName(tagName); if (referenceNodes.getLength() != testNodes.getLength()) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } for (int k = 0; k < referenceNodes.getLength(); k++) { referenceNodes.item(k).normalize(); testNodes.item(k).normalize(); if (!referenceNodes.item(k).isEqualNode(testNodes.item(k))) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } } } } }  }
Validator { static void validateOrbitReference(Document[] manifests) throws PDUStitchingException { if (manifests.length < 2) { return; } String[] tagNames = new String[]{"sentinel-safe:orbitNumber", "sentinel-safe:relativeOrbitNumber", "sentinel-safe:passNumber", "sentinel-safe:relativePassNumber", "sentinel-safe:cycleNumber", "sentinel-safe:phaseIdentifier", "sentinel-safe:epoch", "sentinel-safe:x", "sentinel-safe:y", "sentinel-safe:z" }; for (String tagName : tagNames) { final NodeList referenceNodes = manifests[0].getElementsByTagName(tagName); for (int j = 1; j < manifests.length; j++) { final NodeList testNodes = manifests[j].getElementsByTagName(tagName); if (referenceNodes.getLength() != testNodes.getLength()) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } for (int k = 0; k < referenceNodes.getLength(); k++) { referenceNodes.item(k).normalize(); testNodes.item(k).normalize(); if (!referenceNodes.item(k).isEqualNode(testNodes.item(k))) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } } } } }  static void validate(File[] manifestFiles); }
Validator { static void validateOrbitReference(Document[] manifests) throws PDUStitchingException { if (manifests.length < 2) { return; } String[] tagNames = new String[]{"sentinel-safe:orbitNumber", "sentinel-safe:relativeOrbitNumber", "sentinel-safe:passNumber", "sentinel-safe:relativePassNumber", "sentinel-safe:cycleNumber", "sentinel-safe:phaseIdentifier", "sentinel-safe:epoch", "sentinel-safe:x", "sentinel-safe:y", "sentinel-safe:z" }; for (String tagName : tagNames) { final NodeList referenceNodes = manifests[0].getElementsByTagName(tagName); for (int j = 1; j < manifests.length; j++) { final NodeList testNodes = manifests[j].getElementsByTagName(tagName); if (referenceNodes.getLength() != testNodes.getLength()) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } for (int k = 0; k < referenceNodes.getLength(); k++) { referenceNodes.item(k).normalize(); testNodes.item(k).normalize(); if (!referenceNodes.item(k).isEqualNode(testNodes.item(k))) { throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName); } } } } }  static void validate(File[] manifestFiles);  }