From 72d5d27c912f51d08728bde42127cda18c472f6d Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Tue, 29 Oct 2024 09:32:35 -0500 Subject: [PATCH] fix(java): Fix exception when baseline has fewer issues than what is returned by scan (#2078) * Wrong variable used in diff * Add test with an item removed from the baseline --- .../equalaccess/report/BaselineManager.java | 6 +-- .../AccessibilityCheckerSeleniumTest.java | 40 ++++++++++++++++++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java b/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java index 0ea851961..4739487c7 100644 --- a/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java +++ b/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java @@ -208,10 +208,10 @@ public static DiffResult[] diffResultsWithExpected(ACReport actual, ACReport exp DiffResult[] differences = diff(actual, expected); if (differences != null && differences.length > 0) { differences = Arrays.stream(differences).filter(difference -> { - return "E".equals(difference.kind) + return !("E".equals(difference.kind) && difference.path.length == 4 && difference.path.length > 2 && "bounds".equals(difference.path[2]) - && Math.abs((Integer)difference.lhs-(Integer)difference.rhs) <= 1; + && Math.abs((Integer)difference.lhs-(Integer)difference.rhs) <= 1); }).toArray(size -> new DiffResult[size]); if (differences.length == 0) return null; } @@ -270,7 +270,7 @@ private static DiffResult[] diff(ACReport actual, ACReport expected) { retVal.add(new DiffResult("A", idx, null, gson.toJson(expectedRs[idx]))); } for (int idx=expectedRs.length; idx < actualRs.length; ++idx) { - retVal.add(new DiffResult("A", idx, gson.toJson(expectedRs[idx]), null)); + retVal.add(new DiffResult("A", idx, gson.toJson(actualRs[idx]), null)); } for (int idx=0; idx lines = new ArrayList(); + String line = null; + + try { + FileReader fr = new FileReader(f1); + BufferedReader br = new BufferedReader(fr); + int idx=1; + while ((line = br.readLine()) != null) { + if (idx <= 2 || idx >= 30) { + lines.add(line); + } + ++idx; + } + fr.close(); + br.close(); + + FileWriter fw = new FileWriter(f1); + BufferedWriter out = new BufferedWriter(fw); + for(String s : lines) + out.write(s+"\n"); + out.flush(); + out.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } } // @Test public void getComplianceLong() {