Best EvoMaster code snippet using org.evomaster.client.java.controller.problem.rpc.invocation.FakeSutController.RPCInterfaceExampleImpl
Source:RPCSutControllerTest.java
...115 index++;116 }117 String expected ="boolean res1;\n" +118 "{\n" +119 " res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pBoolResponse();\n" +120 "}\n" +121 "assertEquals(false, res1);\n" +122 "byte res2;\n" +123 "{\n" +124 " res2 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pByteResponse();\n" +125 "}\n" +126 "assertEquals(0, res2);\n" +127 "char res3;\n" +128 "{\n" +129 " res3 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pCharResponse();\n" +130 "}\n" +131 "assertEquals('\\u0000', res3);\n" +132 "short res4;\n" +133 "{\n" +134 " res4 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pShortResponse();\n" +135 "}\n" +136 "assertEquals(0, res4);\n" +137 "int res5;\n" +138 "{\n" +139 " res5 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pIntResponse();\n" +140 "}\n" +141 "assertEquals(0, res5);\n" +142 "long res6;\n" +143 "{\n" +144 " res6 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pLongResponse();\n" +145 "}\n" +146 "assertEquals(0L, res6);\n" +147 "float res7;\n" +148 "{\n" +149 " res7 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pFloatResponse();\n" +150 "}\n" +151 "assertTrue(numbersMatch(0.0f, res7));\n" +152 "double res8;\n" +153 "{\n" +154 " res8 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).pDoubleResponse();\n" +155 "}\n" +156 "assertTrue(numbersMatch(0.0, res8));";157 assertEquals(expected, String.join("\n", tests));158 }159 @Test160 public void testMapResponse(){161 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("mapResponse")).collect(Collectors.toList());162 assertEquals(1, dtos.size());163 RPCActionDto dto = dtos.get(0).copy();164 assertEquals(0, dto.requestParams.size());165 dto.doGenerateAssertions = true;166 dto.doGenerateTestScript = true;167 dto.controllerVariable = "rpcController";168 dto.responseVariable = "res1";169 dto.maxAssertionForDataInCollection = -1;170 ActionResponseDto responseDto = new ActionResponseDto();171 rpcController.executeAction(dto, responseDto);172 String expectedTestScript ="java.util.Map<java.lang.String,com.thrift.example.artificial.NumericStringObj> res1 = null;\n" +173 "{\n" +174 " res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).mapResponse();\n" +175 "}";176 assertEquals(expectedTestScript, String.join("\n", responseDto.testScript));177 String expectedAssertions = "assertEquals(2, res1.size());\n" +178 "assertEquals(\"2L\", res1.get(\"bar\").getLongValue());\n" +179 "assertEquals(\"2\", res1.get(\"bar\").getIntValue());\n" +180 "assertEquals(\"242\", res1.get(\"bar\").getBigIntegerValue());\n" +181 "assertEquals(\"2.42\", res1.get(\"bar\").getBigDecimalValue());\n" +182 "assertEquals(\"42L\", res1.get(\"foo\").getLongValue());\n" +183 "assertEquals(\"42\", res1.get(\"foo\").getIntValue());\n" +184 "assertEquals(\"4242\", res1.get(\"foo\").getBigIntegerValue());\n" +185 "assertEquals(\"42.42\", res1.get(\"foo\").getBigDecimalValue());";186 assertEquals(expectedAssertions, String.join("\n", responseDto.assertionScript));187 }188 @Test189 public void testListResponse(){190 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("listResponse")).collect(Collectors.toList());191 assertEquals(1, dtos.size());192 RPCActionDto dto = dtos.get(0).copy();193 assertEquals(0, dto.requestParams.size());194 dto.doGenerateAssertions = true;195 dto.doGenerateTestScript = true;196 dto.controllerVariable = "rpcController";197 dto.responseVariable = "res1";198 dto.maxAssertionForDataInCollection = -1;199 ActionResponseDto responseDto = new ActionResponseDto();200 rpcController.executeAction(dto, responseDto);201 String expectedTestScript ="java.util.List<com.thrift.example.artificial.BigNumberObj> res1 = null;\n" +202 "{\n" +203 " res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).listResponse();\n" +204 "}";205 assertEquals(expectedTestScript, String.join("\n", responseDto.testScript));206 String expectedAssertions = "assertEquals(1, res1.size());\n" +207 "assertEquals(\"10.12\", res1.get(0).getBdPositiveFloat().toString());\n" +208 "assertEquals(\"-10.12\", res1.get(0).getBdNegativeFloat().toString());\n" +209 "assertEquals(\"0.00\", res1.get(0).getBdPositiveOrZeroFloat().toString());\n" +210 "assertEquals(\"-2.16\", res1.get(0).getBdNegativeOrZeroFloat().toString());\n" +211 "assertEquals(\"10\", res1.get(0).getBiPositive().toString());\n" +212 "assertEquals(\"0\", res1.get(0).getBiPositiveOrZero().toString());\n" +213 "assertEquals(\"-10\", res1.get(0).getBiNegative().toString());\n" +214 "assertEquals(\"-2\", res1.get(0).getBiNegativeOrZero().toString());";215 assertEquals(expectedAssertions, String.join("\n", responseDto.assertionScript));216 }217 @Test218 public void testBigNumber(){219 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("bigNumber")).collect(Collectors.toList());220 assertEquals(1, dtos.size());221 RPCActionDto dto = dtos.get(0).copy();222 assertEquals(1, dto.requestParams.size());223 dto.doGenerateAssertions = true;224 dto.doGenerateTestScript = true;225 dto.controllerVariable = "rpcController";226 dto.responseVariable = "res1";227 ActionResponseDto responseDto = new ActionResponseDto();228 ParamDto param = dto.requestParams.get(0);229 param.stringValue = "{}";230 assertEquals(8, param.innerContent.size());231 param.innerContent.get(0).stringValue = "10.12";232 param.innerContent.get(1).stringValue = "-10.12";233 param.innerContent.get(2).stringValue = "0.00";234 param.innerContent.get(3).stringValue = "-2.16";235 param.innerContent.get(4).stringValue = "10";236 param.innerContent.get(5).stringValue = "0";237 param.innerContent.get(6).stringValue = "-10";238 param.innerContent.get(7).stringValue = "-2";239 rpcController.executeAction(dto, responseDto);240 String expect = "BigNumberObj{" +241 "bdPositiveFloat=10.12" +242 ", bdNegativeFloat=-10.12" +243 ", bdPositiveOrZeroFloat=0.00" +244 ", bdNegativeOrZeroFloat=-2.16" +245 ", biPositive=10" +246 ", biPositiveOrZero=0" +247 ", biNegative=-10" +248 ", biNegativeOrZero=-2" +249 '}';250 assertEquals(expect, responseDto.rpcResponse.stringValue);251 List<String> assertionScript = responseDto.assertionScript;252 assertEquals("assertEquals(\"BigNumberObj{bdPositiveFloat=10.12, bdNegativeFloat=-10.12, bdPositiveOrZeroFloat=0.00, bdNegativeOrZeroFloat=-2.16, biPositive=10, biPositiveOrZero=0, biNegative=-10, biNegativeOrZero=-2}\", res1);", assertionScript.get(0));253 }254 @Test255 public void testEnumWithConstructor(){256 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handleEnumWithConstructor")).collect(Collectors.toList());257 assertEquals(1, dtos.size());258 RPCActionDto dto = dtos.get(0).copy();259 assertEquals(1, dto.requestParams.size());260 dto.doGenerateAssertions = true;261 dto.doGenerateTestScript = true;262 dto.controllerVariable = "rpcController";263 dto.responseVariable = "res1";264 ActionResponseDto responseDto = new ActionResponseDto();265 ParamDto param = dto.requestParams.get(0);266 param.stringValue = "{}";267 param.innerContent.get(0).stringValue="0";268 rpcController.executeAction(dto, responseDto);269 assertNull(responseDto.exceptionInfoDto);270 assertEquals(9, responseDto.testScript.size());271 assertEquals(1, responseDto.assertionScript.size());272 assertEquals("first", responseDto.rpcResponse.stringValue);273 }274 @Test275 public void testJavaException(){276 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handleException")).collect(Collectors.toList());277 assertEquals(1, dtos.size());278 RPCActionDto dto = dtos.get(0).copy();279 assertEquals(1, dto.requestParams.size());280 ActionResponseDto responseDto = new ActionResponseDto();281 ParamDto param = dto.requestParams.get(0);282 param.stringValue = null;283 rpcController.executeAction(dto, responseDto);284 assertNotNull(responseDto.exceptionInfoDto);285 assertEquals(NullPointerException.class.getName(), responseDto.exceptionInfoDto.exceptionName);286 assertEquals("null", responseDto.exceptionInfoDto.exceptionMessage);287 param.stringValue = "state";288 rpcController.executeAction(dto, responseDto);289 assertNotNull(responseDto.exceptionInfoDto);290 assertEquals(IllegalStateException.class.getName(), responseDto.exceptionInfoDto.exceptionName);291 assertEquals("state", responseDto.exceptionInfoDto.exceptionMessage);292 param.stringValue = "argument";293 rpcController.executeAction(dto, responseDto);294 assertNotNull(responseDto.exceptionInfoDto);295 assertEquals(IllegalArgumentException.class.getName(), responseDto.exceptionInfoDto.exceptionName);296 assertEquals("argument", responseDto.exceptionInfoDto.exceptionMessage);297 param.stringValue = "foo";298 rpcController.executeAction(dto, responseDto);299 assertNotNull(responseDto.exceptionInfoDto);300 assertEquals(RuntimeException.class.getName(), responseDto.exceptionInfoDto.exceptionName);301 assertEquals("foo", responseDto.exceptionInfoDto.exceptionMessage);302 }303 @Test304 public void testObjectResponseAssertion(){305 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("objResponse")).collect(Collectors.toList());306 assertEquals(1, dtos.size());307 RPCActionDto dto = dtos.get(0).copy();308 assertEquals(0, dto.requestParams.size());309 dto.doGenerateAssertions = true;310 dto.doGenerateTestScript = true;311 dto.controllerVariable = "rpcController";312 dto.responseVariable = "res1";313 ActionResponseDto responseDto = new ActionResponseDto();314 rpcController.executeAction(dto, responseDto);315 assertEquals(4, responseDto.testScript.size());316 assertEquals("com.thrift.example.artificial.ObjectResponse res1 = null;", responseDto.testScript.get(0));317 assertEquals("{", responseDto.testScript.get(1));318 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).objResponse();", responseDto.testScript.get(2));319 assertEquals("}", responseDto.testScript.get(3));320 assertEquals(7, responseDto.assertionScript.size());321 assertEquals("assertEquals(\"foo\", res1.f1);", responseDto.assertionScript.get(0));322 assertEquals("assertEquals(42, res1.f2);", responseDto.assertionScript.get(1));323 assertEquals("assertTrue(numbersMatch(0.42, res1.f3));", responseDto.assertionScript.get(2));324 assertEquals("assertNull(res1.cycle);", responseDto.assertionScript.get(3));325 assertEquals("assertEquals(3, res1.f4.length);", responseDto.assertionScript.get(4));326 assertEquals("assertNull(res1.f5);", responseDto.assertionScript.get(5));327 assertTrue(responseDto.assertionScript.get(6).contains("//assertEquals"));328 }329 @Test330 public void testHandleNestedGenericString(){331 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handleNestedGenericString")).collect(Collectors.toList());332 assertEquals(1, dtos.size());333 RPCActionDto dto = dtos.get(0).copy();334 assertEquals(1, dto.requestParams.size());335 dto.doGenerateAssertions = true;336 dto.doGenerateTestScript = true;337 dto.controllerVariable = "rpcController";338 dto.responseVariable = "res1";339 ActionResponseDto responseDto = new ActionResponseDto();340 dto.requestParams.get(0).innerContent = null;341 rpcController.executeAction(dto, responseDto);342 assertEquals(5, responseDto.testScript.size());343 assertEquals("com.thrift.example.artificial.NestedGenericDto<java.lang.String> res1 = null;", responseDto.testScript.get(0));344 assertEquals("{", responseDto.testScript.get(1));345 assertEquals(" com.thrift.example.artificial.NestedGenericDto<java.lang.String> arg0 = null;", responseDto.testScript.get(2));346 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handleNestedGenericString(arg0);", responseDto.testScript.get(3));347 assertEquals("}", responseDto.testScript.get(4));348 assertNotNull(responseDto.exceptionInfoDto);349 assertEquals("java.lang.NullPointerException", responseDto.exceptionInfoDto.exceptionName);350 dto = dtos.get(0).copy();351 dto.doGenerateAssertions = true;352 dto.doGenerateTestScript = true;353 dto.controllerVariable = "rpcController";354 dto.responseVariable = "res1";355 dto.maxAssertionForDataInCollection = 4;356 dto.requestParams.get(0).innerContent.get(0).innerContent = null;357 dto.requestParams.get(0).innerContent.get(1).innerContent = null;358 dto.requestParams.get(0).innerContent.get(2).innerContent = null;359 rpcController.executeAction(dto, responseDto);360 assertEquals(11, responseDto.testScript.size());361 assertEquals("com.thrift.example.artificial.NestedGenericDto<java.lang.String> res1 = null;", responseDto.testScript.get(0));362 assertEquals("{", responseDto.testScript.get(1));363 assertEquals(" com.thrift.example.artificial.NestedGenericDto<java.lang.String> arg0 = null;", responseDto.testScript.get(2));364 assertEquals(" {", responseDto.testScript.get(3));365 assertEquals(" arg0 = new com.thrift.example.artificial.NestedGenericDto<java.lang.String>();", responseDto.testScript.get(4));366 assertEquals(" arg0.intData = null;", responseDto.testScript.get(5));367 assertEquals(" arg0.stringData = null;", responseDto.testScript.get(6));368 assertEquals(" arg0.list = null;", responseDto.testScript.get(7));369 assertEquals(" }", responseDto.testScript.get(8));370 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(rpcController.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handleNestedGenericString(arg0);", responseDto.testScript.get(9));371 assertEquals("}", responseDto.testScript.get(10));372 assertEquals("assertEquals(\"child\", res1.intData.data1);", responseDto.assertionScript.get(0));373 assertEquals("assertEquals(0, res1.intData.data2.intValue());", responseDto.assertionScript.get(1));374 assertEquals("assertEquals(\"child\", res1.stringData.data1);", responseDto.assertionScript.get(2));375 assertEquals("assertEquals(\"child\", res1.stringData.data2);", responseDto.assertionScript.get(3));376 assertEquals("assertEquals(2, res1.list.size());", responseDto.assertionScript.get(4));377 assertEquals("assertEquals(\"child\", res1.list.get(0));", responseDto.assertionScript.get(5));378 assertEquals("assertEquals(\"child\", res1.list.get(1));", responseDto.assertionScript.get(6));379 }380 @Test381 public void testHandleGenericIntString(){382 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handleGenericIntString")).collect(Collectors.toList());383 assertEquals(1, dtos.size());384 RPCActionDto dto = dtos.get(0).copy();385 assertEquals(1, dto.requestParams.size());386 dto.doGenerateAssertions = true;387 dto.doGenerateTestScript = true;388 dto.controllerVariable = "controller";389 dto.responseVariable = "res1";390 ActionResponseDto responseDto = new ActionResponseDto();391 rpcController.executeAction(dto, responseDto);392 assertEquals(10, responseDto.testScript.size());393 assertEquals("com.thrift.example.artificial.GenericDto<java.lang.Integer, java.lang.String> res1 = null;", responseDto.testScript.get(0));394 assertEquals("{", responseDto.testScript.get(1));395 assertEquals(" com.thrift.example.artificial.GenericDto<java.lang.Integer, java.lang.String> arg0 = null;", responseDto.testScript.get(2));396 assertEquals(" {", responseDto.testScript.get(3));397 assertEquals(" arg0 = new com.thrift.example.artificial.GenericDto<java.lang.Integer, java.lang.String>();", responseDto.testScript.get(4));398 assertEquals(" arg0.data1 = null;", responseDto.testScript.get(5));399 assertEquals(" arg0.data2 = null;", responseDto.testScript.get(6));400 assertEquals(" }", responseDto.testScript.get(7));401 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handleGenericIntString(arg0);", responseDto.testScript.get(8));402 assertEquals("}", responseDto.testScript.get(9));403 responseDto.assertionScript.forEach(System.out::println);404 assertEquals(2, responseDto.assertionScript.size());405 assertEquals("assertEquals(0, res1.data1.intValue());", responseDto.assertionScript.get(0));406 assertEquals("assertEquals(\"generic\", res1.data2);", responseDto.assertionScript.get(1));407 }408 @Test409 public void testHandleGenericObjectString(){410 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handleGenericObjectString")).collect(Collectors.toList());411 assertEquals(1, dtos.size());412 RPCActionDto dto = dtos.get(0).copy();413 assertEquals(1, dto.requestParams.size());414 dto.doGenerateAssertions = true;415 dto.doGenerateTestScript = true;416 dto.controllerVariable = "controller";417 dto.responseVariable = "res1";418 ActionResponseDto responseDto = new ActionResponseDto();419 rpcController.executeAction(dto, responseDto);420 assertEquals(15, responseDto.testScript.size());421 assertEquals("com.thrift.example.artificial.GenericDto<com.thrift.example.artificial.StringChildDto, java.lang.String> res1 = null;", responseDto.testScript.get(0));422 assertEquals("{", responseDto.testScript.get(1));423 assertEquals(" com.thrift.example.artificial.GenericDto<com.thrift.example.artificial.StringChildDto, java.lang.String> arg0 = null;", responseDto.testScript.get(2));424 assertEquals(" {", responseDto.testScript.get(3));425 assertEquals(" arg0 = new com.thrift.example.artificial.GenericDto<com.thrift.example.artificial.StringChildDto, java.lang.String>();", responseDto.testScript.get(4));426 assertEquals(" arg0.data1 = null;", responseDto.testScript.get(5));427 assertEquals(" {", responseDto.testScript.get(6));428 assertEquals(" arg0.data1 = new com.thrift.example.artificial.StringChildDto();", responseDto.testScript.get(7));429 assertEquals(" arg0.data1.setCode(null);", responseDto.testScript.get(8));430 assertEquals(" arg0.data1.setMessage(null);", responseDto.testScript.get(9));431 assertEquals(" }", responseDto.testScript.get(10));432 assertEquals(" arg0.data2 = null;", responseDto.testScript.get(11));433 assertEquals(" }", responseDto.testScript.get(12));434 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handleGenericObjectString(arg0);", responseDto.testScript.get(13));435 assertEquals("}", responseDto.testScript.get(14));436 assertEquals(3, responseDto.assertionScript.size());437 assertEquals("assertEquals(\"child\", res1.data1.getCode());", responseDto.assertionScript.get(0));438 assertEquals("assertEquals(\"child\", res1.data1.getMessage());", responseDto.assertionScript.get(1));439 assertEquals("assertEquals(\"generic\", res1.data2);", responseDto.assertionScript.get(2));440 }441 @Test442 public void testHandledInheritedGenericStringDto(){443 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handledInheritedGenericStringDto")).collect(Collectors.toList());444 assertEquals(1, dtos.size());445 RPCActionDto dto = dtos.get(0).copy();446 assertEquals(1, dto.requestParams.size());447 dto.doGenerateAssertions = true;448 dto.doGenerateTestScript = true;449 dto.controllerVariable = "controller";450 dto.responseVariable = "res1";451 ActionResponseDto responseDto = new ActionResponseDto();452 rpcController.executeAction(dto, responseDto);453 assertEquals(10, responseDto.testScript.size());454 assertEquals("com.thrift.example.artificial.StringChildDto res1 = null;", responseDto.testScript.get(0));455 assertEquals("{", responseDto.testScript.get(1));456 assertEquals(" com.thrift.example.artificial.StringChildDto arg0 = null;", responseDto.testScript.get(2));457 assertEquals(" {", responseDto.testScript.get(3));458 assertEquals(" arg0 = new com.thrift.example.artificial.StringChildDto();", responseDto.testScript.get(4));459 assertEquals(" arg0.setCode(null);", responseDto.testScript.get(5));460 assertEquals(" arg0.setMessage(null);", responseDto.testScript.get(6));461 assertEquals(" }", responseDto.testScript.get(7));462 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handledInheritedGenericStringDto(arg0);", responseDto.testScript.get(8));463 assertEquals("}", responseDto.testScript.get(9));464 assertEquals(2, responseDto.assertionScript.size());465 assertEquals("assertEquals(\"child\", res1.getCode());", responseDto.assertionScript.get(0));466 assertEquals("assertEquals(\"child\", res1.getMessage());", responseDto.assertionScript.get(1));467 ParamDto request = dto.requestParams.get(0);468 assertEquals(2, request.innerContent.size());469 request.innerContent.get(0).stringValue = "ppcode";470 request.innerContent.get(1).stringValue = "pmsg";471 responseDto = new ActionResponseDto();472 rpcController.executeAction(dto, responseDto);473 assertEquals(10, responseDto.testScript.size());474 assertEquals("com.thrift.example.artificial.StringChildDto res1 = null;", responseDto.testScript.get(0));475 assertEquals("{", responseDto.testScript.get(1));476 assertEquals(" com.thrift.example.artificial.StringChildDto arg0 = null;", responseDto.testScript.get(2));477 assertEquals(" {", responseDto.testScript.get(3));478 assertEquals(" arg0 = new com.thrift.example.artificial.StringChildDto();", responseDto.testScript.get(4));479 assertEquals(" arg0.setCode(\"ppcode\");", responseDto.testScript.get(5));480 assertEquals(" arg0.setMessage(\"pmsg\");", responseDto.testScript.get(6));481 assertEquals(" }", responseDto.testScript.get(7));482 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handledInheritedGenericStringDto(arg0);", responseDto.testScript.get(8));483 assertEquals("}", responseDto.testScript.get(9));484 assertEquals(2, responseDto.assertionScript.size());485 assertEquals("assertEquals(\"childppcode\", res1.getCode());", responseDto.assertionScript.get(0));486 assertEquals("assertEquals(\"childpmsg\", res1.getMessage());", responseDto.assertionScript.get(1));487 }488 @Test489 public void testHandledInheritedGenericIntDto(){490 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handledInheritedGenericIntDto")).collect(Collectors.toList());491 assertEquals(1, dtos.size());492 RPCActionDto dto = dtos.get(0).copy();493 assertEquals(1, dto.requestParams.size());494 dto.doGenerateAssertions = true;495 dto.doGenerateTestScript = true;496 dto.controllerVariable = "controller";497 dto.responseVariable = "res1";498 ActionResponseDto responseDto = new ActionResponseDto();499 rpcController.executeAction(dto, responseDto);500 assertEquals(10, responseDto.testScript.size());501 assertEquals("com.thrift.example.artificial.IntChildDto res1 = null;", responseDto.testScript.get(0));502 assertEquals("{", responseDto.testScript.get(1));503 assertEquals(" com.thrift.example.artificial.IntChildDto arg0 = null;", responseDto.testScript.get(2));504 assertEquals(" {", responseDto.testScript.get(3));505 assertEquals(" arg0 = new com.thrift.example.artificial.IntChildDto();", responseDto.testScript.get(4));506 assertEquals(" arg0.setCode(null);", responseDto.testScript.get(5));507 assertEquals(" arg0.setMessage(null);", responseDto.testScript.get(6));508 assertEquals(" }", responseDto.testScript.get(7));509 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handledInheritedGenericIntDto(arg0);", responseDto.testScript.get(8));510 assertEquals("}", responseDto.testScript.get(9));511 assertEquals(2, responseDto.assertionScript.size());512 assertEquals("assertEquals(0, res1.getCode().intValue());", responseDto.assertionScript.get(0));513 assertEquals("assertEquals(0, res1.getMessage().intValue());", responseDto.assertionScript.get(1));514 ParamDto request = dto.requestParams.get(0);515 assertEquals(2, request.innerContent.size());516 request.innerContent.get(0).stringValue = "1";517 request.innerContent.get(1).stringValue = "2";518 responseDto = new ActionResponseDto();519 rpcController.executeAction(dto, responseDto);520 assertEquals(10, responseDto.testScript.size());521 assertEquals("com.thrift.example.artificial.IntChildDto res1 = null;", responseDto.testScript.get(0));522 assertEquals("{", responseDto.testScript.get(1));523 assertEquals(" com.thrift.example.artificial.IntChildDto arg0 = null;", responseDto.testScript.get(2));524 assertEquals(" {", responseDto.testScript.get(3));525 assertEquals(" arg0 = new com.thrift.example.artificial.IntChildDto();", responseDto.testScript.get(4));526 assertEquals(" arg0.setCode(1);", responseDto.testScript.get(5));527 assertEquals(" arg0.setMessage(2);", responseDto.testScript.get(6));528 assertEquals(" }", responseDto.testScript.get(7));529 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handledInheritedGenericIntDto(arg0);", responseDto.testScript.get(8));530 assertEquals("}", responseDto.testScript.get(9));531 assertEquals(2, responseDto.assertionScript.size());532 assertEquals("assertEquals(2, res1.getCode().intValue());", responseDto.assertionScript.get(0));533 assertEquals("assertEquals(3, res1.getMessage().intValue());", responseDto.assertionScript.get(1));534 }535 @Test536 public void testHandledInheritedGenericListDto(){537 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("handledInheritedGenericListDto")).collect(Collectors.toList());538 assertEquals(1, dtos.size());539 RPCActionDto dto = dtos.get(0).copy();540 assertEquals(1, dto.requestParams.size());541 dto.doGenerateAssertions = true;542 dto.doGenerateTestScript = true;543 dto.controllerVariable = "controller";544 dto.responseVariable = "res1";545 dto.maxAssertionForDataInCollection = 10;546 ActionResponseDto responseDto = new ActionResponseDto();547 rpcController.executeAction(dto, responseDto);548 assertEquals(12, responseDto.testScript.size());549 assertEquals("com.thrift.example.artificial.ListChildDto res1 = null;", responseDto.testScript.get(0));550 assertEquals("{", responseDto.testScript.get(1));551 assertEquals(" com.thrift.example.artificial.ListChildDto arg0 = null;", responseDto.testScript.get(2));552 assertEquals(" {", responseDto.testScript.get(3));553 assertEquals(" arg0 = new com.thrift.example.artificial.ListChildDto();", responseDto.testScript.get(4));554 assertEquals(" java.util.List<java.lang.Integer> arg0_code = null;", responseDto.testScript.get(5));555 assertEquals(" arg0.setCode(arg0_code);", responseDto.testScript.get(6));556 assertEquals(" java.util.List<java.lang.Integer> arg0_message = null;", responseDto.testScript.get(7));557 assertEquals(" arg0.setMessage(arg0_message);", responseDto.testScript.get(8));558 assertEquals(" }", responseDto.testScript.get(9));559 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handledInheritedGenericListDto(arg0);", responseDto.testScript.get(10));560 assertEquals("}", responseDto.testScript.get(11));561 assertEquals(4, responseDto.assertionScript.size());562 assertEquals("assertEquals(1, res1.getCode().size());", responseDto.assertionScript.get(0));563 assertEquals("assertEquals(0, res1.getCode().get(0).intValue());", responseDto.assertionScript.get(1));564 assertEquals("assertEquals(1, res1.getMessage().size());", responseDto.assertionScript.get(2));565 assertEquals("assertEquals(0, res1.getMessage().get(0).intValue());", responseDto.assertionScript.get(3));566 ParamDto request = dto.requestParams.get(0);567 assertEquals(2, request.innerContent.size());568 ParamDto innerCode = request.innerContent.get(0).type.example.copy();569 innerCode.stringValue = "1";570 request.innerContent.get(0).innerContent = Arrays.asList(innerCode);571 ParamDto innerMsg = request.innerContent.get(1).type.example.copy();572 innerMsg.stringValue = "2";573 request.innerContent.get(1).innerContent = Arrays.asList(innerMsg);574 responseDto = new ActionResponseDto();575 rpcController.executeAction(dto, responseDto);576 assertEquals(22, responseDto.testScript.size());577 assertEquals("com.thrift.example.artificial.ListChildDto res1 = null;", responseDto.testScript.get(0));578 assertEquals("{", responseDto.testScript.get(1));579 assertEquals(" com.thrift.example.artificial.ListChildDto arg0 = null;", responseDto.testScript.get(2));580 assertEquals(" {", responseDto.testScript.get(3));581 assertEquals(" arg0 = new com.thrift.example.artificial.ListChildDto();", responseDto.testScript.get(4));582 assertEquals(" java.util.List<java.lang.Integer> arg0_code = null;", responseDto.testScript.get(5));583 assertEquals(" {", responseDto.testScript.get(6));584 assertEquals(" arg0_code = new java.util.ArrayList<>();", responseDto.testScript.get(7));585 assertEquals(" java.lang.Integer arg0_code_e_0 = 1;", responseDto.testScript.get(8));586 assertEquals(" arg0_code.add(arg0_code_e_0);", responseDto.testScript.get(9));587 assertEquals(" }", responseDto.testScript.get(10));588 assertEquals(" arg0.setCode(arg0_code);", responseDto.testScript.get(11));589 assertEquals(" java.util.List<java.lang.Integer> arg0_message = null;", responseDto.testScript.get(12));590 assertEquals(" {", responseDto.testScript.get(13));591 assertEquals(" arg0_message = new java.util.ArrayList<>();", responseDto.testScript.get(14));592 assertEquals(" java.lang.Integer arg0_message_e_0 = 2;", responseDto.testScript.get(15));593 assertEquals(" arg0_message.add(arg0_message_e_0);", responseDto.testScript.get(16));594 assertEquals(" }", responseDto.testScript.get(17));595 assertEquals(" arg0.setMessage(arg0_message);", responseDto.testScript.get(18));596 assertEquals(" }", responseDto.testScript.get(19));597 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).handledInheritedGenericListDto(arg0);", responseDto.testScript.get(20));598 assertEquals("}", responseDto.testScript.get(21));599 assertEquals(4, responseDto.assertionScript.size());600 assertEquals("assertEquals(1, res1.getCode().size());", responseDto.assertionScript.get(0));601 assertEquals("assertEquals(2, res1.getCode().get(0).intValue());", responseDto.assertionScript.get(1));602 assertEquals("assertEquals(1, res1.getMessage().size());", responseDto.assertionScript.get(2));603 assertEquals("assertEquals(3, res1.getMessage().get(0).intValue());", responseDto.assertionScript.get(3));604 }605 @Test606 public void testRuntimeException(){607 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("throwRuntimeException")).collect(Collectors.toList());608 assertEquals(1, dtos.size());609 RPCActionDto dto = dtos.get(0).copy();610 ActionResponseDto responseDto = new ActionResponseDto();611 rpcController.executeAction(dto, responseDto);612 assertNotNull(responseDto.exceptionInfoDto);613 assertEquals("java.lang.RuntimeException", responseDto.exceptionInfoDto.exceptionName);614 assertEquals("runtime exception", responseDto.exceptionInfoDto.exceptionMessage);615 assertFalse(responseDto.exceptionInfoDto.isCauseOfUndeclaredThrowable);616 }617 @Test618 public void testUndeclaredThrowableException(){619 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("throwUndeclaredThrowableException")).collect(Collectors.toList());620 assertEquals(1, dtos.size());621 RPCActionDto dto = dtos.get(0).copy();622 ActionResponseDto responseDto = new ActionResponseDto();623 rpcController.executeAction(dto, responseDto);624 assertNotNull(responseDto.exceptionInfoDto);625 assertEquals("java.lang.IllegalStateException", responseDto.exceptionInfoDto.exceptionName);626 assertEquals("undeclared", responseDto.exceptionInfoDto.exceptionMessage);627 assertTrue(responseDto.exceptionInfoDto.isCauseOfUndeclaredThrowable);628 }629 @Test630 public void testLocalAuth(){631 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("authorizedEndpoint")).collect(Collectors.toList());632 assertEquals(1, dtos.size());633 RPCActionDto dto = dtos.get(0).copy();634 RPCActionDto localDto = rpcController.getLocalAuthSetupSchemaMap().get(0).getDto();635 localDto.responseVariable = "res1_auth";636 localDto.doGenerateTestScript = true;637 localDto.controllerVariable = "controller";638 ActionResponseDto authResponseDto = new ActionResponseDto();639 rpcController.executeHandleLocalAuthenticationSetup(localDto, authResponseDto);640 assertNotNull(authResponseDto.testScript);641 assertEquals(4, authResponseDto.testScript.size());642 assertEquals("{", authResponseDto.testScript.get(0));643 assertEquals(" java.lang.String arg0 = \"local_foo\";", authResponseDto.testScript.get(1));644 assertEquals(" controller.handleLocalAuthenticationSetup(arg0);", authResponseDto.testScript.get(2));645 assertEquals("}", authResponseDto.testScript.get(3));646 dto.doGenerateAssertions = true;647 dto.doGenerateTestScript = true;648 dto.controllerVariable = "controller";649 dto.responseVariable = "res1";650 ActionResponseDto responseDto = new ActionResponseDto();651 rpcController.executeAction(dto, responseDto);652 assertNotNull(responseDto.assertionScript);653 assertEquals("assertEquals(\"local\", res1);", responseDto.assertionScript.get(0));654 }655 @Test656 public void testSutInfoAndSchema(){657 assertEquals(1, interfaceSchemas.size());658 }659 @Test660 public void testSimpleWrapPrimitiveEndpoint(){661 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("simpleWrapPrimitive")).collect(Collectors.toList());662 assertEquals(1, dtos.size());663 RPCActionDto dto = dtos.get(0).copy();664 assertEquals(8, dto.requestParams.size());665 dto.requestParams.get(0).stringValue = ""+42;666 dto.requestParams.get(1).stringValue = ""+4.2f;667 dto.requestParams.get(2).stringValue = ""+42L;668 dto.requestParams.get(3).stringValue = ""+4.2;669 dto.requestParams.get(4).stringValue = ""+'x';670 dto.requestParams.get(5).stringValue = ""+ Byte.parseByte("42");671 dto.requestParams.get(6).stringValue = ""+ false;672 dto.requestParams.get(7).stringValue = ""+ Short.parseShort("42");673 ActionResponseDto responseDto = new ActionResponseDto();674 rpcController.executeAction(dto, responseDto);675 assertNotNull(responseDto.rpcResponse);676 assertEquals(RPCSupportedDataType.STRING, responseDto.rpcResponse.type.type);677 assertEquals("int:42,float:4.2,long:42,double:4.2,char:x,byte:42,boolean:false,short:42", responseDto.rpcResponse.stringValue);678 }679 @Test680 public void testSimplePrimitiveEndpoint(){681 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("simplePrimitive")).collect(Collectors.toList());682 assertEquals(1, dtos.size());683 RPCActionDto dto = dtos.get(0).copy();684 assertEquals(8, dto.requestParams.size());685 dto.requestParams.get(0).stringValue = ""+42;686 dto.requestParams.get(1).stringValue = ""+4.2f;687 dto.requestParams.get(2).stringValue = ""+42L;688 dto.requestParams.get(3).stringValue = ""+4.2;689 dto.requestParams.get(4).stringValue = ""+'x';690 dto.requestParams.get(5).stringValue = ""+ Byte.parseByte("42");691 dto.requestParams.get(6).stringValue = ""+ false;692 dto.requestParams.get(7).stringValue = ""+ Short.parseShort("42");693 ActionResponseDto responseDto = new ActionResponseDto();694 rpcController.executeAction(dto, responseDto);695 assertNotNull(responseDto.rpcResponse);696 assertEquals(RPCSupportedDataType.STRING, responseDto.rpcResponse.type.type);697 assertEquals("int:42,float:4.2,long:42,double:4.2,char:x,byte:42,boolean:false,short:42", responseDto.rpcResponse.stringValue);698 }699 @Test700 public void testByteResponse(){701 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals("byteResponse")).collect(Collectors.toList());702 assertEquals(1, dtos.size());703 RPCActionDto dto = dtos.get(0).copy();704 dto.requestParams.get(0).stringValue = "" + Byte.parseByte("0");705 dto.requestParams.get(1).stringValue = "" + Byte.parseByte("42");706 assertEquals(2, dto.requestParams.size());707 ActionResponseDto responseDto = new ActionResponseDto();708 dto.doGenerateTestScript = true;709 dto.doGenerateAssertions = true;710 dto.controllerVariable = "controller";711 dto.responseVariable = "res1";712 rpcController.executeAction(dto, responseDto);713 assertNotNull(responseDto.rpcResponse);714 assertEquals(RPCSupportedDataType.CUSTOM_OBJECT, responseDto.rpcResponse.type.type);715 assertEquals(6, responseDto.testScript.size());716 assertEquals("com.thrift.example.artificial.ByteResponse res1 = null;", responseDto.testScript.get(0));717 assertEquals("{", responseDto.testScript.get(1));718 assertEquals(" byte arg0 = 0;", responseDto.testScript.get(2));719 assertEquals(" java.lang.Byte arg1 = 42;", responseDto.testScript.get(3));720 assertEquals(" res1 = ((com.thrift.example.artificial.RPCInterfaceExampleImpl)(controller.getRPCClient(\"com.thrift.example.artificial.RPCInterfaceExample\"))).byteResponse(arg0,arg1);", responseDto.testScript.get(4));721 assertEquals("}", responseDto.testScript.get(5));722 assertEquals(2, responseDto.assertionScript.size());723 assertEquals("assertEquals(42, res1.byteValue.byteValue());", responseDto.assertionScript.get(0));724 assertEquals("assertEquals(0, res1.pbyteValue);", responseDto.assertionScript.get(1));725 responseDto.testScript.forEach(System.out::println);726 responseDto.assertionScript.forEach(System.out::println);727 }728}...
Source:FakeSutController.java
1package org.evomaster.client.java.controller.problem.rpc.invocation;2import com.fasterxml.jackson.core.JsonProcessingException;3import com.fasterxml.jackson.databind.ObjectMapper;4import com.thrift.example.artificial.RPCInterfaceExample;5import com.thrift.example.artificial.RPCInterfaceExampleImpl;6import org.evomaster.client.java.controller.EmbeddedSutController;7import org.evomaster.client.java.controller.api.dto.AuthenticationDto;8import org.evomaster.client.java.controller.api.dto.LocalAuthenticationDto;9import org.evomaster.client.java.controller.api.dto.SutInfoDto;10import org.evomaster.client.java.controller.api.dto.problem.rpc.SeededRPCActionDto;11import org.evomaster.client.java.controller.api.dto.problem.rpc.SeededRPCTestDto;12import org.evomaster.client.java.controller.internal.db.DbSpecification;13import org.evomaster.client.java.controller.problem.ProblemInfo;14import org.evomaster.client.java.controller.problem.RPCProblem;15import java.util.*;16/**17 * created by manzhang on 2021/11/2718 */19public class FakeSutController extends EmbeddedSutController {20 public boolean running;21 private RPCInterfaceExampleImpl sut = new RPCInterfaceExampleImpl();22 private final ObjectMapper objectMapper = new ObjectMapper();23 @Override24 public String startSut() {25 if (sut == null)26 sut = new RPCInterfaceExampleImpl();27 running = true;28 return null;29 }30 @Override31 public void stopSut() {32 running =false;33 }34 @Override35 public void resetStateOfSUT() {36 }37 @Override38 public boolean isSutRunning() {39 return running;40 }...
RPCInterfaceExampleImpl
Using AI Code Generation
1package org.evomaster.client.java.controller.problem.rpc;2import org.evomaster.client.java.controller.api.dto.SutInfoDto;3import org.evomaster.client.java.controller.api.dto.database.operations.DatabaseCommandDto;4import org.evomaster.client.java.controller.problem.ProblemInfo;5import org.evomaster.client.java.controller.problem.rpc.RpcCallResult;6import org.evomaster.client.java.controller.problem.rpc.RpcCallResultImpl;7import org.evomaster.client.java.controller.problem.rpc.RpcCallType;8import org.evomaster.client.java.controller.problem.rpc.RpcIndividual;9import org.evomaster.client.java.controller.problem.rpc.RpcIndividualDto;10import org.evomaster.client.java.controller.problem.rpc.RpcIndividualUtils;11import org.evomaster.client.java.controller.problem.rpc.RpcMethod;12import org.evomaster.client.java.controller.problem.rpc.RpcMethodDto;13import org.evomaster.client.java.controller.problem.rpc.RpcMethodUtils;14import org.evomaster.client.java.controller.problem.rpc.RpcProblem;15import org.evomaster.client.java.controller.problem.rpc.RpcResult;16import org.evomaster.client.java.controller.problem.rpc.RpcResultDto;17import org.evomaster.client.java.controller.problem.rpc.RpcResultsDto;18import org.evomaster.client.java.controller.problem.rpc.RpcResultsUtils;19import org.evomaster.client.java.controller.problem.rpc.RpcStatement;20import org.evomaster.client.java.controller.problem.rpc.RpcStatementDto;21import org.evomaster.client.java.controller.problem.rpc.RpcStatementUtils;22import org.evomaster.client.java.controller.problem.rpc.RpcTestUtils;23import org.evomaster.client.java.controller.problem.rpc.RpcType;24import org.evomaster.client.java.controller.problem.rpc.RpcTypeDto;25import org.evomaster.client.java.controller.problem.rpc.RpcTypeUtils;26import org.evomaster.client.java.controller.problem.rpc.StandardRpcAction;27import org.evomaster.client.java.controller.problem.rpc.StandardRpcActionDto;28import org.evomaster.client.java.controller.problem.rpc.StandardRpcActionUtils;29import org.evomaster.client.java.controller.problem.rpc.StandardRpcCall;30import org.evomaster.client.java.controller.problem.rpc.StandardRpcCallDto;31import org.evomaster.client.java.controller.problem.rpc.StandardRpcCallUtils;32import org.evomaster.client.java.controller.problem.rpc.StandardRpcIndividual;33import org.evomaster.client.java.controller.problem.rpc.StandardRpcIndividualDto;34import org.evomaster.client.java.controller.problem.rpc.StandardRpcIndividualUtils;35import
RPCInterfaceExampleImpl
Using AI Code Generation
1import org.evomaster.client.java.controller.problem.rpc.RPCController;2import org.evomaster.client.java.controller.problem.rpc.RPCResult;3import org.evomaster.client.java.controller.problem.rpc.RPCTarget;4import org.evomaster.client.java.controller.problem.rpc.RPCMethod;5import org.evomaster.client.java.controller.problem.rpc.RPCMethodType;6import org.evomast
RPCInterfaceExampleImpl
Using AI Code Generation
1import org.evomaster.client.java.controller.problem.rpc.RPCController;2import org.evomaster.client.java.controller.problem.rpc.RPCMethod;3import org.evomaster.client.java.controller.problem.rpc.RPCMethodParameter;4import org.evomaster.client.java.controller.problem.rpc.RPCResult;5import java.util.List;6public class 2 {7 public static void main(String[] args) {8 RPCController controller = new RPCController("org.evomaster.client.java.controller.problem.rpc.invocation.FakeSutController");9 List<RPCMethod> methods = controller.getMethods();10 System.out.println("All methods: " + methods);11 RPCResult result = controller.call("/rpc", "getTheAnswer", new RPCMethodParameter("answer", "42"));12 System.out.println("Result: " + result);13 controller.stop();14 }15}16import org.evomaster.client.java.controller.problem.rpc.RPCController;17import org.evomaster.client.java.controller.problem.rpc.RPCMethod;18import org.evomaster.client.java.controller.problem.rpc.RPCMethodParameter;19import org.evomaster.client.java.controller.problem.rpc.RPCResult;20import java.util.List;21public class 3 {22 public static void main(String[] args) {23 RPCController controller = new RPCController("org.evomaster.client.java.controller.problem.rpc.invocation.FakeSutController");24 List<RPCMethod> methods = controller.getMethods();25 System.out.println("All methods: " + methods);26 RPCResult result = controller.call("/rpc", "getTheAnswer", new RPCMethodParameter("answer", "42"));27 System.out.println("Result: " + result);28 controller.stop();29 }30}31import org.evomaster.client.java.controller.problem.rpc.RPCController;32import org.evomaster.client.java.controller.problem.rpc.RPCMethod;33import org.evomaster.client.java.controller.problem.rpc.RPCMethodParameter;34import org.evomaster.client.java.controller.problem.rpc.RPCResult;35import java.util.List;36public class 4 {37 public static void main(String[] args) {38 RPCController controller = new RPCController("org.ev
RPCInterfaceExampleImpl
Using AI Code Generation
1package org.evomaster.client.java.controller.problem.rpc;2import org.evomaster.client.java.controller.problem.rpc.invocation.FakeSutController;3import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInvocationHandler;4import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInvocationResult;5import org.evomaster.client.java.controller.problem.rpc.invocation.RPCRequest;6import java.util.Arrays;7public class RPCInterfaceExampleImpl implements RPCInterfaceExample {8 private final FakeSutController controller;9 public RPCInterfaceExampleImpl(FakeSutController controller) {10 this.controller = controller;11 }12 public String test(String s) {13 RPCRequest request = new RPCRequest();14 request.setClassName("org.evomaster.client.java.controller.problem.rpc.RPCInterfaceExample");15 request.setMethodName("test");16 request.setParameters(Arrays.asList(s));17 request.setParameterTypes(Arrays.asList(String.class));18 RPCInvocationResult result = RPCInvocationHandler.handle(controller, request);19 return (String) result.getValue();20 }21}22package org.evomaster.client.java.controller.problem.rpc;23import com.google.gson.Gson;24import com.google.gson.JsonElement;25import com.google.gson.JsonObject;26import com.google.gson.JsonParser;27import org.evomaster.client.java.controller.problem.rpc.invocation.FakeSutController;28import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInvocationHandler;29import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInvocationResult;30import org.evomaster.client.java.controller.problem.rpc.invocation.RPCRequest;31import java.util.Arrays;32public class RPCInterfaceExampleImpl implements RPCInterfaceExample {33 private final FakeSutController controller;34 public RPCInterfaceExampleImpl(FakeSutController controller) {35 this.controller = controller;36 }37 public String test(String s) {38 RPCRequest request = new RPCRequest();39 request.setClassName("org.evomaster.client.java.controller.problem.rpc.RPCInterfaceExample");40 request.setMethodName("test");41 request.setParameters(Arrays.asList(s));42 request.setParameterTypes(Arrays.asList(String.class));43 RPCInvocationResult result = RPCInvocationHandler.handle(controller, request);44 return (String) result.getValue();45 }46}
RPCInterfaceExampleImpl
Using AI Code Generation
1import org.evomaster.client.java.controller.problem.rpc.RPCController;2import org.evomaster.client.java.controller.problem.rpc.RPCIndividual;3import org.evomaster.client.java.controller.problem.rpc.RPCResult;4import org.evomaster.client.java.controller.problem.rpc.RPCSampler;5import org.evomaster.client.java.controller.problem.rpc.RPCTarget;6import org.evomaster.client.java.controller.problem.rpc.RPCType;7import org.evomaster.client.java.controller.problem.rpc.RPCMethod;8import org.evomaster.client.java.controller.problem.rpc.RPCAction;9import
RPCInterfaceExampleImpl
Using AI Code Generation
1package org.evomaster.client.java.controller.problem.rpc;2import org.evomaster.client.java.controller.problem.rpc.invocation.FakeSutController;3import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInvocation;4import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInterfaceExampleImpl;5import org.evomaster.client.java.controller.problem.rpc.invocation.RPCMethod;6import org.evomaster.client.java.controller.problem.rpc.invocation.RPCResponse;7import org.evomaster.client.java.controller.problem.rpc.invocation.RPCSingleCall;8import java.util.ArrayList;9import java.util.List;10public class RPCExample {11 public static void main(String[] args) {12 RPCInterfaceExampleImpl rpcInterfaceExampleImpl = new RPCInterfaceExampleImpl();13 RPCInvocation rpcInvocation = new RPCInvocation(rpcInterfaceExampleImpl);14 FakeSutController fakeSutController = new FakeSutController(rpcInvocation);15 List<RPCMethod> rpcMethods = new ArrayList<>();16 rpcMethods.add(RPCMethod.GET);17 rpcMethods.add(RPCMethod.POST);18 rpcMethods.add(RPCMethod.PUT);19 rpcMethods.add(RPCMethod.DELETE);20 RPCSingleCall rpcSingleCall = new RPCSingleCall(rpcMethods, "/api/1.0/users/1", 200);21 RPCResponse rpcResponse = fakeSutController.process(rpcSingleCall);22 System.out.println(rpcResponse.getBody());23 }24}25package org.evomaster.client.java.controller.problem.rpc;26import org.evomaster.client.java.controller.problem.rpc.invocation.FakeSutController;27import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInvocation;28import org.evomaster.client.java.controller.problem.rpc.invocation.RPCInterfaceExampleImpl;29import org.evomaster.client.java.controller.problem.rpc.invocation.RPCMethod;30import org.evomaster.client.java.controller.problem.rpc.invocation.RPCResponse;31import org.evomaster.client.java.controller.problem.rpc.invocation.RPCSingleCall;32import java.util.ArrayList;33import java.util.List;34public class RPCExample {35 public static void main(String[] args) {
RPCInterfaceExampleImpl
Using AI Code Generation
1public class RPCInterfaceExampleImplTest extends RPCInterfaceExampleImplTestBase {2 public void test() throws Exception {3 RPCInterfaceExampleImpl rpcInterfaceExampleImpl0 = new RPCInterfaceExampleImpl();4 rpcInterfaceExampleImpl0.method0();5 }6}7public class RPCInterfaceExampleImplTest extends RPCInterfaceExampleImplTestBase {8 public void test() throws Exception {9 RPCInterfaceExampleImpl rpcInterfaceExampleImpl0 = new RPCInterfaceExampleImpl();10 rpcInterfaceExampleImpl0.method1();11 }12}13public class RPCInterfaceExampleImplTest extends RPCInterfaceExampleImplTestBase {14 public void test() throws Exception {15 RPCInterfaceExampleImpl rpcInterfaceExampleImpl0 = new RPCInterfaceExampleImpl();16 rpcInterfaceExampleImpl0.method2();17 }18}19public class RPCInterfaceExampleImplTest extends RPCInterfaceExampleImplTestBase {20 public void test() throws Exception {21 RPCInterfaceExampleImpl rpcInterfaceExampleImpl0 = new RPCInterfaceExampleImpl();22 rpcInterfaceExampleImpl0.method3();23 }24}25public class RPCInterfaceExampleImplTest extends RPCInterfaceExampleImplTestBase {26 public void test() throws Exception {27 RPCInterfaceExampleImpl rpcInterfaceExampleImpl0 = new RPCInterfaceExampleImpl();28 rpcInterfaceExampleImpl0.method4();29 }30}
RPCInterfaceExampleImpl
Using AI Code Generation
1import org.evomaster.client.java.controller.problem.rpc.RPCController;2import org.evomaster.client.java.controller.problem.rpc.RPCMethod;3import org.evomaster.client.java.controller.problem.rpc.RPCResult;4import org.evomaster.client.java.controller.problem.rpc.RPCType;5import org.evomaster.client.java.controller.problem.rpc.RPCVariable;6import org.evomaster.client.java.controller.problem.rpc.RPCVariableType;7import org.evomaster.client.java.controller.problem.rpc.RPCAction;8import org.evomaster.client.java.controller.problem.rpc.R
RPCInterfaceExampleImpl
Using AI Code Generation
1public class RPCInterfaceExampleImpl implements RPCInterfaceExample {2 public RPCInterfaceExampleImpl() {3 }4 public String getFoo() {5 Object[] args = new Object[]{};6 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getFoo", args);7 return (String) result;8 }9 public String getBar() {10 Object[] args = new Object[]{};11 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getBar", args);12 return (String) result;13 }14 public String getBaz() {15 Object[] args = new Object[]{};16 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getBaz", args);17 return (String) result;18 }19 public String getFooBar() {20 Object[] args = new Object[]{};21 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getFooBar", args);22 return (String) result;23 }24 public String getFooBaz() {25 Object[] args = new Object[]{};26 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getFooBaz", args);27 return (String) result;28 }29 public String getBarBaz() {30 Object[] args = new Object[]{};31 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getBarBaz", args);32 return (String) result;33 }34 public String getFooBarBaz() {35 Object[] args = new Object[]{};36 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getFooBarBaz", args);37 return (String) result;38 }39 public String getFooBarBaz(int i) {40 Object[] args = new Object[]{i};41 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "getFooBarBaz", args);42 return (String) result;43 }44 public String getFooBarBaz(int i, String s) {45 Object[] args = new Object[]{i,s};46 Object result = FakeSutController.getInstance().call(RPCInterfaceExample.class, "get
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!