How to use build method of org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam class

Best EvoMaster code snippet using org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam.build

Source:RPCEndpointsBuilder.java Github

copy

Full Screen

...122 * @param authenticationDtoList specifies a list of authentication info123 * @param customizedRequestValueDtos specifies a list of candidate values in requests124 * @return an interface schema for evomaster to access125 */126 public static InterfaceSchema build(String interfaceName, RPCType rpcType, Object client,127 List<String> skipEndpointsByName, List<String> skipEndpointsByAnnotation,128 List<String> involveEndpointsByName, List<String> involveEndpointsByAnnotation,129 List<AuthenticationDto> authenticationDtoList,130 List<CustomizedRequestValueDto> customizedRequestValueDtos,131 List<CustomizedNotNullAnnotationForRPCDto> notNullAnnotations) {132 List<EndpointSchema> endpoints = new ArrayList<>();133 List<EndpointSchema> endpointsForAuth = new ArrayList<>();134 List<String> skippedEndpoints = new ArrayList<>();135 Map<Integer, EndpointSchema> authEndpoints = new HashMap<>();136 try {137 Class<?> interfaze = Class.forName(interfaceName);138 InterfaceSchema schema = new InterfaceSchema(interfaceName, endpoints, getClientClass(client) , rpcType, skippedEndpoints, authEndpoints, endpointsForAuth);139 for (Method m : interfaze.getDeclaredMethods()) {140 if (filterMethod(m, skipEndpointsByName, skipEndpointsByAnnotation, involveEndpointsByName, involveEndpointsByAnnotation)){141 try{142 EndpointSchema endpointSchema = build(schema, m, rpcType, authenticationDtoList, customizedRequestValueDtos, notNullAnnotations);143 endpoints.add(endpointSchema);144 }catch (RuntimeException exception){145 /*146 TODO might send such log to core in order to better identify problems which is not handled yet147 */148 SimpleLogger.error("EM Driver Error: fail to handle the endpoint schema "+m.getName()+" with the error msg:"+exception.getMessage());149 }150 } else {151 skippedEndpoints.add(m.getName());152 }153 List<AuthenticationDto> auths = getAuthEndpointInInterface(authenticationDtoList, interfaceName, m);154 if (auths != null && !auths.isEmpty()){155 try{156 // handle endpoint which is for auth setup157 EndpointSchema authEndpoint = build(schema, m, rpcType, null, customizedRequestValueDtos,notNullAnnotations);158 endpointsForAuth.add(authEndpoint);159 for (AuthenticationDto auth: auths){160 EndpointSchema copy = authEndpoint.copyStructure();161 if (auth.jsonAuthEndpoint == null){162 throw new IllegalArgumentException("Driver Config Error: now we only support auth info specified with JsonAuthRPCEndpointDto");163 }164 int index = authenticationDtoList.indexOf(auth);165 // set value based on specified info166 if (copy.getRequestParams().size() != auth.jsonAuthEndpoint.jsonPayloads.size())167 throw new IllegalArgumentException("Driver Config Error: mismatched size of jsonPayloads ("+auth.jsonAuthEndpoint.classNames.size()+") with real endpoint ("+authEndpoint.getRequestParams().size()+").");168 setAuthEndpoint(copy, auth.jsonAuthEndpoint);169 authEndpoints.put(index, copy);170 }171 }catch (RuntimeException exception){172 SimpleLogger.error("EM Driver Error: fail to handle the authEndpoint schema "+m.getName()+" with the error msg:"+exception.getMessage());173 }174 }175 }176 return schema;177 } catch (ClassNotFoundException e) {178 throw new RuntimeException("cannot find the interface with the name (" + interfaceName + ") and the error message is " + e.getMessage());179 }180 }181 /**182 * build the local auth setup183 * @param authenticationDtoList a list of auth info specified by user184 * @return a map of such local auth setup185 * key - index at a list of auth info specified by user186 * value - local endpoint187 */188 public static Map<Integer, LocalAuthSetupSchema> buildLocalAuthSetup(List<AuthenticationDto> authenticationDtoList){189 if (authenticationDtoList==null || authenticationDtoList.isEmpty()) return null;190 Map<Integer, LocalAuthSetupSchema> map = new HashMap<>();191 for (AuthenticationDto dto : authenticationDtoList){192 if (dto.localAuthSetup != null){193 int index = authenticationDtoList.indexOf(dto);194 LocalAuthSetupSchema local = new LocalAuthSetupSchema();195 local.getRequestParams().get(0).setValueBasedOnInstance(dto.localAuthSetup.authenticationInfo);196 map.put(index, local);197 }198 }199 return map;200 }201 private static void setAuthEndpoint(EndpointSchema authEndpoint, JsonAuthRPCEndpointDto jsonAuthEndpoint) throws ClassNotFoundException{202 if (jsonAuthEndpoint.classNames != null && jsonAuthEndpoint.classNames.size() != jsonAuthEndpoint.jsonPayloads.size())203 throw new IllegalArgumentException("Driver Config Error: to specify inputs for auth endpoint, classNames and jsonPayloads should have same size");204 for (int i = 0; i < authEndpoint.getRequestParams().size(); i++){205 NamedTypedValue inputParam = authEndpoint.getRequestParams().get(i);206 String jsonString = jsonAuthEndpoint.jsonPayloads.get(i);207 if (jsonAuthEndpoint.classNames == null){208 setNamedValueBasedOnJsonString(inputParam,jsonString, i);209 }else{210 Class<?> clazz = Class.forName(jsonAuthEndpoint.classNames.get(i));211 try {212 Object value = objectMapper.readValue(jsonString, clazz);213 inputParam.setValueBasedOnInstance(value);214 } catch (JsonProcessingException e) {215 SimpleLogger.uniqueWarn("Driver Config Error: a jsonPayload at ("+i+") cannot be read as the object "+jsonAuthEndpoint.classNames.get(i));216 setNamedValueBasedOnJsonString(inputParam,jsonString, i);217 }218 }219 }220 }221 private static void setNamedValueBasedOnJsonString(NamedTypedValue inputParam, String jsonString, int index){222 if (inputParam instanceof StringParam || inputParam instanceof PrimitiveOrWrapperParam || inputParam instanceof ByteBufferParam){223 setNamedValueBasedOnCandidates(inputParam, jsonString);224 } else if (inputParam instanceof ObjectParam){225 try {226 JsonNode node = objectMapper.readTree(jsonString);227 List<NamedTypedValue> fields = new ArrayList<>();228 for (NamedTypedValue f: ((ObjectParam) inputParam).getType().getFields()){229 NamedTypedValue v = f.copyStructureWithProperties();230 if (node.has(v.getName())){231 setNamedValueBasedOnCandidates(f, node.textValue());232 fields.add(v);233 }else {234 SimpleLogger.uniqueWarn("Driver Config Error: cannot find field with the name "+v.getName()+" in the specified json");235 }236 }237 inputParam.setValue(fields);238 } catch (JsonProcessingException ex) {239 SimpleLogger.uniqueWarn("Driver Config Error: a jsonPayload at ("+index+") cannot be read as a JSON object with error:" +ex.getMessage());240 }241 }242 }243 private static List<AuthenticationDto> getAuthEndpointInInterface(List<AuthenticationDto> authenticationDtos, String interfaceName, Method method){244 if (authenticationDtos == null) return null;245 for (AuthenticationDto dto : authenticationDtos){246 if (dto.localAuthSetup == null && (dto.jsonAuthEndpoint == null || dto.jsonAuthEndpoint.endpointName == null || dto.jsonAuthEndpoint.interfaceName == null)){247 SimpleLogger.uniqueWarn("Driver Config Error: To specify auth for RPC, either localAuthSetup or jsonAuthEndpoint should be specified." +248 "For JsonAuthRPCEndpointDto, endpointName and interfaceName cannot be null");249 }250 }251 return authenticationDtos.stream().filter(a-> a.jsonAuthEndpoint != null252 && a.jsonAuthEndpoint.endpointName.equals(method.getName())253 && a.jsonAuthEndpoint.interfaceName.equals(interfaceName)).collect(Collectors.toList());254 }255 private static boolean filterMethod(Method endpoint,256 List<String> skipEndpointsByName, List<String> skipEndpointsByAnnotation,257 List<String> involveEndpointsByName, List<String> involveEndpointsByAnnotation){258 if (skipEndpointsByName != null && involveEndpointsByName != null)259 throw new IllegalArgumentException("Driver Config Error: skipEndpointsByName and involveEndpointsByName should not be specified at same time.");260 if (skipEndpointsByAnnotation != null && involveEndpointsByAnnotation != null)261 throw new IllegalArgumentException("Driver Config Error: skipEndpointsByAnnotation and involveEndpointsByAnnotation should not be specified at same time.");262 if (skipEndpointsByName != null || skipEndpointsByAnnotation != null)263 return !anyMatchByNameAndAnnotation(endpoint, skipEndpointsByName, skipEndpointsByAnnotation);264 if (involveEndpointsByName != null || involveEndpointsByAnnotation != null)265 return anyMatchByNameAndAnnotation(endpoint, involveEndpointsByName, involveEndpointsByAnnotation);266 return true;267 }268 private static boolean anyMatchByNameAndAnnotation(Method endpoint, List<String> names, List<String> annotations){269 boolean anyMatch = false;270 if (annotations != null){271 for (Annotation annotation : endpoint.getAnnotations()){272 anyMatch = anyMatch || annotations.contains(annotation.annotationType().getName());273 }274 }275 if (names != null)276 anyMatch = anyMatch || names.contains(endpoint.getName());277 return anyMatch;278 }279 private static String getClientClass(Object client){280 if (client == null) return null;281 String clazzType = client.getClass().getName();282 // handle com.sun.proxy283 if (!clazzType.startsWith("com.sun.proxy.")){284 return clazzType;285 }286 Class<?>[] clazz = client.getClass().getInterfaces();287 if (clazz.length == 0){288 SimpleLogger.error("Error: the client is not related to any interface");289 return null;290 }291 if (clazz.length > 1)292 SimpleLogger.error("ERROR: the client has more than one interfaces");293 return clazz[0].getName();294 }295 private static EndpointSchema build(InterfaceSchema schema, Method method, RPCType rpcType, List<AuthenticationDto> authenticationDtoList,296 List<CustomizedRequestValueDto> customizedRequestValueDtos,297 List<CustomizedNotNullAnnotationForRPCDto> notNullAnnotations) {298 List<NamedTypedValue> requestParams = new ArrayList<>();299 List<AuthenticationDto> authAnnotationDtos = getSpecificRelatedAuth(authenticationDtoList, method);300 List<Integer> authKeys = null;301 if (authAnnotationDtos != null)302 authKeys = authAnnotationDtos.stream().map(s-> authenticationDtoList.indexOf(s)).collect(Collectors.toList());303 Set<String> relatedCustomization = new HashSet<>();304 for (Parameter p : method.getParameters()) {305 requestParams.add(buildInputParameter(schema, p, rpcType, getRelatedCustomization(customizedRequestValueDtos, method), relatedCustomization, notNullAnnotations));306 }307 NamedTypedValue response = null;308 if (!method.getReturnType().equals(Void.TYPE)) {309 Map<TypeVariable, Type> genericTypeMap = new HashMap<>();310 response = build(schema, method.getReturnType(), method.getGenericReturnType(), "return", rpcType, new ArrayList<>(), null, null, null, null, null, genericTypeMap);311 }312 List<NamedTypedValue> exceptions = null;313 if (method.getExceptionTypes().length > 0){314 exceptions = new ArrayList<>();315 for (int i = 0; i < method.getExceptionTypes().length; i++){316 NamedTypedValue exception = build(schema, method.getExceptionTypes()[i],317 method.getGenericExceptionTypes()[i], "exception_"+i, rpcType, new ArrayList<>(), null, null, null, null, null, null);318 exceptions.add(exception);319 }320 }321 return new EndpointSchema(method.getName(),322 schema.getName(), schema.getClientInfo(), requestParams, response, exceptions,323 authAnnotationDtos!= null && !authAnnotationDtos.isEmpty(), authKeys, relatedCustomization);324 }325 private static List<AuthenticationDto> getSpecificRelatedAuth(List<AuthenticationDto> authenticationDtoList, Method method){326 if (authenticationDtoList == null) return null;327 List<String> annotations = Arrays.stream(method.getAnnotations()).map(s-> s.annotationType().getName()).collect(Collectors.toList());328 return authenticationDtoList.stream().filter(s->329 (s.localAuthSetup != null && s.localAuthSetup.annotationOnEndpoint != null && annotations.contains(s.localAuthSetup.annotationOnEndpoint)) ||330 (s.jsonAuthEndpoint != null && s.jsonAuthEndpoint.annotationOnEndpoint != null && annotations.contains(s.jsonAuthEndpoint.annotationOnEndpoint))331 ).collect(Collectors.toList());332 }333 private static Map<Integer, CustomizedRequestValueDto> getRelatedCustomization(List<CustomizedRequestValueDto> customizedRequestValueDtos, Method method){334 if (customizedRequestValueDtos == null) return null;335 List<String> annotations = Arrays.stream(method.getAnnotations()).map(s-> s.annotationType().getName()).collect(Collectors.toList());336 List<CustomizedRequestValueDto> list = customizedRequestValueDtos.stream().filter(337 s-> (s.annotationOnEndpoint == null || annotations.contains(s.annotationOnEndpoint)) &&338 (s.specificEndpointName == null || s.specificEndpointName.contains(method.getName()))339 ).collect(Collectors.toList());340 if (list.isEmpty()) return null;341 Map<Integer, CustomizedRequestValueDto> map = new HashMap<>();342 list.forEach(s->map.put(customizedRequestValueDtos.indexOf(s), s));343 return map;344 }345 private static NamedTypedValue buildInputParameter(InterfaceSchema schema, Parameter parameter, RPCType type,346 Map<Integer,CustomizedRequestValueDto> customizationDtos, Set<String> relatedCustomization,347 List<CustomizedNotNullAnnotationForRPCDto> notNullAnnotations) {348 String name = parameter.getName();349 Class<?> clazz = parameter.getType();350 List<String> depth = new ArrayList<>();351 Map<TypeVariable, Type> genericTypeMap = new HashMap<>();352 NamedTypedValue namedTypedValue = build(schema, clazz, parameter.getParameterizedType(), name, type, depth, customizationDtos, relatedCustomization, null, notNullAnnotations, null, genericTypeMap);353 for (Annotation annotation: parameter.getAnnotations()){354 handleConstraint(namedTypedValue, annotation, notNullAnnotations);355 }356 return namedTypedValue;357 }358 private static NamedTypedValue build(InterfaceSchema schema, Class<?> clazz, Type genericType, String name, RPCType rpcType, List<String> depth,359 Map<Integer, CustomizedRequestValueDto> customizationDtos, Set<String> relatedCustomization, AccessibleSchema accessibleSchema,360 List<CustomizedNotNullAnnotationForRPCDto> notNullAnnotations, Class<?> originalType, Map<TypeVariable, Type> genericTypeMap) {361 handleGenericSuperclass(clazz, genericTypeMap);362 List<String> genericTypes = handleGenericType(clazz, genericType, genericTypeMap);363 String clazzWithGenericTypes = CodeJavaGenerator.handleClassNameWithGeneric(clazz.getName(), genericTypes);364 depth.add(getObjectTypeNameWithFlag(clazz, clazzWithGenericTypes));365 NamedTypedValue namedValue = null;366 try{367 if (PrimitiveOrWrapperType.isPrimitiveOrTypes(clazz)) {368 namedValue = PrimitiveOrWrapperParam.build(name, clazz, accessibleSchema);369 } else if (clazz == String.class) {370 StringType stringType = new StringType();371 namedValue = new StringParam(name, stringType, accessibleSchema);372 } else if (clazz == BigDecimal.class){373 BigDecimalType bigDecimalType = new BigDecimalType();374 namedValue = new BigDecimalParam(name, bigDecimalType, accessibleSchema);375 } else if (clazz == BigInteger.class){376 BigIntegerType bigIntegerType = new BigIntegerType();377 namedValue = new BigIntegerParam(name, bigIntegerType, accessibleSchema);378 } else if (clazz.isEnum()) {379 String [] items = Arrays.stream(clazz.getEnumConstants()).map(e-> getNameEnumConstant(e)).toArray(String[]::new);380 EnumType enumType = new EnumType(clazz.getSimpleName(), clazz.getName(), items, clazz);381 EnumParam param = new EnumParam(name, enumType, accessibleSchema);382 //register this type in the schema383 schema.registerType(enumType.copy(), param.copyStructureWithProperties());384 namedValue = param;385 } else if (clazz.isArray()){386 Type type = null;387 Class<?> templateClazz = null;388 if (genericType instanceof GenericArrayType){389 type = ((GenericArrayType)genericType).getGenericComponentType();390 templateClazz = getTemplateClass(type, genericTypeMap);391 }else {392 templateClazz = clazz.getComponentType();393 }394 NamedTypedValue template = build(schema, templateClazz, type,"template", rpcType, depth, customizationDtos, relatedCustomization, null, notNullAnnotations, null, genericTypeMap);395 template.setNullable(false);396 CollectionType ctype = new CollectionType(clazz.getSimpleName(),clazz.getName(), template, clazz);397 ctype.depth = getDepthLevel(clazz, depth, clazzWithGenericTypes);398 namedValue = new ArrayParam(name, ctype, accessibleSchema);399 } else if (clazz == ByteBuffer.class){400 // handle binary of thrift401 namedValue = new ByteBufferParam(name, accessibleSchema);402 } else if (List.class.isAssignableFrom(clazz) || Set.class.isAssignableFrom(clazz)){403 if (genericType == null)404 throw new RuntimeException("genericType should not be null for List and Set class");405 Type type = ((ParameterizedType) genericType).getActualTypeArguments()[0];406 Class<?> templateClazz = getTemplateClass(type, genericTypeMap);407 NamedTypedValue template = build(schema, templateClazz, type,"template", rpcType, depth, customizationDtos, relatedCustomization, null, notNullAnnotations, null, genericTypeMap);408 template.setNullable(false);409 CollectionType ctype = new CollectionType(clazz.getSimpleName(),clazz.getName(), template, clazz);410 ctype.depth = getDepthLevel(clazz, depth, clazzWithGenericTypes);411 if (List.class.isAssignableFrom(clazz))412 namedValue = new ListParam(name, ctype, accessibleSchema);413 else414 namedValue = new SetParam(name, ctype, accessibleSchema);415 } else if (Map.class.isAssignableFrom(clazz)){416 if (genericType == null)417 throw new RuntimeException("genericType should not be null for List and Set class");418 Type keyType = ((ParameterizedType) genericType).getActualTypeArguments()[0];419 Type valueType = ((ParameterizedType) genericType).getActualTypeArguments()[1];420 Class<?> keyTemplateClazz = getTemplateClass(keyType, genericTypeMap);421 NamedTypedValue keyTemplate = build(schema, keyTemplateClazz, keyType,"keyTemplate", rpcType, depth, customizationDtos, relatedCustomization, null, notNullAnnotations, null, genericTypeMap);422 keyTemplate.setNullable(false);423 Class<?> valueTemplateClazz = getTemplateClass(valueType, genericTypeMap);424 NamedTypedValue valueTemplate = build(schema, valueTemplateClazz, valueType,"valueTemplate", rpcType, depth, customizationDtos, relatedCustomization, null, notNullAnnotations, null, genericTypeMap);425 MapType mtype = new MapType(clazz.getSimpleName(), clazz.getName(), new PairParam(new PairType(keyTemplate, valueTemplate), null), clazz);426 mtype.depth = getDepthLevel(clazz, depth, clazzWithGenericTypes);427 namedValue = new MapParam(name, mtype, accessibleSchema);428 } else if (Date.class.isAssignableFrom(clazz)){429 if (clazz == Date.class)430 namedValue = new DateParam(name, accessibleSchema);431 else432 throw new RuntimeException("NOT support "+clazz.getName()+" date type in java yet");433 } else if (Exception.class.isAssignableFrom(clazz) && clazz.getName().startsWith("java")){434 // note that here we only extract class name and message435 StringParam msgField = new StringParam("message", new AccessibleSchema(false, null, "getMessage"));436 ObjectType exceptionType = new ObjectType(clazz.getSimpleName(), clazz.getName(), Collections.singletonList(msgField), clazz, genericTypes);437 namedValue = new ObjectParam(name, exceptionType, accessibleSchema);438 } else {439 if (clazz.getName().startsWith("java")){440 throw new RuntimeException("NOT handle "+clazz.getName()+" class in java yet");441 }442 long cycleSize = depth.stream().filter(s-> s.equals(getObjectTypeNameWithFlag(clazz, clazzWithGenericTypes))).count();443 if (cycleSize == 1){444 List<NamedTypedValue> fields = new ArrayList<>();445 Map<Integer, CustomizedRequestValueDto> objRelatedCustomizationDtos = getCustomizationBasedOnSpecifiedType(customizationDtos, clazz.getName());446 // field list447 List<Field> fieldList = new ArrayList<>();448 getAllFields(clazz, fieldList, rpcType);449 for(Field f: fieldList){450 // skip final field451 if (Modifier.isFinal(f.getModifiers()))452 continue;453 if (doSkipReflection(f.getName()))454 continue;455 AccessibleSchema faccessSchema = null;456 //check accessible457 if (Modifier.isPublic(f.getModifiers())){458 faccessSchema = new AccessibleSchema();459 } else{460 // find getter and setter461 faccessSchema = new AccessibleSchema(false, findGetterOrSetter(clazz, f, false), findGetterOrSetter(clazz, f, true));462 if (faccessSchema.getterMethodName == null || faccessSchema.setterMethodName == null){463 SimpleLogger.warn("Error: skip the field "+f.getName()+" since its setter/getter is not found");464 continue;465 }466 }467 Class<?> fType = f.getType();468 Class<?> foriginalType = null;469 Type fGType = f.getGenericType();470 if (f.getGenericType() instanceof TypeVariable){471 foriginalType = f.getType();472 Type actualType = getActualType(genericTypeMap, (TypeVariable) f.getGenericType());473 if (actualType instanceof Class){474 fType = (Class<?>) actualType;475 fGType = fType;476 }else if (actualType instanceof ParameterizedType){477 fGType = actualType;478 if (((ParameterizedType) actualType).getRawType() instanceof Class<?>)479 fType = (Class<?>) ((ParameterizedType) actualType).getRawType();480 else481 throw new RuntimeException("Error: Fail to handle actual type of a generic type");482 }483 }484 NamedTypedValue field = build(schema, fType, fGType,f.getName(), rpcType, depth, objRelatedCustomizationDtos, relatedCustomization, faccessSchema, notNullAnnotations, foriginalType, genericTypeMap);485 for (Annotation annotation : f.getAnnotations()){486 handleConstraint(field, annotation, notNullAnnotations);487 }488 fields.add(field);489 }490 handleNativeRPCConstraints(clazz, fields, rpcType);491 ObjectType otype = new ObjectType(clazz.getSimpleName(), clazz.getName(), fields, clazz, genericTypes);492 otype.setOriginalType(originalType);493 otype.depth = getDepthLevel(clazz, depth, clazzWithGenericTypes);494 ObjectParam oparam = new ObjectParam(name, otype, accessibleSchema);495 schema.registerType(otype.copy(), oparam);496 namedValue = oparam;497 }else {498 CycleObjectType otype = new CycleObjectType(clazz.getSimpleName(), clazz.getName(), clazz, genericTypes);...

Full Screen

Full Screen

Source:PrimitiveOrWrapperParam.java Github

copy

Full Screen

...36 super(name, type, accessibleSchema);37 // primitive type is not nullable38 setNullable(getType().isWrapper);39 }40 public static PrimitiveOrWrapperParam build(String name, Class<?> clazz, AccessibleSchema accessibleSchema){41 if (clazz == Integer.class || clazz == int.class)42 return new IntParam(name, clazz.getSimpleName(), clazz.getName(), clazz, accessibleSchema);43 if (clazz == Boolean.class || clazz == boolean.class)44 return new BooleanParam(name, clazz.getSimpleName(), clazz.getName(), clazz, accessibleSchema);45 if (clazz == Double.class || clazz == double.class)46 return new DoubleParam(name, clazz.getSimpleName(), clazz.getName(), clazz, accessibleSchema);47 if (clazz == Float.class || clazz == float.class)48 return new FloatParam(name, clazz.getSimpleName(), clazz.getName(), clazz, accessibleSchema);49 if (clazz == Long.class || clazz == long.class)50 return new LongParam(name, clazz.getSimpleName(), clazz.getName(), clazz, accessibleSchema);51 if (clazz == Character.class || clazz == char.class)52 return new CharParam(name, clazz.getSimpleName(), clazz.getName(), clazz, accessibleSchema);53 if (clazz == Byte.class || clazz == byte.class)54 return new ByteParam(name, clazz.getSimpleName(), clazz.getName(), clazz, accessibleSchema);...

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1package org.evomaster.client.java.controller.problem.rpc.schema.params;2import org.evomaster.client.java.controller.problem.rpc.RpcCallAction;3import org.evomaster.client.java.controller.problem.rest.param.Param;4import org.evomaster.client.java.controller.problem.rest.param.ParamBuilder;5import org.evomaster.client.java.controller.problem.rest.param.ParamType;6import java.util.List;7import java.util.Map;8import java.util.Objects;9public class PrimitiveOrWrapperParam extends Param {10 public PrimitiveOrWrapperParam(String name, ParamType type) {11 super(name, type);12 }13 public PrimitiveOrWrapperParam(String name, ParamType type, boolean required) {14 super(name, type, required);15 }16 public Object getValueAsObject() {17 return null;18 }19 public boolean isBodyParam() {20 return false;21 }22 public boolean isHeaderParam() {23 return false;24 }25 public boolean isPathParam() {26 return false;27 }28 public boolean isQueryOrFormParam() {29 return false;30 }31 public boolean isPrimitiveOrWrapper() {32 return true;33 }34 public boolean isFileParam() {35 return false;36 }37 public boolean isMultipartParam() {38 return false;39 }40 public boolean isJsonParam() {41 return false;42 }43 public boolean isXmlParam() {44 return false;45 }46 public boolean isPrimitiveOrWrapperArray() {47 return false;48 }49 public boolean isEnum() {50 return false;51 }52 public boolean isEnumArray() {53 return false;54 }55 public boolean isString() {56 return false;57 }58 public boolean isStringArray() {59 return false;60 }61 public boolean isByteArray() {62 return false;63 }64 public boolean isIntArray() {65 return false;66 }67 public boolean isLongArray() {68 return false;69 }70 public boolean isFloatArray() {71 return false;72 }73 public boolean isDoubleArray() {

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1package org.evomaster.client.java.controller.problem.rpc.schema.params;2import com.fasterxml.jackson.databind.JsonNode;3import com.fasterxml.jackson.databind.ObjectMapper;4import org.evomaster.client.java.controller.problem.ProblemInfo;5import org.evomaster.client.java.controller.problem.RestProblem;6import org.evomaster.client.java.controller.problem.rpc.RpcCallResult;7import org.evomaster.client.java.controller.problem.rpc.RpcCallResultAction;8import org.evomaster.client.java.controller.problem.rpc.RpcCallResultActionResult;9import org.evomaster.client.java.controller.problem.rpc.RpcCallResultResult;10import org.evomaster.client.java.controller.problem.rpc.schema.RpcSchemaProblem;11import java.util.ArrayList;12import java.util.Arrays;13import java.util.List;14import java.util.Map;15public class PrimitiveOrWrapperParam extends RpcSchemaProblem {16 public PrimitiveOrWrapperParam() {17 }18 public RpcCallResult invoke(RpcCallResultAction action) {19 String body = action.getBody();20 String path = action.getPath();21 String method = action.getMethod();22 Map<String, List<String>> headers = action.getHeaders();23 List<String> pathParams = action.getPathParams();24 Map<String, List<String>> queryParams = action.getQueryParams();25 Map<String, List<String>> formParams = action.getFormParams();26 Map<String, List<String>> cookieParams = action.getCookieParams();27 String contentType = action.getContentType();28 String accept = action.getAccept();29 if (path.equals("/primitiveOrWrapperParam") && method.equals("POST")) {30 if (contentType != null && contentType.equals("application/json") && accept != null && accept.equals("application/json")) {31 try {32 ObjectMapper mapper = new ObjectMapper();33 JsonNode root = mapper.readTree(body);34 if (root.isArray()) {35 if (root.size() != 2) {36 return new RpcCallResultResult(400, "Bad Request", "{\"message\":\"Invalid request body\"}");37 }

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1public class 2 {2 public static PrimitiveOrWrapperParam build() {3 PrimitiveOrWrapperParam primitiveOrWrapperParam = new PrimitiveOrWrapperParam();4 primitiveOrWrapperParam.setPrimitiveOrWrapper(0);5 return primitiveOrWrapperParam;6 }7}8public class 3 {9 public static PrimitiveOrWrapperParam build() {10 PrimitiveOrWrapperParam primitiveOrWrapperParam = new PrimitiveOrWrapperParam();11 primitiveOrWrapperParam.setPrimitiveOrWrapper(0);12 return primitiveOrWrapperParam;13 }14}15public class 4 {16 public static PrimitiveOrWrapperParam build() {17 PrimitiveOrWrapperParam primitiveOrWrapperParam = new PrimitiveOrWrapperParam();18 primitiveOrWrapperParam.setPrimitiveOrWrapper(0);19 return primitiveOrWrapperParam;20 }21}22public class 5 {23 public static PrimitiveOrWrapperParam build() {24 PrimitiveOrWrapperParam primitiveOrWrapperParam = new PrimitiveOrWrapperParam();25 primitiveOrWrapperParam.setPrimitiveOrWrapper(0);26 return primitiveOrWrapperParam;27 }28}29public class 6 {30 public static PrimitiveOrWrapperParam build() {31 PrimitiveOrWrapperParam primitiveOrWrapperParam = new PrimitiveOrWrapperParam();32 primitiveOrWrapperParam.setPrimitiveOrWrapper(0);33 return primitiveOrWrapperParam;34 }35}36public class 7 {37 public static PrimitiveOrWrapperParam build() {38 PrimitiveOrWrapperParam primitiveOrWrapperParam = new PrimitiveOrWrapperParam();39 primitiveOrWrapperParam.setPrimitiveOrWrapper(0);40 return primitiveOrWrapperParam;41 }42}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1public class 2 {2 public static void main(String[] args) {3 PrimitiveOrWrapperParam param = PrimitiveOrWrapperParam.build("boolean", "true");4 param = PrimitiveOrWrapperParam.build("byte", "1");5 param = PrimitiveOrWrapperParam.build("short", "1");6 param = PrimitiveOrWrapperParam.build("int", "1");7 param = PrimitiveOrWrapperParam.build("long", "1");8 param = PrimitiveOrWrapperParam.build("float", "1.0");9 param = PrimitiveOrWrapperParam.build("double", "1.0");10 param = PrimitiveOrWrapperParam.build("char", "a");11 }12}13public class 3 {14 public static void main(String[] args) {15 PrimitiveOrWrapperParam param = PrimitiveOrWrapperParam.build("boolean", "true");16 param = PrimitiveOrWrapperParam.build("byte", "1");17 param = PrimitiveOrWrapperParam.build("short", "1");18 param = PrimitiveOrWrapperParam.build("int", "1");19 param = PrimitiveOrWrapperParam.build("long", "1");20 param = PrimitiveOrWrapperParam.build("float", "1.0");21 param = PrimitiveOrWrapperParam.build("double", "1.0");22 param = PrimitiveOrWrapperParam.build("char", "a");23 }24}25public class 4 {26 public static void main(String[] args) {27 PrimitiveOrWrapperParam param = PrimitiveOrWrapperParam.build("boolean", "true");28 param = PrimitiveOrWrapperParam.build("byte", "1");29 param = PrimitiveOrWrapperParam.build("short", "1");30 param = PrimitiveOrWrapperParam.build("int", "1");31 param = PrimitiveOrWrapperParam.build("long", "1");32 param = PrimitiveOrWrapperParam.build("float", "1.0");33 param = PrimitiveOrWrapperParam.build("double", "1.0");34 param = PrimitiveOrWrapperParam.build("char", "a");35 }36}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1public class 2 {2 public static void main(String[] args) {3 PrimitiveOrWrapperParam param = PrimitiveOrWrapperParam.build();4 param.setPrimitive("primitive");5 param.setWrapper("wrapper");6 param.setPrimitiveArray(new String[]{"primitiveArray"});7 param.setWrapperArray(new String[]{"wrapperArray"});8 param.setPrimitiveList(new ArrayList<>(Arrays.asList("primitiveList")));9 param.setWrapperList(new ArrayList<>(Arrays.asList("wrapperList")));10 param.setPrimitiveSet(new HashSet<>(Arrays.asList("primitiveSet")));11 param.setWrapperSet(new HashSet<>(Arrays.asList("wrapperSet")));12 param.setPrimitiveMap(new HashMap<String, String>() {{13 put("primitiveMapKey", "primitiveMapValue");14 }});15 param.setWrapperMap(new HashMap<String, String>() {{16 put("wrapperMapKey", "wrapperMapValue");17 }});18 param.setPrimitiveArrayArray(new String[][]{new String[]{"primitiveArrayArray"}});19 param.setWrapperArrayArray(new String[][]{new String[]{"wrapperArrayArray"}});20 param.setPrimitiveListArray(new List[]{new ArrayList<>(Arrays.asList("primitiveListArray"))});21 param.setWrapperListArray(new List[]{new ArrayList<>(Arrays.asList("wrapperListArray"))});22 param.setPrimitiveSetArray(new Set[]{new HashSet<>(Arrays.asList("primitiveSetArray"))});23 param.setWrapperSetArray(new Set[]{new HashSet<>(Arrays.asList("wrapperSetArray"))});24 param.setPrimitiveMapArray(new Map[]{new HashMap<String, String>() {{25 put("primitiveMapArrayKey", "primitiveMapArrayValue");26 }}});27 param.setWrapperMapArray(new Map[]{new HashMap<String, String>() {{28 put("wrapperMapArrayKey", "wrapperMapArrayValue");29 }}});30 param.setPrimitiveListList(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("primitiveListList")))));31 param.setWrapperListList(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("wrapperListList")))));32 param.setPrimitiveSetList(new ArrayList<>(Arrays.asList(new HashSet<>(Arrays.asList("primitiveSetList")))));33 param.setWrapperSetList(new ArrayList<>(Arrays.asList(new HashSet<>(Arrays.asList("wrapperSetList")))));34 param.setPrimitiveMapList(new ArrayList<>(Arrays.asList(new HashMap<String, String>() {{35 put("primitiveMapListKey", "primitiveMapListValue");36 }})));37 param.setWrapperMapList(new ArrayList<>(Arrays.asList(new HashMap<String, String>() {{

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1public class Test_2 {2 public static void main(String[] args) {3 PrimitiveOrWrapperParam param0 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");4 PrimitiveOrWrapperParam param1 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");5 PrimitiveOrWrapperParam param2 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");6 PrimitiveOrWrapperParam param3 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");7 PrimitiveOrWrapperParam param4 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");8 PrimitiveOrWrapperParam param5 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");9 PrimitiveOrWrapperParam param6 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");10 PrimitiveOrWrapperParam param7 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");11 PrimitiveOrWrapperParam param8 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");12 PrimitiveOrWrapperParam param9 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");13 PrimitiveOrWrapperParam param10 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");14 PrimitiveOrWrapperParam param11 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");15 PrimitiveOrWrapperParam param12 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");16 PrimitiveOrWrapperParam param13 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");17 PrimitiveOrWrapperParam param14 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");18 PrimitiveOrWrapperParam param15 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");19 PrimitiveOrWrapperParam param16 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");20 PrimitiveOrWrapperParam param17 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");21 PrimitiveOrWrapperParam param18 = PrimitiveOrWrapperParam.build(PrimitiveOrWrapperParam.Type.BOOLEAN, "true");

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam param2 = org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam.build(java.lang.Integer.class);2param2.setIntField(null);3org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam param3 = org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam.build(java.lang.Integer.class);4param3.setIntField(null);5org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam param4 = org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam.build(java.lang.Long.class);6param4.setLongField(null);7org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam param5 = org.evomaster.client.java.controller.problem.rpc.schema.params.PrimitiveOrWrapperParam.build(java.lang.Long.class);

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