@@ -1318,6 +1318,35 @@ public void test() throws Exception {
13181318 }
13191319
13201320
1321+ @Test
1322+ fun testJavaObjectAssertionInArrayUsesGPathIndex () {
1323+ val fooAction = RestCallAction (" 1" , HttpVerb .GET , RestPath (" /foo" ), mutableListOf ())
1324+
1325+ val (format, baseUrlOfSut, ei) = buildResourceEvaluatedIndividual(
1326+ dbInitialization = mutableListOf (),
1327+ groups = mutableListOf (
1328+ (mutableListOf<SqlAction >() to mutableListOf (fooAction))
1329+ ),
1330+ format = OutputFormat .JAVA_JUNIT_4
1331+ )
1332+
1333+ val fooResult = ei.seeResult(fooAction.getLocalId()) as RestCallResult
1334+ fooResult.setTimedout(false )
1335+ fooResult.setStatusCode(200 )
1336+ fooResult.setBody(" [{}]" ) // example in restcountries
1337+ fooResult.setBodyType(MediaType .APPLICATION_JSON_TYPE )
1338+
1339+ val config = getConfig(format)
1340+ val test = TestCase (test = ei, name = " test" )
1341+
1342+ val writer = RestTestCaseWriter (config, PartialOracles ())
1343+ val lines = writer.convertToCompilableTestCode(test, baseUrlOfSut)
1344+
1345+ assertTrue(lines.toString().contains(" .body(\" [0].isEmpty()\" , is(true))" ))
1346+ assertFalse(lines.toString().contains(" .body(\" '[0]'.isEmpty()\" , is(true))" ))
1347+ }
1348+
1349+
13211350 @Test
13221351 fun testTestWithObjectAssertion (){
13231352 val fooAction = RestCallAction (" 1" , HttpVerb .GET , RestPath (" /foo" ), mutableListOf ())
0 commit comments