Merge pull request #233 from apache/dependabot/maven/jackson.version-2.10.1
Bump jackson.version from 2.6.7 to 2.10.1
diff --git a/CHANGES.md b/CHANGES.md
index 2ab7c90..5c6a8cb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,6 @@
### Apache MetaModel _WIP_
+ * Upgrade to Jackson 2.10.1
+ * Upgrade to Spring 5.2.2
* [METAMODEL-82] - Detect Column Types with Excel datastores
* [METAMODEL-1221] - Upgrade to Elasticsearch 7.3
* Bind Travis build to Trusty distribution to avoid CI build failures.
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index f39b162..29ec710 100644
--- a/elasticsearch/common/pom.xml
+++ b/elasticsearch/common/pom.xml
@@ -33,7 +33,11 @@
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.25</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
diff --git a/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java b/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
index 1ac7fa2..1cf9b40 100644
--- a/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
+++ b/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
@@ -21,7 +21,9 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -217,7 +219,7 @@
String bookNodeIdJSONObject = requestWrapper.executeCypherQuery("MATCH (n:JUnitBook)"
+ " WHERE n.title = 'Introduction to algorithms'" + " RETURN id(n);");
String bookNodeId = new JSONObject(bookNodeIdJSONObject).getJSONArray("results").getJSONObject(0)
- .getJSONArray("data").getJSONObject(0).getJSONArray("row").getString(0);
+ .getJSONArray("data").getJSONObject(0).getJSONArray("row").optString(0);
Neo4jDataContext strategy = new Neo4jDataContext(getHostname(), getPort(), getUsername(), getPassword());
@@ -288,22 +290,22 @@
String bookNodeIdJSONObject = requestWrapper.executeCypherQuery("MATCH (n:JUnitBook)"
+ " WHERE n.title = 'Introduction to algorithms'" + " RETURN id(n);");
String bookNodeId = new JSONObject(bookNodeIdJSONObject).getJSONArray("results").getJSONObject(0)
- .getJSONArray("data").getJSONObject(0).getJSONArray("row").getString(0);
+ .getJSONArray("data").getJSONObject(0).getJSONArray("row").optString(0);
String helenaNodeIdJSONObject = requestWrapper.executeCypherQuery("MATCH (n:JUnitPerson)"
+ " WHERE n.name = 'Helena'" + " RETURN id(n);");
String helenaNodeId = new JSONObject(helenaNodeIdJSONObject).getJSONArray("results").getJSONObject(0)
- .getJSONArray("data").getJSONObject(0).getJSONArray("row").getString(0);
+ .getJSONArray("data").getJSONObject(0).getJSONArray("row").optString(0);
String tomaszNodeIdJSONObject = requestWrapper.executeCypherQuery("MATCH (n:JUnitPerson)"
+ " WHERE n.name = 'Tomasz'" + " RETURN id(n);");
String tomaszNodeId = new JSONObject(tomaszNodeIdJSONObject).getJSONArray("results").getJSONObject(0)
- .getJSONArray("data").getJSONObject(0).getJSONArray("row").getString(0);
+ .getJSONArray("data").getJSONObject(0).getJSONArray("row").optString(0);
String philomeenaNodeIdJSONObject = requestWrapper.executeCypherQuery("MATCH (n:JUnitPerson)"
+ " WHERE n.name = 'Philomeena'" + " RETURN id(n);");
String philomeenaNodeId = new JSONObject(philomeenaNodeIdJSONObject).getJSONArray("results").getJSONObject(0)
- .getJSONArray("data").getJSONObject(0).getJSONArray("row").getString(0);
+ .getJSONArray("data").getJSONObject(0).getJSONArray("row").optString(0);
Neo4jDataContext strategy = new Neo4jDataContext(getHostname(), getPort(), getUsername(), getPassword());
@@ -322,14 +324,31 @@
}
});
assertEquals(3, rows.size());
- assertEquals("Row[values=[" + helenaNodeId + ", Helena, 100, null, null, null]]", rows.get(0).toString());
- assertEquals("Row[values=[" + philomeenaNodeId + ", Philomeena, 18, null, null, " + bookNodeId + "]]", rows
- .get(1).toString());
- assertEquals("Row[values=[" + tomaszNodeId + ", Tomasz, 26, " + bookNodeId + ", 5, null]]", rows.get(2)
- .toString());
+
+ validateRow(rows.get(0), helenaNodeId, "Helena", "100", "null", "null", "null");
+ validateRow(rows.get(1), philomeenaNodeId, "Philomeena", "18", "null", "null", bookNodeId);
+ validateRow(rows.get(2), tomaszNodeId, "Tomasz", "26", bookNodeId, "5", "null");
}
}
+ void validateRow(final Row row, String... expectedValues) {
+ // Because the order of columns can vary over different test runs, we have to determine at which index the
+ // columns are.
+ final Map<String, Integer> columnNameMap = new HashMap<>();
+ for (int i = 0; i < 6; i++) {
+ String columnName = row.getSelectItems().get(i).getColumn().getName();
+
+ columnNameMap.put(columnName, i);
+ }
+
+ assertEquals(expectedValues[0], row.getValue(columnNameMap.get("_id")).toString());
+ assertEquals(expectedValues[1], row.getValue(columnNameMap.get("name")).toString());
+ assertEquals(expectedValues[2], row.getValue(columnNameMap.get("age")).toString());
+ assertEquals(expectedValues[3], row.getValue(columnNameMap.get("rel_HAS_READ")).toString());
+ assertEquals(expectedValues[4], row.getValue(columnNameMap.get("rel_HAS_READ#rating")).toString());
+ assertEquals(expectedValues[5], row.getValue(columnNameMap.get("rel_HAS_BROWSED")).toString());
+ }
+
@Test
public void testWhereClause() throws Exception {
if (!isConfigured()) {
@@ -445,7 +464,7 @@
String bookNodeIdJSONObject = requestWrapper.executeCypherQuery("MATCH (n:JUnitBook)"
+ " WHERE n.title = 'Introduction to algorithms'" + " RETURN id(n);");
String bookNodeId = new JSONObject(bookNodeIdJSONObject).getJSONArray("results").getJSONObject(0)
- .getJSONArray("data").getJSONObject(0).getJSONArray("row").getString(0);
+ .getJSONArray("data").getJSONObject(0).getJSONArray("row").optString(0);
Neo4jDataContext strategy = new Neo4jDataContext(getHostname(), getPort(), getUsername(), getPassword());
@@ -486,11 +505,21 @@
// create datacontext using detected schema
final DataContext dc = new Neo4jDataContext(getHostname(), getPort(), getUsername(), getPassword());
+ final String expectedFirstResult;
try (final DataSet ds = dc.query().from("JUnitLabel").select("name").and("age").firstRow(2).execute()) {
assertTrue("Class: " + ds.getClass().getName(), ds instanceof Neo4jDataSet);
assertTrue(ds.next());
final Row row = ds.getRow();
- assertEquals("Row[values=[Jane Doe, null]]", row.toString());
+
+ // Because the select query doesn't return results in an ordered manner, we can't be sure which result will
+ // be returned first and which second, but we do know that the one expected here (the second) shouldn't be
+ // the one returned first by the second query.
+ if (row.toString().equals("Row[values=[Jane Doe, null]]")) {
+ expectedFirstResult = "Row[values=[John Doe, 30]]";
+ } else {
+ assertEquals("Row[values=[John Doe, 30]]", row.toString());
+ expectedFirstResult = "Row[values=[Jane Doe, null]]";
+ }
assertFalse(ds.next());
}
@@ -498,7 +527,7 @@
assertTrue("Class: " + ds.getClass().getName(), ds instanceof Neo4jDataSet);
assertTrue(ds.next());
final Row row = ds.getRow();
- assertEquals("Row[values=[John Doe, 30]]", row.toString());
+ assertEquals(expectedFirstResult, row.toString());
assertFalse(ds.next());
}
}
diff --git a/pom.xml b/pom.xml
index 22a9233..ced6266 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
<junit.version>4.12</junit.version>
<guava.version>27.0.1-jre</guava.version>
<hadoop.version>3.1.1</hadoop.version>
- <jackson.version>2.6.7</jackson.version>
+ <jackson.version>2.10.1</jackson.version>
<easymock.version>3.2</easymock.version>
<spring.version>5.2.2.RELEASE</spring.version>
<httpcomponents.version>4.4.1</httpcomponents.version>