How to use RPCActionDto class of org.evomaster.client.java.controller.api.dto.problem.rpc package

Best EvoMaster code snippet using org.evomaster.client.java.controller.api.dto.problem.rpc.RPCActionDto

Source:EndpointSchema.java Github

copy

Full Screen

1package org.evomaster.client.java.controller.problem.rpc.schema;2import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCActionDto;3import org.evomaster.client.java.controller.api.dto.problem.rpc.SeededRPCActionDto;4import org.evomaster.client.java.controller.problem.rpc.CodeJavaGenerator;5import org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue;6import org.evomaster.client.java.controller.problem.rpc.schema.types.PrimitiveOrWrapperType;7import java.util.ArrayList;8import java.util.HashSet;9import java.util.List;10import java.util.Set;11import java.util.stream.Collectors;12import java.util.stream.IntStream;13/**14 * endpoint dto for RPC service15 */16public class EndpointSchema {17 /**18 * name of the endpoint19 */20 private final String name;21 /**22 * name of the interface23 */24 private final String interfaceName;25 /**26 * name of type of the client27 */28 private final String clientTypeName;29 /**30 * request params of the endpoint31 */32 private final List<NamedTypedValue> requestParams;33 /**34 * response of the endpoint35 */36 private final NamedTypedValue response;37 /**38 * a list of exceptions which could throw from this endpoint39 */40 private final List<NamedTypedValue> exceptions;41 /**42 * whether the endpoint is clarified with auth43 */44 private final boolean authRequired;45 /**46 * a list of index of auth info based on what are configured in the driver47 */48 private final List<Integer> requiredAuthCandidates;49 public Set<String> getRelatedCustomizedCandidates() {50 return relatedCustomizedCandidates;51 }52 /**53 * a list of references of the related customizations related to this endpoint54 * the reference now is defined based on the index of a list specified in the driver55 */56 private final Set<String> relatedCustomizedCandidates;57 /**58 *59 * @param name is the name of the endpoint, ie, method name60 * @param interfaceName is the full name of the interface61 * @param clientTypeName is the client type with its full name62 * @param requestParams is a list of parameters in request63 * @param response is the response, ie, return64 * @param exceptions is related to exception for this endpoint65 * @param authRequired specifies whether the endpoint clearly declares that it requires auth, eg with annotation66 * note that if authRequired is false, the endpoint could also apply global auth setup67 * @param requiredAuthCandidates represents required candidates for its auth setup68 * @param relatedCustomizedCandidates represents related customizations based on their references69 */70 public EndpointSchema(String name, String interfaceName, String clientTypeName,71 List<NamedTypedValue> requestParams, NamedTypedValue response, List<NamedTypedValue> exceptions,72 boolean authRequired, List<Integer> requiredAuthCandidates, Set<String> relatedCustomizedCandidates) {73 this.name = name;74 this.interfaceName = interfaceName;75 this.clientTypeName = clientTypeName;76 this.requestParams = requestParams;77 this.response = response;78 this.exceptions = exceptions;79 this.authRequired = authRequired;80 this.requiredAuthCandidates = requiredAuthCandidates;81 this.relatedCustomizedCandidates = relatedCustomizedCandidates;82 }83 public String getName() {84 return name;85 }86 public List<NamedTypedValue> getRequestParams() {87 return requestParams;88 }89 public NamedTypedValue getResponse() {90 return response;91 }92 public List<NamedTypedValue> getExceptions() {93 return exceptions;94 }95 /**96 *97 * @return a dto with a respect to this endpoint98 * such dto would be used between core and driver99 */100 public RPCActionDto getDto(){101 RPCActionDto dto = new RPCActionDto();102 dto.actionName = name;103 dto.interfaceId = interfaceName;104 dto.clientInfo = clientTypeName;105 if (requestParams != null)106 dto.requestParams = requestParams.stream().map(NamedTypedValue::getDto).collect(Collectors.toList());107 if (response != null)108 dto.responseParam = response.getDto();109 if (relatedCustomizedCandidates != null)110 dto.relatedCustomization = new HashSet<>(relatedCustomizedCandidates);111 if (requiredAuthCandidates != null)112 dto.requiredAuthCandidates = new ArrayList<>(requiredAuthCandidates);113 dto.isAuthorized = authRequired;114 return dto;115 }116 /**117 *118 * @param dto is a dto of rpc call which contains value info119 * @return if this endpoint matches the specified dto120 */121 public boolean sameEndpoint(RPCActionDto dto){122 return dto.actionName.equals(name)123 // only check input parameters124 // && (getResponse() == null || getResponse().sameParam(dto.responseParam))125 && ((getRequestParams() == null && dto.requestParams == null) || getRequestParams().size() == dto.requestParams.size())126 && IntStream.range(0, getRequestParams().size()).allMatch(i-> getRequestParams().get(i).sameParam(dto.requestParams.get(i)));127 }128 /**129 * find an endpoint schema based on seeded tests130 * @param dto a seeded test dto131 * @return an endpoint schema132 */133 public boolean sameEndpoint(SeededRPCActionDto dto){134 return dto.functionName.equals(name)135 // only check input parameters136 // && (getResponse() == null || getResponse().sameParam(dto.responseParam))137 && ((getRequestParams() == null && dto.inputParams == null) || getRequestParams().size() == dto.inputParams.size())138 && IntStream.range(0, getRequestParams().size()).allMatch(i-> getRequestParams().get(i).getType().getFullTypeName().equals(dto.inputParamTypes.get(i)));139 }140 /**141 *142 * @return a copy of this endpoint which contains its structure but not values143 */144 public EndpointSchema copyStructure(){145 return new EndpointSchema(146 name, interfaceName, clientTypeName,147 requestParams == null? null: requestParams.stream().map(NamedTypedValue::copyStructureWithProperties).collect(Collectors.toList()),148 response == null? null: response.copyStructureWithProperties(), exceptions == null? null: exceptions.stream().map(NamedTypedValue::copyStructureWithProperties).collect(Collectors.toList()),149 authRequired, requiredAuthCandidates, relatedCustomizedCandidates);150 }151 /**152 * set value of endpoint based on dto153 * @param dto contains value info the endpoint154 * note that the dto is typically generated by core side, ie, search155 */156 public void setValue(RPCActionDto dto){157 if (dto.requestParams != null ){158 IntStream.range(0, dto.requestParams.size()).forEach(s-> requestParams.get(s).setValueBasedOnDto(dto.requestParams.get(s)));159 }160 // might be not useful161 if (dto.responseParam != null)162 response.setValueBasedOnDto(dto.responseParam);163 }164 /**165 * process to generate java code to invoke this request166 * @param responseVarName specifies a variable name representing a response of this endpoint167 * @param clientVariable168 * @return code to send the request and set the response if exists169 */170 public List<String> newInvocationWithJava(String responseVarName, String controllerVarName, String clientVariable){...

Full Screen

Full Screen

Source:LocalAuthSetupSchema.java Github

copy

Full Screen

1package org.evomaster.client.java.controller.problem.rpc.schema;2import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCActionDto;3import org.evomaster.client.java.controller.problem.rpc.CodeJavaGenerator;4import org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue;5import org.evomaster.client.java.controller.problem.rpc.schema.params.StringParam;6import org.evomaster.client.java.controller.problem.rpc.schema.types.AccessibleSchema;7import org.evomaster.client.java.controller.problem.rpc.schema.types.StringType;8import java.util.ArrayList;9import java.util.Arrays;10import java.util.List;11import java.util.stream.Collectors;12public class LocalAuthSetupSchema extends EndpointSchema{13 public final static String EM_LOCAL_METHOD = "__EM__LOCAL__";14 public final static String HANDLE_LOCAL_AUTHENTICATION_SETUP_METHOD_NAME = "handleLocalAuthenticationSetup";15 public LocalAuthSetupSchema() {16 super(HANDLE_LOCAL_AUTHENTICATION_SETUP_METHOD_NAME,17 EM_LOCAL_METHOD, null, Arrays.asList(new StringParam("arg0", new StringType(), new AccessibleSchema())), null, null, false, null, null);18 }19 /**20 *21 * @return value of AuthenticationInfo22 */23 public String getAuthenticationInfo(){24 return ((StringParam)getRequestParams().get(0)).getValue();25 }26 @Override27 public List<String> newInvocationWithJava(String responseVarName, String controllerVarName, String clientVariable) {28 List<String> javaCode = new ArrayList<>();29 javaCode.add("{");30 int indent = 1;31 for (NamedTypedValue param: getRequestParams()){32 javaCode.addAll(param.newInstanceWithJava(indent));33 }34 String paramVars = getRequestParams().stream().map(NamedTypedValue::getName).collect(Collectors.joining(","));35 CodeJavaGenerator.addCode(36 javaCode,37 CodeJavaGenerator.methodInvocation(controllerVarName, getName(), paramVars) + CodeJavaGenerator.appendLast(),38 indent);39 javaCode.add("}");40 return javaCode;41 }42 /**43 *44 * @param dto a RPCAction dto45 * @return if the action is to local method46 */47 public static boolean isLocalAuthSetup(RPCActionDto dto){48 return dto.actionName.equals(HANDLE_LOCAL_AUTHENTICATION_SETUP_METHOD_NAME) && dto.interfaceId.equals(EM_LOCAL_METHOD) && dto.clientInfo == null;49 }50}...

Full Screen

Full Screen

Source:RPCProblemDto.java Github

copy

Full Screen

1package org.evomaster.client.java.controller.api.dto.problem;2import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCActionDto;3import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCInterfaceSchemaDto;4import org.evomaster.client.java.controller.api.dto.problem.rpc.SeededRPCTestDto;5import java.util.List;6/**7 * a dto to collect info of RPC problem to be tested8 * that is sent to core9 */10public class RPCProblemDto {11 /**12 * a list of accessible endpoints grouped by interface13 */14 public List<RPCInterfaceSchemaDto> schemas;15 /**16 * a list of actions with specified value that are used for handling auth of the SUT17 * the action refers to a method at SutController18 */19 public List<RPCActionDto> localAuthEndpoints;20 /**21 * a list of reference of the endpoints, and22 * the reference is identified based on the index where to be specified in the driver23 */24 public List<Integer> localAuthEndpointReferences;25 /**26 * a list of seeded RPC tests27 */28 public List<List<RPCActionDto>> seededTestDtos;29}...

Full Screen

Full Screen

RPCActionDto

Using AI Code Generation

copy

Full Screen

1public class 2.java {2 public static void main(String[] args) {3 RPCActionDto rpcActionDto = new RPCActionDto();4 rpcActionDto.setRpcName("rpcName");5 rpcActionDto.setParameters(new ArrayList<Object>());6 rpcActionDto.setTargetFormat("targetFormat");7 rpcActionDto.setTargetMethod("targetMethod");8 rpcActionDto.setTargetName("targetName");9 rpcActionDto.setTargetObject("targetObject");10 rpcActionDto.setTargetType("targetType");11 rpcActionDto.setTimestamp(0L);12 rpcActionDto.setIndex(0);13 rpcActionDto.setExecutionTime(0);14 rpcActionDto.setSuccessful(true);15 rpcActionDto.setBody("body");16 rpcActionDto.setHttpStatusCode(0);17 rpcActionDto.setHeaders(new ArrayList<String>());18 rpcActionDto.setResponseTime(0);19 rpcActionDto.setResponseLength(0);20 rpcActionDto.setCookies(new ArrayList<String>());21 rpcActionDto.setResponseLocation("responseLocation");22 rpcActionDto.setResponsePayload("responsePayload");23 rpcActionDto.setResponseTime(0);24 rpcActionDto.setResponseLength(0);25 rpcActionDto.setResponseLocation("responseLocation");26 rpcActionDto.setResponsePayload("responsePayload");27 rpcActionDto.setResponseTime(0);28 rpcActionDto.setResponseLength(0);29 rpcActionDto.setResponseLocation("responseLocation");30 rpcActionDto.setResponsePayload("responsePayload");31 rpcActionDto.setResponseTime(0);32 rpcActionDto.setResponseLength(0);33 rpcActionDto.setResponseLocation("responseLocation");34 rpcActionDto.setResponsePayload("responsePayload");35 rpcActionDto.setResponseTime(0);36 rpcActionDto.setResponseLength(0);37 rpcActionDto.setResponseLocation("responseLocation");38 rpcActionDto.setResponsePayload("responsePayload");39 rpcActionDto.setResponseTime(0);40 rpcActionDto.setResponseLength(0);41 rpcActionDto.setResponseLocation("responseLocation");42 rpcActionDto.setResponsePayload("responsePayload");43 rpcActionDto.setResponseTime(0);44 rpcActionDto.setResponseLength(0);45 rpcActionDto.setResponseLocation("responseLocation");46 rpcActionDto.setResponsePayload("responsePayload");47 rpcActionDto.setResponseTime(0);48 rpcActionDto.setResponseLength(0);

Full Screen

Full Screen

RPCActionDto

Using AI Code Generation

copy

Full Screen

1public class RPCActionDtoBuilder {2 public static RPCActionDto buildDto(String targetId, String methodName, Object[] parameters){3 RPCActionDto dto = new RPCActionDto();4 dto.setTargetId(targetId);5 dto.setMethodName(methodName);6 dto.setParameters(RPCActionDtoBuilder.buildParameters(parameters));7 return dto;8 }9 private static List<RPCArgumentDto> buildParameters(Object[] parameters){10 List<RPCArgumentDto> dtos = new ArrayList<>();11 for(Object p : parameters){12 dtos.add(RPCActionDtoBuilder.buildParameter(p));13 }14 return dtos;15 }16 private static RPCArgumentDto buildParameter(Object p){17 RPCArgumentDto dto = new RPCArgumentDto();18 dto.setValue(p);19 return dto;20 }21}22public class RPCActionDtoBuilder {23 public static RPCActionDto buildDto(String targetId, String methodName, Object[] parameters){24 RPCActionDto dto = new RPCActionDto();25 dto.setTargetId(targetId);26 dto.setMethodName(methodName);27 dto.setParameters(RPCActionDtoBuilder.buildParameters(parameters));28 return dto;29 }30 private static List<RPCArgumentDto> buildParameters(Object[] parameters){31 List<RPCArgumentDto> dtos = new ArrayList<>();32 for(Object p : parameters){33 dtos.add(RPCActionDtoBuilder.buildParameter(p));34 }35 return dtos;36 }37 private static RPCArgumentDto buildParameter(Object p){38 RPCArgumentDto dto = new RPCArgumentDto();39 dto.setValue(p);40 return dto;41 }42}

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.

Run EvoMaster automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in RPCActionDto

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful