Skip to content

Commit 17946a7

Browse files
llingllinggit
authored andcommitted
#1329 add type checking and result checking
1 parent dacf117 commit 17946a7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/impl/RowManagerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ public <T extends JSONReadHandle> T columnInfo(Plan plan, T resultsHandle) {
302302
@Override
303303
public <T> T columnInfoAs(Plan plan, Class<T> as) {
304304
ContentHandle<T> handle = handleFor(as);
305+
if (!(handle instanceof JSONReadHandle))
306+
throw new IllegalArgumentException("The handle is not an instance of JSONReadHandle.");
305307
if (columnInfo(plan, (JSONReadHandle) handle) == null) {
306308
return null;
307309
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,13 @@ public void testMapper() throws IOException, XPathExpressionException {
12071207
}
12081208
@Test
12091209
public void testColumnInfo() throws IOException {
1210+
String expected =
1211+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"lastName\", \"type\":\"string\", \"nullable\":false}\n" +
1212+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"firstName\", \"type\":\"string\", \"nullable\":false}\n" +
1213+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"dob\", \"type\":\"date\", \"nullable\":false}\n" +
1214+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"rowid\", \"type\":\"rowid\", \"nullable\":false}\n" +
1215+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"__docid\", \"type\":\"fraghint\", \"nullable\":false}\n" +
1216+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"__content\", \"type\":\"value\", \"nullable\":false}";
12101217
RowManager rowMgr = Common.client.newRowManager();
12111218

12121219
PlanBuilder p = rowMgr.newPlanBuilder();
@@ -1223,8 +1230,10 @@ public void testColumnInfo() throws IOException {
12231230

12241231
String result = rowMgr.columnInfo(builtPlan, new StringHandle()).get();
12251232
assertNotNull(result);
1233+
assertEquals(result, expected);
12261234
result = rowMgr.columnInfoAs(builtPlan, String.class);
12271235
assertNotNull(result);
1236+
assertEquals(result, expected);
12281237
}
12291238
@Test
12301239
public void testGenerateView() throws IOException {

0 commit comments

Comments
 (0)