I have this command which is sent by a client to antlr: "GET CUSTOMER ID 1234"
Required:
Parse complete command string to ensure it is valid (For example, if
antlr receives "GET CUSTOMER 1234", it should throw error.
After parsing the complete command, return only ID ("1234")
Is this possible in antlr? If yes, how?
Related
I am new in the logic app. I want develop one new logic app when message received from topic content data couldn't parse as json , its throwing error like **"
InvalidJSON. The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing value: e. Path '', line 0, position 0.'
."**
after decode my string my json like below
{"Id":"ddd9cc1e-8e41-4684-be2e-cd874398e209","Type":"userData","Content":[{"EmpId":1,"EmpName":"Raja1"},{"EmpId":2,"EmpName":"Raja2"}]}
Any one suggest whats wrong am doing here? Attached some screenshot for reference.
enter image description here
enter image description here
As you are trying to convert an xml to json. You are very close - only issue is #json() expects either
A string that is a valid JSON object.
An application/xml object to convert to JSON.
The #base64toString() is converting to a string, but you really need to let #json() know this is #2 and not #1, so changing expression to this should work:
#{json(xml(base64toBinary(triggerBody()[contentdata])))[foo]}
I have a PowerShell script that pulls data from a DLL. The DLL returns the first 3000 characters of the JSON. Most of the time this is fine, because the complete json is less than 3000 characters. However, if a row returns a longer json I only get the first 3000 characters.
If I have a json that hit the cap and I run:
$myString = $returnedArray[$currentrow] | ConvertFrom-Json
I get:
ConvertFrom-Json : Unterminated string passed in. (3000):
The proper fix would be to deal with the source that is truncating the JSON. However, I don't have access to that source code (owned by a third party company).
Now that I have the output is this a question of just adding a string terminator? Or do I have to parse the JSON myself, figure out what it needs to correctly end the current field, and add it?
I have been trying various things to terminate the JSON string, but none have worked. For the moment my PowerShell script is simply skipping any row that fails the ConvertFrom-Json line.
You will need to parse the JSON string yourself and keep track of any strings or nested values so you can properly terminate them once you stop receiving the values.
Here is a short example of some Json that will be hard to terminate without tracking it in the first place.
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
I've created a Swagger (on nodejs/express) test API with this specification (only relevant part):
...
parameters:
- name: name
in: query
required: true
type: string
...
But I can call the url with empty paramter, for example
http://localhost/test?name=
And it works without any problem, throws no exception or any other sign. Why?
If I make a similar call from the terminal via curl or via postman, it works as well. I parsed the query from the request object and found that in this case, the query parameter is interpreted as an empty string.
Making the call via SwaggerUI is different though, as the UI will actually not make the call UNLESS the query field has a value.
Try doing console.log(req.query); in your handler. You will probably see {name: ''}. Which is legitimate, just that the value of name is an empty string.
Look at JSON4 here: Representing null in JSON. So name IS defined, but it's empty.
You will probably need to do a check for empty string values.
I hope this helps!
I have created a script in JMeter where it fetches Login credentials from CSV.
UserName: pshah
Password: Welcome&1
When I execute the script, I can see value in POST as:
UserName: pshah
But Password: Welcome
I would like to know why "&" is ignored from CSV.
In Http Request element, in parameters table check the encode checkbox as & is a reserved character in HTTP request.
Note you can debug by using a DebugSampler and replace name by ${UserName},${Password} where UserName and Password are your variable names. Use a View Results Tree to see if the issue is in loading the CSV or somewhere else
It appears there's a bug in the HTTP Renderer of the Request. As & is a separator of HTTP Request, it appears JMeter decodes the encoded value "Welcome%261" before showing parameters, this leads to presence of 1 parameter:
While the RAW one is OK:
So it's just a Display issue in HTTP renderer , you can ignore it as RAW shows the correct request is sent.
I opened bug:
https://bz.apache.org/bugzilla/show_bug.cgi?id=58413
For some reason, the 1 in the password Welcome&1 is showing up in the parameter name in the View result tree.
Check the values of userName and Password in the raw tab of View Result Tree in Jmeter ,which correctly shows Welcome&1
Check the response of your request, If it is successful then the username and password are passed correctly.
Is it possible to specify some kind of "OR" (alternative) clause in Cucumber?
I.e. if I have two valid responses to some event I would like my test to pass if either of them happens.
Something like that:
"When I press a button"
"Then I should see the text 'Boo'"
"Or I should see the text 'Foo'"
My particular scenario is a login screen. When I try to log in with some random password, I should see an error message "invalid password" if the server is working or a message "network error" if it is not.
You can't really define OR functionality using the Gherkin but you can pass in a list and check that one of the values in the list matches what was returned.
Define list:
Then the greeting service response will contain one of the following messages
|Hello how are you doing?|
|Welcome to the front door!|
|How has your day been?|
|Come right on in!|
Check list:
#Then("the get messages service response will contain one of the following messages")
public void text_matching_one_of_the_following(List<String> greetingMessages){
boolean success = false;
for(String message : greetingMessages){
assertTrue(textMatchesResponse(message));
}
}
OR is not supported. You can use Given, When, Then, And and But. Please refer to http://docs.behat.org/en/v2.5/guides/1.gherkin.html
But perhaps you could make use of the But keyword to achieve what you are looking for.