Skip to content

Commit 8fba19b

Browse files
author
ehennum
committed
explain test for raw SQL, SPARQL, and QueryDSL #1280
1 parent 8a0458b commit 8fba19b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

marklogic-client-api/src/test/java/com/marklogic/client/test/RowManagerTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import javax.xml.transform.stream.StreamResult;
4040
import javax.xml.xpath.XPathExpressionException;
4141

42+
import com.marklogic.client.row.*;
4243
import com.marklogic.client.type.*;
4344
import org.junit.AfterClass;
4445
import org.junit.BeforeClass;
@@ -58,13 +59,9 @@
5859
import com.marklogic.client.io.JacksonHandle;
5960
import com.marklogic.client.io.ReaderHandle;
6061
import com.marklogic.client.io.StringHandle;
61-
import com.marklogic.client.row.RawPlanDefinition;
62-
import com.marklogic.client.row.RowManager;
6362
import com.marklogic.client.row.RowManager.RowSetPart;
6463
import com.marklogic.client.row.RowManager.RowStructure;
65-
import com.marklogic.client.row.RowRecord;
6664
import com.marklogic.client.row.RowRecord.ColumnKind;
67-
import com.marklogic.client.row.RowSet;
6865
import com.marklogic.client.util.EditableNamespaceContext;
6966

7067
public class RowManagerTest {
@@ -1212,9 +1209,11 @@ public void testRawSQL() throws IOException {
12121209

12131210
RowManager rowMgr = Common.client.newRowManager();
12141211

1215-
testViewRows(rowMgr.resultRows(rowMgr.newRawSQLPlan(new StringHandle(plan))));
1212+
RawPlan builtPlan = rowMgr.newRawSQLPlan(new StringHandle(plan));
1213+
testViewRows(rowMgr.resultRows(builtPlan));
12161214

1217-
// TODO: test explain
1215+
String stringRoot = rowMgr.explain(builtPlan, new StringHandle()).get();
1216+
assertNotNull(new ObjectMapper().readTree(stringRoot));
12181217
}
12191218
@Test
12201219
public void testRawSPARQLSelect() throws IOException {
@@ -1229,7 +1228,8 @@ public void testRawSPARQLSelect() throws IOException {
12291228

12301229
RowManager rowMgr = Common.client.newRowManager();
12311230

1232-
RowSet<RowRecord> rows = rowMgr.resultRows(rowMgr.newRawSPARQLSelectPlan(new StringHandle(plan)));
1231+
RawPlan builtPlan = rowMgr.newRawSPARQLSelectPlan(new StringHandle(plan));
1232+
RowSet<RowRecord> rows = rowMgr.resultRows(builtPlan);
12331233

12341234
int rowNum = 0;
12351235
for (RowRecord row: rows) {
@@ -1240,7 +1240,8 @@ public void testRawSPARQLSelect() throws IOException {
12401240
}
12411241
assertEquals("unexpected count of result records", 2, rowNum);
12421242

1243-
// TODO: test explain
1243+
String stringRoot = rowMgr.explain(builtPlan, new StringHandle()).get();
1244+
assertNotNull(new ObjectMapper().readTree(stringRoot));
12441245
}
12451246
@Test
12461247
public void testRawQueryDSL() throws IOException {
@@ -1255,9 +1256,11 @@ public void testRawQueryDSL() throws IOException {
12551256

12561257
RowManager rowMgr = Common.client.newRowManager();
12571258

1258-
testViewRows(rowMgr.resultRows(rowMgr.newRawQueryDSLPlan(new StringHandle(plan))));
1259+
RawPlan builtPlan = rowMgr.newRawQueryDSLPlan(new StringHandle(plan));
1260+
testViewRows(rowMgr.resultRows(builtPlan));
12591261

1260-
// TODO: test explain
1262+
String stringRoot = rowMgr.explain(builtPlan, new StringHandle()).get();
1263+
assertNotNull(new ObjectMapper().readTree(stringRoot));
12611264
}
12621265
private void checkSingleRow(NodeList row, RowSetPart datatypeStyle) {
12631266
assertEquals("unexpected column count in XML", 2, row.getLength());

0 commit comments

Comments
 (0)