@@ -300,4 +300,80 @@ public void testFetchTableSchema_WithGlide_ListType_ParseAsString() throws Excep
300300 Assert .assertEquals (Schema .Type .STRING ,
301301 schema .getField ("u_glide_array3" ).getSchema ().getUnionSchemas ().get (0 ).getType ());
302302 }
303+
304+ @ Test
305+ public void testFetchTableSchema_WithGlide_Static_ListType_ParseAsArray () throws Exception {
306+ ServiceNowConnectorConfig mockConfig = Mockito .mock (ServiceNowConnectorConfig .class );
307+ ServiceNowTableAPIClientImpl impl = new ServiceNowTableAPIClientImpl (mockConfig , true );
308+ ServiceNowTableAPIClientImpl implSpy = Mockito .spy (impl );
309+ String jsonResponse = "{\n " +
310+ " \" result\" : {\n " +
311+ " \" columns\" : {\n " +
312+ " \" u_glide_array2\" : {\n " +
313+ " \" label\" : \" glide_array2\" ,\n " +
314+ " \" type\" : \" glide_static_list\" ,\n " +
315+ " \" base_type\" : \" string\" ,\n " +
316+ " \" name\" : \" u_glide_array2\" ,\n " +
317+ " \" internal_type\" : \" glide_list\" \n " +
318+ " },\n " +
319+ " \" u_glide_array3\" : {\n " +
320+ " \" label\" : \" glide_array3\" ,\n " +
321+ " \" type\" : \" glide_static_list\" ,\n " +
322+ " \" base_type\" : \" string\" ,\n " +
323+ " \" name\" : \" u_glide_array3\" ,\n " +
324+ " \" internal_type\" : \" glide_list\" \n " +
325+ " }\n " +
326+ " }\n " +
327+ " }\n " +
328+ "}" ;
329+ RestAPIResponse mockResponse = new RestAPIResponse (Collections .emptyMap (), jsonResponse , null );
330+ Mockito .doReturn (mockResponse ).when (implSpy ).executeGetWithRetries (Mockito .any ());
331+ Schema schema = implSpy .fetchTableSchema ("u_custom_13" , "dummy-access-token" ,
332+ SourceValueType .SHOW_DISPLAY_VALUE , SchemaType .METADATA_API_BASED , false );
333+ Assert .assertNotNull (schema );
334+ Assert .assertEquals ("record" , schema .getDisplayName ());
335+ Assert .assertEquals (2 , schema .getFields ().size ());
336+ Assert .assertEquals (Schema .Type .ARRAY ,
337+ schema .getField ("u_glide_array2" ).getSchema ().getUnionSchemas ().get (0 ).getType ());
338+ Assert .assertEquals (Schema .Type .ARRAY ,
339+ schema .getField ("u_glide_array3" ).getSchema ().getUnionSchemas ().get (0 ).getType ());
340+ }
341+
342+ @ Test
343+ public void testFetchTableSchema_WithGlide_Static_ListType_ParseAsString () throws Exception {
344+ ServiceNowConnectorConfig mockConfig = Mockito .mock (ServiceNowConnectorConfig .class );
345+ ServiceNowTableAPIClientImpl impl = new ServiceNowTableAPIClientImpl (mockConfig , true );
346+ ServiceNowTableAPIClientImpl implSpy = Mockito .spy (impl );
347+ String jsonResponse = "{\n " +
348+ " \" result\" : {\n " +
349+ " \" columns\" : {\n " +
350+ " \" u_glide_array2\" : {\n " +
351+ " \" label\" : \" glide_array2\" ,\n " +
352+ " \" type\" : \" glide_static_list\" ,\n " +
353+ " \" base_type\" : \" string\" ,\n " +
354+ " \" name\" : \" u_glide_array2\" ,\n " +
355+ " \" internal_type\" : \" glide_list\" \n " +
356+ " },\n " +
357+ " \" u_glide_array3\" : {\n " +
358+ " \" label\" : \" glide_array3\" ,\n " +
359+ " \" type\" : \" glide_static_list\" ,\n " +
360+ " \" base_type\" : \" string\" ,\n " +
361+ " \" name\" : \" u_glide_array3\" ,\n " +
362+ " \" internal_type\" : \" glide_list\" \n " +
363+ " }\n " +
364+ " }\n " +
365+ " }\n " +
366+ "}" ;
367+ RestAPIResponse mockResponse = new RestAPIResponse (Collections .emptyMap (), jsonResponse , null );
368+ Mockito .doReturn (mockResponse ).when (implSpy ).executeGetWithRetries (Mockito .any ());
369+ Schema schema = implSpy .fetchTableSchema ("u_custom_13" , "dummy-access-token" ,
370+ SourceValueType .SHOW_DISPLAY_VALUE , SchemaType .METADATA_API_BASED , true );
371+ Assert .assertNotNull (schema );
372+ Assert .assertEquals ("record" , schema .getDisplayName ());
373+ Assert .assertEquals (2 , schema .getFields ().size ());
374+ Assert .assertEquals (Schema .Type .STRING ,
375+ schema .getField ("u_glide_array2" ).getSchema ().getUnionSchemas ().get (0 ).getType ());
376+ Assert .assertEquals (Schema .Type .STRING ,
377+ schema .getField ("u_glide_array3" ).getSchema ().getUnionSchemas ().get (0 ).getType ());
378+ }
303379}
0 commit comments