String modification in APIGEE edge without using Javascript - apigee

I was wondering on there was an keyword like lower() in apigee edge to change the value to lowercase to check in conditional flow
http://api.com/{uriparam}?Action=Lower
lower(request.queryparam.Action) == "lower"
is there any way to achieve this without using any java script?

Apigee has its own operator for doing case insensitive matching. So you can just use := instead of == and it will match your example.
request.queryparam.Action := "lower"
Also see the conditions reference from the Apigee documentation: https://docs.apigee.com/api-platform/reference/conditions-reference#operators

Related

How to use Pact Matcher for values other than 'Strings'

In pact-jvm (groovy on consumer side and gradle on the provider side), I'm trying to use Pact matchers like below:
name regexp(~/\w+/,'sony')
Will Pact matcher regex work only for Strings ? For values other than strings, do I need to use Pact term ?
If the answer is 'yes' for the above two questions. Please explain me how to use Pact term in groovy style.
I have tried using Pact term like below:
date Pact.Term(generate :"02/11/2013", matcher:/\d{2}\/\d{2}\/\d{4}/)
But getting groovy - MethodMissingException.
My complete response body for reference:
withBody {
id regexp('[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}','e8cda07e-849f-49c2-94d6-aaa5c4ab7fcd')
name regexp(~/\w+/,'sony')
date Pact.Term(generate :"02/11/2013", matcher:/\d{2}\/\d{2}\/\d{4}/)
}
Regex only applies to strings.
If you want to match a date, I'd suggest using the date matcher, e.g.
withBody {
id regexp('[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}','e8cda07e-849f-49c2-94d6-aaa5c4ab7fcd')
name regexp(~/\w+/,'sony')
date date("dd/MM/yyyy", "02/11/2013")
}
See the available DSL methods https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-groovy#dsl-methods-1

Jmeter how to get the dynamic parameter value in the path

JMeter path contents some dynamically generated value.
Eg
[HTTP Request]
[path-home/user?p=er3562]
This "p" value is dynamically generated.
I want to get this parameter value in the first HTTP request path.
This parameter value should pass through each HTTP request path.
I am new to JMeter. Please help me to solve this?
You need to extract it somehow and convert into a JMeter Variable for later reuse. JMeter provides several PostProcessors for extracting data from different responses types, in your case the most suitable one will be Regular Expression Extractor.
Add Regular Expression Extractor as a child of the request which returns that path-home/user?p=er3562 value
Configure it as follows:
Apply to: depending on where the "interesting" value lives, the most "safe" setting is Main sample and sub-samples
Field to check: depending on where the "interesting" value comes from, in the majority of cases it's Body but in your case it may be i.e. URL
Reference Name: anything meaningful, it is JMeter Variable name, if JMeter finds anything it will store the result in a variable named accordingly to this field. I.e. path-home
Regular Expression: Perl5-style regular expression, in your case it would be something like: path-home/user\?p=er(\d+)
Template: if you're looking to extract a single value it will be $1$
Refer extracted value as ${path-home} where required.
References and tips:
You can use Debug Sampler and View Results Tree listener combination to view JMeter Variable names and test regular expressions against actual response
Using RegEx (Regular Expression Extractor) With JMeter
Perl 5 Regex Cheat sheet
JMeter Regular Expressions
By using correlation concept ,
regular expression extractor concept & try this key
p=er(.*?)

How is the || operator used in CSS?

CSS3 added the <column-token> operator as follow:
<column-token>: ||
It also says:
<column-token> has been added, to keep Selectors parsing in single-token lookahead.
So, is that just an artifact of the lexer, or is that an actual operator used for something I do not know about yet?
CSS level 4 does in fact have a column operator (used to select table cells of a column).
No idea if that's related and the token was added to CSS3 to be forward-compatile - it would be strange, but then the naming does not sound coincidental. The argument for the new token was indeed parsing convenience:
I just added a COLUMN token to the Syntax draft, matching "||". It's
needed for Selectors, so it can maintain LL(1). (Otherwise, seeing
"*" followed by "|" is ambiguous until you look at the next token.)
Which I admit I don't quite understand. What else could *| be interpreted as, even in CSS4? There is no other valid use of | in a selector (except inside an attribute matcher, but there there is no valid use for ||). CSS4 Values uses both *, | and || but that's not the spec the email was referring to.
This is not strictly a CSS3 feature, column-token is just one of many tokens used to parse currently interpreted CSS stylesheet by CSS parser. So it has no use for you unless you're implementing a CSS parser.

JavaCC match token group

I ended up writing a parser for a small subset of SQL.
The grammar has a lot of regular tokens (SELECT, CREATE, ...) and a few more general (e.g. S_GEN_IDENTIFIER matches [A-Z_.\d]|\"(~[\n, \r, \"])*\").
The problem is, "SELECT col AS type ..." doesn't get parsed since instead of <S_GEN_IDENTIFIER> "type" column alias is matched as <T_TYPE>.
I had an idea to replace token with a rule with the same name and check is the token of interest lies within some token range (something like [<T_AS> - <T_KEEP_DUPLICATES>]. Unfortunately it turned out that the syntax for tokens and rules differs so I can't do it.
I could just copy-paste all tokens inside the new rule but I don't want to do it for obvious reasons.
Is there any way to check if token lies within the range of predefined tokens?
Perhaps you could treat "type" as an unreserved keyword. Then you can follow the advice of question 4.19 of the FAQ
http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc4.19

OData and case sensitivity

I've been messing with the OData and realized that URIs are case sensitive. .../Northwind.svc/Products != .../Northwind.svc/products
Is this done on purpose? is there a way to make it case insensitive?
The recommended solution is to either use the supported OData functions toupper or tolower to work out the case sensitivity issues (when using a filter$ command) and get the full result set.
I wrote a brief post explaining this a bit further in detail:
Dealing With Case Sensitivity in OData
Here's an example:
/people?$filter=tolower(Name) eq tolower('jAmes') -
This would return you all people with name is 'James' (case insensitive, could be 'JAMES', 'james', 'JamES', etc.
Hope this will help

Resources