How to use login method of com.thrift.example.artificial.RPCInterfaceExampleImpl class

Best EvoMaster code snippet using com.thrift.example.artificial.RPCInterfaceExampleImpl.login

Source:RPCSutControllerTest.java Github

copy

Full Screen

1package org.evomaster.client.java.controller.problem.rpc.invocation;2import com.thrift.example.artificial.*;3import io.restassured.RestAssured;4import io.restassured.common.mapper.TypeRef;5import io.restassured.path.json.JsonPath;6import io.restassured.response.ResponseBodyExtractionOptions;7import org.evomaster.client.java.controller.api.Formats;8import org.evomaster.client.java.controller.api.dto.ActionResponseDto;9import org.evomaster.client.java.controller.api.dto.problem.RPCProblemDto;10import org.evomaster.client.java.controller.api.dto.problem.rpc.ParamDto;11import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCActionDto;12import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCInterfaceSchemaDto;13import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCSupportedDataType;14import org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue;15import org.junit.jupiter.api.AfterAll;16import org.junit.jupiter.api.BeforeAll;17import org.junit.jupiter.api.Test;18import java.util.ArrayList;19import java.util.Arrays;20import java.util.List;21import java.util.stream.Collectors;22import static io.restassured.RestAssured.given;23import static org.evomaster.client.java.controller.contentMatchers.NumberMatcher.numbersMatch;24import static org.hamcrest.CoreMatchers.is;25import static org.junit.jupiter.api.Assertions.*;26/**27 * created by manzhang on 2021/11/2728 */29public class RPCSutControllerTest {30 public final static FakeSutController rpcController = new FakeSutController();31 private static List<RPCInterfaceSchemaDto> interfaceSchemas;32 private static List<List<RPCActionDto>> seededTestDtos;33 @BeforeAll34 public static void initClass() {35 rpcController.setControllerPort(0);36 rpcController.startTheControllerServer();37 RestAssured.baseURI = "http://localhost";38 RestAssured.port = rpcController.getControllerServerPort();39 RestAssured.basePath = "/controller/api";40 RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();41 RPCProblemDto dto = given()42 .accept(Formats.JSON_V1)43 .get("/infoSUT")44 .then()45 .statusCode(200)46 .body("data.isSutRunning", is(false))47 .extract().body().jsonPath().getObject("data.rpcProblem.", RPCProblemDto.class);48 interfaceSchemas = dto.schemas;49 seededTestDtos = dto.seededTestDtos;50 }51 @AfterAll52 public static void tearDown() {53 rpcController.stopSut();54 }55 @Test56 public void testTypes(){57 List<String> types = interfaceSchemas.get(0).types.stream().map(t-> t.type.fullTypeNameWithGenericType).collect(Collectors.toList());58 assertTrue(types.contains(GenericResponse.class.getName()));59 assertTrue(types.contains(ObjectResponse.class.getName()));60 assertTrue(types.contains(CycleAObj.class.getName()));61 assertTrue(types.contains(CycleBObj.class.getName()));62 assertTrue(types.contains(ConstrainedRequest.class.getName()));63 assertTrue(types.contains(CustomizedRequestA.class.getName()));64 assertTrue(types.contains(CustomizedRequestB.class.getName()));65 assertTrue(types.contains(AuthLoginDto.class.getName()));66 assertTrue(types.contains(PrivateFieldInResponseDto.class.getName()));67 assertTrue(types.contains(ByteResponse.class.getName()));68 assertTrue(types.contains(StringChildDto.class.getName()));69 assertTrue(types.contains(IntChildDto.class.getName()));70 assertTrue(types.contains(ListChildDto.class.getName()));71 assertTrue(types.contains(GenericDto.class.getName()+"<"+Integer.class.getName()+", "+String.class.getName()+">"));72 assertTrue(types.contains(GenericDto.class.getName()+"<"+StringChildDto.class.getName()+", "+String.class.getName()+">"));73 assertTrue(types.contains(NestedGenericDto.class.getName()+"<"+String.class.getName()+">"));74 assertTrue(types.contains(GenericDto.class.getName()+"<"+String.class.getName()+", "+Integer.class.getName()+">"));75 assertTrue(types.contains(BigNumberObj.class.getName()));76 }77 @Test78 public void testSeedcheck(){79 assertEquals(1, seededTestDtos.size());80 assertEquals(1, seededTestDtos.get(0).size());81 RPCActionDto test_1 = seededTestDtos.get(0).get(0);82 RPCActionDto dto = test_1.copy();83 dto.doGenerateAssertions = true;84 dto.doGenerateTestScript = true;85 dto.controllerVariable = "rpcController";86 dto.responseVariable = "res1";87 dto.maxAssertionForDataInCollection = -1;88 ActionResponseDto responseDto = new ActionResponseDto();89 rpcController.executeAction(dto, responseDto);90 String expectedResponse = "1;2;3;" + System.lineSeparator()+91 "1;2;3;" + System.lineSeparator()+92 "BigNumberObj{bdPositiveFloat=10.12, bdNegativeFloat=-10.12, bdPositiveOrZeroFloat=0.00, bdNegativeOrZeroFloat=-2.16, biPositive=10, biPositiveOrZero=0, biNegative=-10, biNegativeOrZero=-2};" + System.lineSeparator()+93 "1:1;2:2;";94 assertEquals(expectedResponse, responseDto.rpcResponse.stringValue);95 }96 @Test97 public void testPrimitiveResponse(){98 List<String> functions = Arrays.asList("pBoolResponse","pByteResponse","pCharResponse","pShortResponse","pIntResponse","pLongResponse","pFloatResponse","pDoubleResponse");99 List<String> tests = new ArrayList<>();100 int index = 1;101 for (String m : functions){102 List<RPCActionDto> dtos = interfaceSchemas.get(0).endpoints.stream().filter(s-> s.actionName.equals(m)).collect(Collectors.toList());103 assertEquals(1, dtos.size());104 RPCActionDto dto = dtos.get(0).copy();105 assertEquals(0, dto.requestParams.size());106 dto.doGenerateAssertions = true;107 dto.doGenerateTestScript = true;108 dto.controllerVariable = "rpcController";109 dto.responseVariable = "res"+index;110 dto.maxAssertionForDataInCollection = -1;111 ActionResponseDto responseDto = new ActionResponseDto();112 rpcController.executeAction(dto, responseDto);113 tests.addAll(responseDto.testScript);114 tests.addAll(responseDto.assertionScript);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}...

Full Screen

Full Screen

Source:RPCInterfaceExampleImpl.java Github

copy

Full Screen

...95 public String handleCustomizedRequestB(CustomizedRequestB request) {96 return null;97 }98 @Override99 public void login(AuthLoginDto dto) {100 }101 @Override102 public PrivateFieldInResponseDto accessFieldDtoCheck(PrivateFieldInRequestDto dto) {103 return null;104 }105 @Override106 public ByteResponse byteResponse(byte arg1, Byte arg2) {107 ByteResponse res = new ByteResponse();108 res.byteValue = arg2;109 res.pbyteValue = arg1;110 return res;111 }112 @Override113 public String authorizedEndpoint() {...

Full Screen

Full Screen

login

Using AI Code Generation

copy

Full Screen

1import com.thrift.example.artificial.RPCInterfaceExampleImpl;2import com.thrift.example.artificial.RPCInterfaceExample;3import org.apache.thrift.TException;4import org.apache.thrift.protocol.TBinaryProtocol;5import org.apache.thrift.protocol.TCompactProtocol;6import org.apache.thrift.protocol.TJSONProtocol;7import org.apache.thrift.protocol.TProtocol;8import org.apache.thrift.server.TServer;9import org.apache.thrift.server.TServer.Args;10import org.apache.thrift.server.TSimpleServer;11import org.apache.thrift.server.TThreadPoolServer;12import org.apache.thrift.transport.TServerSocket;13import org.apache.thrift.transport.TServerTransport;14import org.apache.thrift.transport.TSocket;15import org.apache.thrift.transport.TTransport;16import org.apache.thrift.transport.TTransportException;17public class RPCInterfaceExampleClient {18 public static void main(String [] args) {19 try {20 TTransport transport;21 transport = new TSocket("localhost", 9090);22 transport.open();23 TProtocol protocol = new TBinaryProtocol(transport);24 RPCInterfaceExample.Client client = new RPCInterfaceExample.Client(protocol);25 perform(client);26 transport.close();27 } catch (TException x) {28 x.printStackTrace();29 } 30 }31 private static void perform(RPCInterfaceExample.Client client) throws TException32 {33 String result = client.login("test", "test");34 System.out.println("login result: " + result);35 }36}37import com.thrift.example.artificial.RPCInterfaceExampleImpl;38import com.thrift.example.artificial.RPCInterfaceExample;39import org.apache.thrift.TException;40import org.apache.thrift.protocol.TBinaryProtocol;41import org.apache.thrift.protocol.TCompactProtocol;42import org.apache.thrift.protocol.TJSONProtocol;43import org.apache.thrift.protocol.TProtocol;44import org.apache.thrift.server.TServer;45import org.apache.thrift.server.TServer.Args;46import org.apache.thrift.server.TSimpleServer;47import org.apache.thrift.server.TThreadPoolServer;48import org.apache.thrift.transport.TServerSocket;49import org.apache.thrift.transport.TServerTransport;50import org.apache.thrift.transport.TSocket;51import org.apache.thrift.transport.TTransport;52import org.apache.thrift.transport.TTransportException;53public class RPCInterfaceExampleServer {

Full Screen

Full Screen

login

Using AI Code Generation

copy

Full Screen

1import java.util.*;2import java.io.*;3import org.apache.thrift.*;4import org.apache.thrift.protocol.*;5import org.apache.thrift.transport.*;6import com.thrift.example.artificial.*;7public class 2 {8 public static void main(String [] args) {9 try {10 TTransport transport = new TSocket("localhost", 9090);11 transport.open();12 TProtocol protocol = new TBinaryProtocol(transport);13 RPCInterfaceExample.Client client = new RPCInterfaceExample.Client(protocol);14 boolean result = client.login("user1", "password1");15 System.out.println("Result = " + result);16 transport.close();17 } catch (TException x) {18 x.printStackTrace();19 }20 }21}

Full Screen

Full Screen

login

Using AI Code Generation

copy

Full Screen

1package com.thrift.example.artificial;2import org.apache.thrift.TException;3public class Client {4public static void main(String[] args) {5 RPCInterfaceExample.Client client = null;6 try {7 client = new RPCInterfaceExample.Client(new TBinaryProtocol(new TSocket("localhost", 9090)));8 client.login("test", "test");9 } catch (TException e) {10 e.printStackTrace();11 }12}13}

Full Screen

Full Screen

login

Using AI Code Generation

copy

Full Screen

1import java.util.*;2import org.apache.thrift.*;3import org.apache.thrift.transport.*;4import org.apache.thrift.protocol.*;5import com.thrift.example.artificial.*;6public class 2 {7 public static void main(String[] args) {8 try {9 TTransport transport;10 transport = new TSocket("localhost", 9090);11 transport.open();12 TProtocol protocol = new TBinaryProtocol(transport);13 RPCInterfaceExample.Client client = new RPCInterfaceExample.Client(protocol);14 perform(client);15 transport.close();16 } catch (TException x) {17 x.printStackTrace();18 }19 }20 private static void perform(RPCInterfaceExample.Client client) throws TException21 {22 client.login("user1", "pass1");23 }24}25import java.util.*;26import org.apache.thrift.*;27import org.apache.thrift.transport.*;28import org.apache.thrift.protocol.*;29import com.thrift.example.artificial.*;30public class 3 {31 public static void main(String[] args) {32 try {33 TTransport transport;34 transport = new TSocket("localhost", 9090);35 transport.open();36 TProtocol protocol = new TBinaryProtocol(transport);37 RPCInterfaceExample.Client client = new RPCInterfaceExample.Client(protocol);38 perform(client);39 transport.close();40 } catch (TException x) {41 x.printStackTrace();42 }43 }44 private static void perform(RPCInterfaceExample.Client client) throws TException45 {46 client.logout();47 }48}49import java.util.*;50import org.apache.thrift.*;51import org.apache.thrift.transport.*;52import org.apache.thrift.protocol.*;53import com.thrift.example.artificial.*;54public class 4 {55 public static void main(String[] args) {56 try {57 TTransport transport;58 transport = new TSocket("localhost", 9090);59 transport.open();60 TProtocol protocol = new TBinaryProtocol(transport);61 RPCInterfaceExample.Client client = new RPCInterfaceExample.Client(protocol);62 perform(client);63 transport.close();64 } catch (TException x) {65 x.printStackTrace();66 }67 }

Full Screen

Full Screen

login

Using AI Code Generation

copy

Full Screen

1public class 2 {2public static void main(String[] args) {3 try {4 TTransport transport = new TSocket("localhost", 9090);5 TProtocol protocol = new TBinaryProtocol(transport);6 RPCInterfaceExample.Client client = new RPCInterfaceExample.Client(protocol);7 transport.open();8 client.login("test", "test");9 transport.close();10 } catch (TTransportException e) {11 e.printStackTrace();12 } catch (TException e) {13 e.printStackTrace();14 }15}16}17RPCInterfaceExampleImpl.login() called with username: test and password: test

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful