@Test public void testQueryParmConstructionWithNullsNonMandatoryParams() { when(mockParamBindingDescriptor.getSource()).thenReturn(ParamSource.QUERY); when(mockOperationBinding.getHttpParamBindingDescriptor("PARAMETER")).thenReturn(mockParamBindingDescriptor); Message message = mb.build(new Object[0], mockParameters, mockOperationBinding); assertNotNull(message); assertEquals(0, message.getHeaderMap().size()); assertEquals(0, message.getRequestBodyMap().size()); assertEquals(0, message.getQueryParmMap().size()); }
public Message build(Object[] args, Parameter[] parameters, RescriptOperationBindingDescriptor operationBinding) { int argIndex = 0; Message message = new Message(); for (Parameter param : parameters) { String parameterName = param.getName(); RescriptParamBindingDescriptor paramDescriptor = operationBinding.getHttpParamBindingDescriptor(parameterName); ParamSource parameterSource = paramDescriptor.getSource(); Object currentArgument = null; if (argIndex < args.length) { currentArgument = args[argIndex++]; } if (param.isMandatory() && currentArgument == null) { throw new CougarValidationException(ServerFaultCode.MandatoryNotDefined,"MANDATORY parameter cannot be null: " + parameterName); } switch (parameterSource) { case BODY: message.addRequestBody(parameterName, currentArgument); break; case HEADER: if (currentArgument != null) { message.addHeaderParm(parameterName, currentArgument.toString()); } break; case QUERY: if (currentArgument != null) { message.addQueryParm(parameterName, currentArgument); } break; default: throw new UnsupportedOperationException(parameterSource + " is not supported"); } } return message; }
MessageBuilder { public Message build(Object[] args, Parameter[] parameters, RescriptOperationBindingDescriptor operationBinding) { int argIndex = 0; Message message = new Message(); for (Parameter param : parameters) { String parameterName = param.getName(); RescriptParamBindingDescriptor paramDescriptor = operationBinding.getHttpParamBindingDescriptor(parameterName); ParamSource parameterSource = paramDescriptor.getSource(); Object currentArgument = null; if (argIndex < args.length) { currentArgument = args[argIndex++]; } if (param.isMandatory() && currentArgument == null) { throw new CougarValidationException(ServerFaultCode.MandatoryNotDefined,"MANDATORY parameter cannot be null: " + parameterName); } switch (parameterSource) { case BODY: message.addRequestBody(parameterName, currentArgument); break; case HEADER: if (currentArgument != null) { message.addHeaderParm(parameterName, currentArgument.toString()); } break; case QUERY: if (currentArgument != null) { message.addQueryParm(parameterName, currentArgument); } break; default: throw new UnsupportedOperationException(parameterSource + " is not supported"); } } return message; } }
MessageBuilder { public Message build(Object[] args, Parameter[] parameters, RescriptOperationBindingDescriptor operationBinding) { int argIndex = 0; Message message = new Message(); for (Parameter param : parameters) { String parameterName = param.getName(); RescriptParamBindingDescriptor paramDescriptor = operationBinding.getHttpParamBindingDescriptor(parameterName); ParamSource parameterSource = paramDescriptor.getSource(); Object currentArgument = null; if (argIndex < args.length) { currentArgument = args[argIndex++]; } if (param.isMandatory() && currentArgument == null) { throw new CougarValidationException(ServerFaultCode.MandatoryNotDefined,"MANDATORY parameter cannot be null: " + parameterName); } switch (parameterSource) { case BODY: message.addRequestBody(parameterName, currentArgument); break; case HEADER: if (currentArgument != null) { message.addHeaderParm(parameterName, currentArgument.toString()); } break; case QUERY: if (currentArgument != null) { message.addQueryParm(parameterName, currentArgument); } break; default: throw new UnsupportedOperationException(parameterSource + " is not supported"); } } return message; }  }
MessageBuilder { public Message build(Object[] args, Parameter[] parameters, RescriptOperationBindingDescriptor operationBinding) { int argIndex = 0; Message message = new Message(); for (Parameter param : parameters) { String parameterName = param.getName(); RescriptParamBindingDescriptor paramDescriptor = operationBinding.getHttpParamBindingDescriptor(parameterName); ParamSource parameterSource = paramDescriptor.getSource(); Object currentArgument = null; if (argIndex < args.length) { currentArgument = args[argIndex++]; } if (param.isMandatory() && currentArgument == null) { throw new CougarValidationException(ServerFaultCode.MandatoryNotDefined,"MANDATORY parameter cannot be null: " + parameterName); } switch (parameterSource) { case BODY: message.addRequestBody(parameterName, currentArgument); break; case HEADER: if (currentArgument != null) { message.addHeaderParm(parameterName, currentArgument.toString()); } break; case QUERY: if (currentArgument != null) { message.addQueryParm(parameterName, currentArgument); } break; default: throw new UnsupportedOperationException(parameterSource + " is not supported"); } } return message; }  Message build(Object[] args,
			Parameter[] parameters,
			RescriptOperationBindingDescriptor operationBinding); }
MessageBuilder { public Message build(Object[] args, Parameter[] parameters, RescriptOperationBindingDescriptor operationBinding) { int argIndex = 0; Message message = new Message(); for (Parameter param : parameters) { String parameterName = param.getName(); RescriptParamBindingDescriptor paramDescriptor = operationBinding.getHttpParamBindingDescriptor(parameterName); ParamSource parameterSource = paramDescriptor.getSource(); Object currentArgument = null; if (argIndex < args.length) { currentArgument = args[argIndex++]; } if (param.isMandatory() && currentArgument == null) { throw new CougarValidationException(ServerFaultCode.MandatoryNotDefined,"MANDATORY parameter cannot be null: " + parameterName); } switch (parameterSource) { case BODY: message.addRequestBody(parameterName, currentArgument); break; case HEADER: if (currentArgument != null) { message.addHeaderParm(parameterName, currentArgument.toString()); } break; case QUERY: if (currentArgument != null) { message.addQueryParm(parameterName, currentArgument); } break; default: throw new UnsupportedOperationException(parameterSource + " is not supported"); } } return message; }  Message build(Object[] args,
			Parameter[] parameters,
			RescriptOperationBindingDescriptor operationBinding);  }