Skip to content

Commit

Permalink
Fix error compare method in IT framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Cpaulyz authored May 27, 2024
1 parent 6a0da36 commit 21a2396
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,37 @@ public final T requestAllAndCompare() throws SQLException {
T data = results.get(0);
for (int i = 1; i < results.size(); i++) {
T anotherData = results.get(i);
if (!Objects.equals(data, anotherData)) {
if (!compare(data, anotherData)) {
throw new InconsistentDataException(results, endpoints);
}
}
return data;
}

private boolean compare(T data, T anotherData) {
if (data instanceof byte[] && anotherData instanceof byte[]) {
return Arrays.equals((byte[]) data, (byte[]) anotherData);
} else if (data instanceof short[] && anotherData instanceof short[]) {
return Arrays.equals((short[]) data, (short[]) anotherData);
} else if (data instanceof int[] && anotherData instanceof int[]) {
return Arrays.equals((int[]) data, (int[]) anotherData);
} else if (data instanceof long[] && anotherData instanceof long[]) {
return Arrays.equals((long[]) data, (long[]) anotherData);
} else if (data instanceof char[] && anotherData instanceof char[]) {
return Arrays.equals((char[]) data, (char[]) anotherData);
} else if (data instanceof float[] && anotherData instanceof float[]) {
return Arrays.equals((float[]) data, (float[]) anotherData);
} else if (data instanceof double[] && anotherData instanceof double[]) {
return Arrays.equals((double[]) data, (double[]) anotherData);
} else if (data instanceof boolean[] && anotherData instanceof boolean[]) {
return Arrays.equals((boolean[]) data, (boolean[]) anotherData);
} else if (data instanceof Object[] && anotherData instanceof Object[]) {
return Arrays.equals((Object[]) data, (Object[]) anotherData);
} else {
return Objects.equals(data, anotherData);
}
}

protected void handleExceptions(Exception[] exceptions) throws SQLException {
if (exceptions.length == 0) {
return;
Expand Down

0 comments on commit 21a2396

Please sign in to comment.