@@ -1140,8 +1140,7 @@ public void testInvalidDefinitions() throws KeyManagementException, NoSuchAlgori
11401140 }
11411141 // Should have SQL-NOCOLUMN exceptions.
11421142 assertTrue ("Exceptions not found" , str .toString ().contains ("SQL-NOCOLUMN" ));
1143- assertTrue ("Exceptions not found" , str .toString ().contains ("Column not found: invalid_view.colorId" ));
1144-
1143+ assertTrue ("Exceptions not found" , str .toString ().contains ("Column not found: invalid_view.colorId" ));
11451144 }
11461145
11471146 /*
@@ -1217,8 +1216,9 @@ public void testInvalidQualifier() throws KeyManagementException, NoSuchAlgorith
12171216
12181217 /*
12191218 * Test Map function
1219+ * TODO Refer to Eric's test and make changes.
12201220 */
1221- @ Test
1221+ @ Ignore
12221222 public void testMapFunction () throws KeyManagementException , NoSuchAlgorithmException , IOException , SAXException , ParserConfigurationException
12231223 {
12241224 System .out .println ("In testMapFunction method" );
@@ -1287,29 +1287,8 @@ public void testMapFunction() throws KeyManagementException, NoSuchAlgorithmExce
12871287 // plans from literals
12881288 ModifyPlan plan1 = p .fromLiterals (literalsM1 );
12891289 ModifyPlan plan2 = p .fromLiterals (literalsM2 );
1290- /*StringBuilder str = new StringBuilder();
1291- str.append("function colorIdMapper(result) {");
1292- str.append("switch(result.myColorId) {");
1293- str.append("case 1:");
1294- str.append("result.myColorId = 'RED';");
1295- str.append(" break;");
1296- str.append("case 2:");
1297- str.append("result.myColorId = 'BLUE';");
1298- str.append("break;");
1299- str.append("case 3:");
1300- str.append("result.myColorId = 'YELLOW';");
1301- str.append("break;");
1302- str.append("case 4:");
1303- str.append("result.myColorId = 'BLACK';");
1304- str.append("break;");
1305- str.append("default:");
1306- str.append("result.myColorId = 'NO COLOR';");
1307- str.append("}");
1308- str.append("return result;");
1309- str.append("};");*/
1310-
1311-
1312- ModifyPlan output = plan1 .joinInner ( plan2 , p .on (p .col ("colorId_shape" ), p .col ("colorId" )))
1290+
1291+ ModifyPlan output = plan1 .joinInner (plan2 , p .on (p .col ("colorId_shape" ), p .col ("colorId" )))
13131292 .select (
13141293 "rowId" ,
13151294 "desc" ,
@@ -1318,22 +1297,25 @@ public void testMapFunction() throws KeyManagementException, NoSuchAlgorithmExce
13181297 )
13191298 .orderBy (p .asc ("rowId" ));
13201299
1321- PlanFunction pf = output .installedFunction ("/marklogic.rest.resource/OpticsJSResourceModule/assets/resource.sjs" , "colorIdMapper" );
1300+ PlanFunction pf = output .installedFunction ("/marklogic.rest.resource/OpticsJSResourceModule/assets/resource.sjs" , "colorIdMapper" );
1301+
13221302 output .map (pf );
13231303
1324- JacksonHandle jacksonHandle = new JacksonHandle ();
1325- jacksonHandle .setMimetype ("application/json" );
1304+ JacksonHandle jacksonHandle = new JacksonHandle ();
1305+ jacksonHandle .setMimetype ("application/json" );
13261306
1327- rowMgr .resultDoc (output , jacksonHandle );
1328- JsonNode jsonBindingsNodes = jacksonHandle .get ().path ("rows" );
1307+ rowMgr .resultDoc (output , jacksonHandle );
1308+ JsonNode jsonBindingsNodes = jacksonHandle .get ().path ("rows" );
13291309
1330- // Should have 1 node returned.
1331- assertEquals ("One node not returned from testIntersect method" , 4 , jsonBindingsNodes .size ());
1332-
1333-
1334-
1310+ // Should have 4 node returned.
1311+ assertEquals ("Four nodes not returned from testMapFunction method" , 4 , jsonBindingsNodes .size ());
1312+ assertEquals ("Row 1 rowId value incorrect" , "1" , jsonBindingsNodes .path (0 ).path ("rowId" ).path ("value" ).asText ());
1313+ assertEquals ("Row 1 descAgg value incorrect" , "red" , jsonBindingsNodes .path (0 ).path ("colorDesc" ).path ("value" ).asText ());
1314+ assertEquals ("Row 1 rowId value incorrect" , "2" , jsonBindingsNodes .path (1 ).path ("rowId" ).path ("value" ).asText ());
1315+ assertEquals ("Row 1 descAgg value incorrect" , "blue" , jsonBindingsNodes .path (1 ).path ("colorDesc" ).path ("value" ).asText ());
13351316 }
13361317
1318+
13371319 @ AfterClass
13381320 public static void tearDownAfterClass () throws Exception
13391321 {
0 commit comments