### Question:
RescriptOperationBinding { public Object[] resolveArgs(HttpServletRequest request, InputStream inputStream, MediaType mediaType, String encoding) { Object[] args = new Object[paramBindings.length]; String format = mediaType == null || mediaType.getSubtype() == null ? "unknown" : mediaType.getSubtype(); RescriptBody body = null; if (bindingDescriptor.containsBodyData()) { if (!request.getMethod().equals("POST")) { throw CougarMarshallingException.unmarshallingException(format, "Bad body data", false); } body = resolveBody(inputStream, mediaType, encoding); } Set<String> headersWithNullValues = new HashSet<>(); Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String header = headerNames.nextElement(); if (request.getHeader(header) == null) { headersWithNullValues.add(header.toLowerCase()); } } try { for (int i = 0; i < args.length; ++i) { RescriptParamBindingDescriptor descriptor = paramBindings[i]; Parameter param = operationDefinition.getParameters()[i]; switch (descriptor.getSource()) { case HEADER : String key = descriptor.getName(); args[i] = resolveArgument(headersWithNullValues.contains(key.toLowerCase()) ? "" : request.getHeader(key), param, descriptor, format); break; case QUERY : args[i] = resolveArgument(request.getParameter(descriptor.getName()), param, descriptor, format); break; case BODY : if (body != null) { args[i] = body.getValue(descriptor.getName()); if (param.getParameterType().getType() == ParameterType.Type.ENUM) { if (args[i] != null) { args[i] = EnumUtils.readEnum(param.getParameterType().getImplementationClass(), (String) args[i]); } } } break; default : throw new PanicInTheCougar("Unsupported argument annotation "+ descriptor.getSource()); } } } catch (EnumDerialisationException ede) { throw CougarMarshallingException.unmarshallingException(format, ede.getMessage(), ede.getCause(), false); } return args; } RescriptOperationBinding(RescriptOperationBindingDescriptor bindingDescriptor, OperationDefinition opDef, boolean hardFailEnums); String getMethod(); OperationKey getOperationKey(); RescriptOperationBindingDescriptor getBindingDescriptor(); Object[] resolveArgs(HttpServletRequest request, InputStream inputStream, MediaType mediaType, String encoding); Object resolveArgument(String value, Parameter param, RescriptParamBindingDescriptor descriptor, String format); RescriptBody resolveBody(InputStream inputStream, MediaType mediaType, String encoding); @Override String toString();  }### Answer:
@Test public void testResolveArgsWithValidQueryStringParams() { when(mockedRequest.getParameter("stringParam")).thenReturn("Hello world"); when(mockedRequest.getParameter("floatParam")).thenReturn("3.21"); when(mockedRequest.getParameter("longParam")).thenReturn("93828123111"); when(mockedRequest.getParameter("stringBodyParam")).thenReturn("is it home time yet?"); Object[] resolvedArguments = operationSimpleGetBinding.resolveArgs(mockedRequest, null, MediaType.APPLICATION_JSON_TYPE, "utf-8"); assertTrue(resolvedArguments[0] instanceof String); int i=0; assertEquals("Hello world", (String)resolvedArguments[i++]); assertEquals(3.21f, (Float)resolvedArguments[i++]); assertEquals(93828123111L, ((Long)resolvedArguments[i++]).longValue()); }
@Test public void testResolveArgsWithInvalidQueryStringParams() { when(mockedRequest.getParameter("stringParam")).thenReturn("Hello world"); when(mockedRequest.getParameter("floatParam")).thenReturn("thisaintnevergonnaparse"); when(mockedRequest.getParameter("longParam")).thenReturn("93828123111"); try { Object[] resolvedArguments = operationSimpleGetBinding.resolveArgs(mockedRequest, null, MediaType.APPLICATION_JSON_TYPE, "utf-8"); fail("A validation exception should have occurred due to an invalid float argument"); } catch (CougarMarshallingException expected) { } }