I'm testing a Spring controller which can give back a 400 with field errors. These field errors is an array of objects containing a "path" and "message" field.
Now I want to test that some specific call returns multiple errors with specific path and message.
I cannot come to anything closer then below:
.andExpect(jsonPath("$.fieldErrors[*].path", containsInAnyOrder("title", "description")))
.andExpect(jsonPath("$.fieldErrors[*].message", containsInAnyOrder(
"The maximum length of the description is 500 characters.",
"The maximum length of the title is 100 characters.")));
But this keeps the option open that bad combinations of "path" and "message" is accepted.
Any ideas how to improve the jsonpath to test this?
This seems to the better approach:
.andExpect(jsonPath('$.fieldErrors[?(#.path == \'title\' && #.message == \'The maximum length of the title is 100 characters.\')]').exists())
Just expanding on the answer provided by Marcel, as it helped me solve the same issue but I had to modify slightly. I found that the '&&' operator wasn't supported in the version of jsonpath we currently use in one project (0.8.1), according to this issue it was marked as 'done' on Dec 8th which implies it should be available in the latest version, 2.0:
JSON Path issue 27 - AND operators
The 'old' syntax for logical AND which I ended up using is also shown on that issue and using the example above would be:
.andExpect(jsonPath('$.fieldErrors[?(#.path == \'title\')][?(#.message == \'The maximum length of the title is 100 characters.\')]').exists())
You can use org.hamcrest.Matchers.containsInAnyOrder().
.andExpect(jsonPath("$.fieldErrors[*].path", Matchers.contains("str1", "str2")))
Related
Team,
Occasionally my flow fails and its enough test it manually to running again. However, I want to avoid that this error ocurrs again to stay in calm.
The error that appears is this:
Unable to process template language expressions in action 'Periodo' inputs at line '0' and column '0': 'The template language function 'split' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#split for usage details.'.
And it appears in 2 of the 4 variables that I create:
Client and Periodo
The variable Clientlooks this:
The same scenario to "Periodo".
The variables are build in the same way:
His formula:
trim(first(split(first(skip(split(outputs('Compos'),'client = '),1)),'indicator')))
His formula:
trim(first(split(first(skip(split(outputs('Compos'),'period = '),1)),'DATA_REPORT_DELIVERY')))
The same scenario to the 4 variables. 4 of them strings (numbers).
Also I attached email example where I extract the info:
CO NIV ICE REFRESCOS DE SOYA has finished successfully.CO NIV ICE REFRESCOS DE SOYA
User
binary.struggle#mail.com
Parameters
output = 7
country = 170
period = 202204012
DATA_REPORT_DELIVERY = NO
read_persistance = YES
write_persistance = YES
client = 18277
indicator_group = SALES
Could you give some help? I reach some attepmpts succeded but it fails for no apparent reason:
Thank you.
I'm not sure if you're interested but I'd do it a slightly different way. It's a little more verbose but it will work and it makes your expressions a lot simpler.
I've just taken two of your desired outputs and provided a solution for those, one being client and the other being country. You can apply the other two as need be given it's the same pattern.
If I take client for example, this is the concept.
Initialize Data
This is your string that you provided in your question.
Initialize Split Lines
This will split up your string for each new line. The expression for this step is ...
split(variables('Data'), '\n')
However, you can't just enter that expression into the editor, you need to do it and then edit in in code view and change it from \\n to \n.
Filter For 'client'
This will filter the array created from the split line step and find the item that contains the word client.
`contains(item(), 'client')`
On the other parallel branches, you'd change out the word to whatever you're searching for, e.g. country.
This should give us a single item array with a string.
Initialize 'client'
Finally, we want to extract the value on the right hand side of the equals sign. The expression for this is ...
trim(split(body('Filter_For_''client''')[0], '=')[1])
Again, just change out the body name for the other action in each case.
I need to put body('Filter_For_''client''')[0] and specify the first item in an array because the filter step returns an array. We're going to assume the length is always 1.
Result
You can see from all of that, you have the value as need be. Like I said, it's a little more verbose but (I think) easier to follow and troubleshoot if something goes wrong.
I'm trying to import a Watson conversation app to a LUIS app, I have already converted the json to its equivalent in LUIS converting all Watson entities into Lists with synonyms, but when I try to import it to LUIS I get the following error:
The text length cannot exceed the limit 50
What's the cause of this and how can I fix it? It may be related to the limit of 50 explicit lists detailed here, if that's the case what exactly is a explicit list? I couldn't find any documentation related.
The entity name or the list normalized value or the list value synonym is more than 50 char.
As Dina mentioned above please check if the entity name or the list normalized value or the list value synonym is more than 50 characters. And you can try after fixing this. And regarding your second question: you can find more information about explicit list here. Hope this helps!!
The google cloud API for compute.instances.aggregatedList includes filter argument.
https://cloud.google.com/compute/docs/reference/rest/beta/instances/aggregatedList
I use (status eq "RUNNING") as a filter to view all my running instances.
I would like to have a more elaborate criteria, such as one that uses labels and or other terms, however even the Google documentation terms (that use OR operator) returns an error, For example - even Google documentation example:
(cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell")
fails with error 400:
"message": "Invalid value for field 'filter': ' (cpuPlatform = \"Intel
Skylake\") OR (cpuPlatform = \"Intel Broadwell\")'. Invalid list
filter expression."
it looks as if the '=' signs are not accepted, and AND/OR operators are not accepted.
What is the correct format for this API.
I had the same issue when I used "=" instead of "eq" in google-api-python-client. I required to use labels to filter the aggregated instances list. At first I used
filter="labels.projectid=test-project"
which returned 400 error in aggregated list but was successful if it was queried for instances of specific zone.
I achieved the list successfully when I used filter as
filter="labels.projectid eq \"test-project\""
or
filter = "labels.projectid eq test-project"
I even tested it using REST-Client provided by google and it worked.
Reference: https://issuetracker.google.com/80238913
Even 3 years later Google haven't fixed the bug: OR and AND operators are not supported even it is advertised:
https://cloud.google.com/compute/docs/reference/rest/v1/instances/aggregatedList
Google API is famous for inconsistency and false promises. Just relax and do 2 queries to emulate OR.
For AND operator just omit AND and quote comparison expressions into parentheses:
(name eq 'stage-.*') (labels.env ne "SKIP")
Note I use eq / ne with regex instead of operators =, !=, :.
I ran into a similar error message calling a GCP API. I finally got it to work by making the filter look like this:
fmt.Sprintf("selfLink = \"%s\"", networkLink)
Compute instances list api filter param should work with
(labels.<label_name_1>=<label_value_1>) OR (labels.<label_name_2>=<label_value_2>)
I have found that this string works as a filter within Python:
test_filter = '((labels.test="test-value") AND (labels.test-second="test-second-value")) OR ((labels.test="test-other-value"))'
This filter worked for me:
name eq my-service-v.*
Will return groups like my-service-v112 etc' (even though the name field is nested inside).
I am trying to call an OData report with the following URL :
https://myXXXXX.sapbydesign.com/sap/byd/odata/crm_customerinvoicing_analytics.svc/RPCRMCIVIB_Q0001QueryResults?&$filter=PARA_CAL_DAY%20gt%20datetime%272017-01-01T00:00:00.000%27%20and%20PARA_CAL_DAY%20lt%20datetime%272017-01-02T00:00:00.000%27&$skip=0
As you can see I am trying to use the and operator inside a filter property but I received the error in the title of this post.
I tried :
$filter=(MyFilter1) and (MyFilter2)
$filter=(MyFilter1 and MyFilter2)
$filter=(MyFilter1 AND MyFilter2)
But I still have an error. Any ideas ?
Just in case someone stumbles upon this thread first, this is error occurs when the same field is used to filter the dataset twice (greater than+less than, greater than+less than or equal to, etc)
SAP issue report
According to the documention for glGetActiveUniformsiv, GL_INVALID_VALUE is generated when
uniformCount is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program.
Why can't uniformCount equal to GL_ACTIVE_UNIFORMS?
That looks like a mistake in the man page. Unfortunately, the man pages are not always a reliable source of information. The final word is always the spec. I haven't been able to find this error in the ES 3.0 spec. The only related error I could find is:
For GetActiveUniformsiv, uniformIndices speciļ¬es an array of uniformCount indices in this list. If index or any value in uniformIndices is greater than or equal to the value of ACTIVE_UNIFORMS, the error INVALID_VALUE is generated.
There is no limit on the uniformCount, as far as I can tell.
In the OpenGL 4.5 spec, glGetActiveUniformsiv() is described as equivalent to a loop where glGetProgramResourceiv() is called uniformCount times. glGetPogramResourceiv() documents a GL_INVALID_VALUE error for invalid indices. But there is nothing about a limitation for uniformCount.