|
18 | 18 | import org.apache.commons.lang3.StringUtils; |
19 | 19 | import org.apache.commons.lang3.tuple.Pair; |
20 | 20 | import org.apache.poi.ss.usermodel.Sheet; |
21 | | -import org.json.simple.JSONArray; |
22 | | -import org.json.simple.JSONObject; |
23 | 21 | import org.junit.Assert; |
24 | 22 | import org.junit.Test; |
25 | 23 | import org.junit.experimental.categories.Category; |
@@ -479,21 +477,21 @@ private void calculatedColumnsTest() throws Exception |
479 | 477 | assertTrue("Row " + i + " is missing value for column: " + col, row.containsKey(col)); |
480 | 478 |
|
481 | 479 | Object serverVal = row.get(col); |
482 | | - //NOTE: the java api uses org.json.simple.JSONArray, which implements List |
483 | | - if (serverVal instanceof List) |
| 480 | + |
| 481 | + //NOTE: the response value can be a List |
| 482 | + if (serverVal instanceof List<?> list) |
484 | 483 | { |
485 | | - List arr = ((List)serverVal); |
486 | | - String value = arr.size() == 0 ? null : StringUtils.trimToNull(StringUtils.join(arr, "\n")); |
| 484 | + String value = list.isEmpty() ? null : StringUtils.trimToNull(StringUtils.join(list, "\n")); |
487 | 485 | assertEquals("Incorrect value for: " + col + " on row: " + i, expectations[idx], value); |
488 | 486 | } |
489 | 487 | else if (serverVal instanceof Date) |
490 | 488 | { |
491 | 489 | Date d = dateFormat.parse(expectations[idx]); |
492 | 490 | assertEquals("Incorrect value for: " + col + " on row " + i, d, serverVal); |
493 | 491 | } |
494 | | - else if (serverVal != null && (serverVal instanceof Integer || serverVal instanceof Double)) |
| 492 | + else if ((serverVal instanceof Integer || serverVal instanceof Double)) |
495 | 493 | { |
496 | | - Double d = Double.parseDouble(expectations[idx]); |
| 494 | + double d = Double.parseDouble(expectations[idx]); |
497 | 495 | assertEquals("Incorrect value for: " + col + " on row " + i, d, Double.parseDouble(serverVal.toString()), DELTA); |
498 | 496 | } |
499 | 497 | else |
@@ -1509,17 +1507,16 @@ private void samplesTableTest() throws Exception |
1509 | 1507 | } |
1510 | 1508 | } |
1511 | 1509 |
|
1512 | | - private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| 1510 | + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
1513 | 1511 |
|
1514 | | - private String getColumnLabel(SelectRowsResponse srr, String name) throws org.json.simple.parser.ParseException |
| 1512 | + private String getColumnLabel(SelectRowsResponse srr, String name) |
1515 | 1513 | { |
1516 | | - JSONArray columnModel = (JSONArray) srr.getMetaData().get("fields"); |
1517 | | - for (Object o : columnModel) |
| 1514 | + List<Map<String, Object>> columnModel = (List<Map<String, Object>>) srr.getMetaData().get("fields"); |
| 1515 | + for (Map<String, Object> column : columnModel) |
1518 | 1516 | { |
1519 | | - JSONObject json = (JSONObject) o; |
1520 | | - if (name.equalsIgnoreCase((String) json.get("name"))) |
| 1517 | + if (name.equalsIgnoreCase((String) column.get("name"))) |
1521 | 1518 | { |
1522 | | - return String.valueOf(json.get("caption")); |
| 1519 | + return (String)column.get("caption"); |
1523 | 1520 | } |
1524 | 1521 | } |
1525 | 1522 |
|
|
0 commit comments