Assert json parameter value in second response with respect to same first request - json

App is related to an f&b business, I have following scenarios (api calls):
Create Order - on creating an order of any food item (let it be X), inventory of which is updated at back-end (this value is under test, let it be P1)
Get Inventory - (this call will fetch me the updated value of inventory of ordered item (X) i.e. inventory value, P1)
Cancel Order - this will cancel the order, i created in my first call, and hence P1 should be rolled back.
Get Inventory - Again i will hit this call to get the value, so as to verify that the inventory value of P1 has been updated properly.
In API call, (2) I extract P1 value using jp#gc Json Extractor and same I did for same call (4).
Now as per my expectations, value obtained in both these extractors should be equal as order has been cancelled now.
To assert these values, I am using JSON Assertion , either I am making use of wrong assertion or lacking a big amount of information here.
May be there is something like I can save the value first in some variable, and then assert.
Image of my test suite:

You can add JSR223 Assertion with checking different variables e.g. a and b:
if (!vars.get("a").equals(vars.get("b"))) {
AssertionResult.setFailureMessage("message");
AssertionResult.setFailure(true);
}
The script can check various aspects of the SampleResult. If an error is detected, the script should use AssertionResult.setFailureMessage("message") and AssertionResult.setFailure(true)

Related

How to fix a query in functions within foundry which is hiting ObjectSet:PagingAboveConfiguredLimitNotAllowed?

I have phonorgraph object with billions of rows and we are querying it through object set service
for example, I want to get all DriverLicences from certain city.
#Function()
public getDriverLicences(city: string): ObjectSet<DriverLicences> {
let drivers = Objects.search().DriverLicences().filter(row => row.city.exactMatch(city));
return drivers ;
}
I am facing this error when I am trying query it from slate:
ERROR 400: {"errorCode":"INVALID_ARGUMENT","errorName":"ObjectSet:PagingAboveConfiguredLimitNotAllowed","errorInstanceId":"0000-000","parameters":{}}
I understand that I am probably retrieving more than 100 000 results but I need all the results because of the implemented logic in the front is a complex slate dashboard built by another team that we cannot re-factor.
The issue here is that, specifically in the Slate <> Function connector, there is a "translation layer" that serializes the contents of the object set and provides a response data structure that materializes the property:value pairs for each object in the set.
This clearly doesn't work for large object sets where throwing so much data into the browser is likely to overwhelm the resources allocated to the tab.
From context it seems like you might be migrating an existing Slate app over to Functions; in the current version, how is the query limiting the number of results returned? It certainly must not be returning several 100 thousand results for further processing on the front end? (And if so, that might be an anti-pattern to consider addressing).
As for options that you could currently explore, you can sort your object set and then specify a smaller limit to return:
Objects.search().DriverLicences().filter(row => row.city.exactMatch(city)).orderBy(date_of_issue).take(100)
You'll find a few more details in the Functions documentation Reference entry on Ontology API: Object Sets in the section on Ordering and limiting.
You can even make a work around for the (current) lack of paging when return an ObjectSet to Slate by using the last value from the property ordered on (i.e. date_of_issue) as a filter in the subsequent request and return the next N objects.
This can work if you need a Slate table or HTML widget that renders on set of results then, on a user action, gets the next page.

Make beam/dataflow Create.of(List<String>) node emit exactly the number of elements in the list

My beam/dataflow job starts with a single static entry passed in like this:
Pipeline p = Pipeline.create(options);
PCollection<String> initValue = p.apply(Create.of("MyStringValue"));
However when I run it (on DataflowRunner), the Create node produced by that statement emits multiple values. The longer I wait, the more times it emits the single value:
This doesn't appear to be an artefact as later in the pipeline I get duplicate/triplicate/.. elements. Beam also logs a warning:
Can't verify serialized elements of type BoundedSource have well defined equals method. This may produce incorrect results on some PipelineRunner
How do I make my Create.of with one value emit just one value to the pipeline?
Do I need to attach an equals method or point it towards the equals method for String values (if so, how)!?

Setting a completion size or predicate for unknown number of splited elements in Camel route

I have a camel route that consume an http service which return a json with several elements I need to correlate through an Id. I don't know how many elements with the same Id are coming in the response, so, How can I set the completion in the aggregation in order to correlate all of them?
These are my routes:
from("direct:getInfo")
.id("getInfo")
.setHeader("accept", constant("application/json"))
.setHeader("authorization", constant("xyz"))
.setHeader("Cache-Control", constant("no-cache"))
.setHeader("content-Type", constant("application/json"))
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.removeHeader(Exchange.HTTP_PATH)
.removeHeader("CamelHttp*")
.setBody(simple("${null}"))
.streamCaching()
.to("http4:someURL") //responses an array of n json elements
.split().jsonpath("$").streaming()
.to("direct:splitInfo");
from("direct:splitInfo")
.id("splitInfo")
.aggregate(jsonpath("CustomerId"), new ArrayListAggregationStrategy())
.completionSize(???) //How must I set the completion in order to correlate all items
.to("direct:process");
Thanks so much.
Complete rewrite of the answer due to example in the comments
Since you want to split and re-aggregate complete JSON payloads, you only need the Splitter EIP with an aggregation strategy.
If you provide the splitter with the expression to split the payload as well as an aggregation strategy, you don't need a completion criteria at all. Every JSON payload is processed as a "batch".
.from(endpoint)
// body = complete JSON payload
.split([split-expression], new MyAggregationStrategy())
// each element is sent to this bean
.to("bean:elementProcessorBean")
// you must end the splitter
.end()
// here you get the complete re-aggregated JSON payload
// how it is re-aggregated is up to MyAggregationStrategy
Check out the linked Splitter documentation for an example.

What is the meanings of the input and output parameters of Kalman Filter in WSO2 CEP?

I would like to have some information about the input (named: measuredValue, measuredChangingRate, measurementNoiseSD and timestamp) and output (2 values) of Kalman Filter Extension in WSO2 CEP 4.2.0. I can't find any kind of documentation.
I suppose that measuredValue is the value to filter, timestamp is a numerical label about the instant of acquisition of measuredValue; and about measuredChangingRate and measurementNoiseSD?
Furthermore I noticed a problem: when I try to use this function, Siddhi says:
No extension exist for StreamFunctionExtension{namespace='kf'} in execution plan "ExecutionPlan"
Is it possible that there isn't any extension for kalmanFilter function?
My fragment query is that:
#Import('InputStream:1.0.0')
define stream InStream (energy double, timestamp long);
define stream ResKalmanFilterStream (energyEstimated double, x double);
from InStream#kf:kalmanFilter(energy)
select *
insert into ResKalmanFilterStream;
Regarding following error:
No extension exist for StreamFunctionExtension{namespace='kf'} in
execution plan "ExecutionPlan"
kf:kalmanFilter(energy) is a function which takes an attribute (energy in this case) as a parameter and outputs a new value. In other words, it produces a new attribute, therefore it has to be used in the select statement.
from InStream
select kf:kalmanFilter(energy) as filteredEnergy
insert into ResKalmanFilterStream;
Regarding parameters; I could find following information on the parameters in the Kalman Filter extension source code (refer the class-level comment).
measuredValue - measured value eg:40.695881
measuredChangingRate -
Changing rate. eg: Velocity of the point which describes from measured
value - 0.003d meters per second
measurementNoiseSD - standard
deviation of the noise. eg: 0.01
timestamp - the timestamp at the
measured time eg: 1445234861l

jmeter to issue http request based on response

I'm using Jmeter for my API testing using various http requests and various samplers to validate them. Now, I'm writing test for another http request. In this test,the steps are:
Issue a http request. Handle response.
using xpath xtractor, I'm extracting the response and storing URL in another variable(store_url).
If variable has a URL, repeat step-1.
This loops has to be repeated until no value is stored in (store_URL).
There is not definite number, how many time the loop has to be repeated. It is based on store_url is empty or not.
How can I achieve this in jmeter? I know step-1 and step-2. But I'm looking how to repeat step-1 and step-2. Please help me.
set a jmeter variable loopCount to 1 for init value,
move your step 1 and 2 into a loop controller,
set to loop count to ${loopCount}
in your step 2,
increase loopCount if store_url is found after you finish xpath xtractor
Put your points 1 and 2 under While Controller
Use ${__javaScript(vars.get("store_URL") != null)} as While Controller's Condition
In condition __javaScript() function is used to check store_URL variable value.
if store_URL variable is set (has any value) - everything under the While Controller will start over
if store_URL variable becomes null - the look will break
vars - is a shorthand to JMeterVariables class instance, it provides read/write access to all JMeter Variables
See Using JMeter Functions article for more detailed information on __javaScript and other useful functions