_import java.net.*
// Match based on query parameter
def queryString = mockRequest.getRequest()getQueryString();
def paramMap = queryString.split('&').collectEntries { param ->
param.split(‘=’).collect { URLDecoder.decode(it) }
}
//def paramCount = paramMap.size()
if( queryString == null)
{
log.info “400 bad request - no parameters”;
return “400 bad request - no parameters”;
}
else if( queryString.contains(” “))
{
log.info “400 bad request - queryString not correctly encoded”;
return “400 bad request - queryString not correctly encoded”;
}
else if( paramMap.size() > 1)
{
log.info “400 bad request - too many parameters”;
return “400 bad request - too many parameters”;
}
else if( paramMap[‘q’] == null)
{
log.info “400 bad request - wrong variable name”;
return “400 bad request - wrong variable name”;
}
else if( paramMap[‘q’] != null)
{
log.info paramMap[‘q’];
log.info “OK”;
return “OK”;
}
else
{
return “400 bad request - general”;
}
_