for the data-driven feature, doest it support an normal array looping, not json array? - karate

I need to loop a string (split by ',') and get each element passed to the feature files automatically. I know there is excellent support for json array data-driven test, but does it support data-driven with normal strings or string array
As I know, I need to get it converted to a json array to support data-driven test at runtime, however, I want to know any existing support for normal array looping directly and automatically.
Here is my string(separated by ',') that needs to get passed as request parameter:
"PHE,TSH,17_a_OHP,G6PD,MSMS,THALASSEMIA,DGT"
Because my string is dynamically produced at runtime, I want to loop it automatically and pass to other feature files, not manually,

Note that converting arrays into other "shapes" is easy in Karate. And in 0.9.3 we introduced the karate.mapWithKey() API, so you can do this:
* def string = 'PHE,TSH,17_a_OHP,G6PD,MSMS,THALASSEMIA,DGT'
* def array = string.split(',')
* def list = karate.mapWithKey(array, 'name')
* print list
So you can see, list is ready to use for data-driven features. Also note that you can use this in dynamic scenario outlines !

Related

lucene .net parser for filter and sorting

In our lucene .net based search (Lucene 4.8.0-beta00016) we save the generated query, the filter and the sorting in a custom text file.
e.g.:
"Query":"+name:*test*"
"Filter":"BooleanFilter(+type:project)"
"Sort":"<long: \"creationdate\">!"
We built a test tool, similiar to Luke and we want to execute this saved search there and run a programmatic search:
For the query I can use the QueryParser and get the corresponding query object, but there seems to be no parser for the filter and the sort.
var queryParsed = new QueryParser().Parse("+name:*test*");
var filter = ?
var sort = ?
indexSearcher.Search(queryParsed, filter?, 10000, sort?);
Is there any way I can parse the filter and sort strings to a Filter/Sort object ?
Have you ever thought to serialize your custom file in a different way?
I'm guessing your file is generated by calling the toString() method of each object type. Something like the follow
"Query:" + queryObject.toString()
"Filter:" + filterObject.toString()
"Sort:" + sortObject.toString()
If you serialize your original query, filter, and sort .NET objects as binary strings, in your test tool, you should be able to re-create the original .NET objects.
Look at https://learn.microsoft.com/en-us/dotnet/standard/serialization/

How can we write karate code inside karate loop? [duplicate]

I need to loop a string (split by ',') and get each element passed to the feature files automatically. I know there is excellent support for json array data-driven test, but does it support data-driven with normal strings or string array
As I know, I need to get it converted to a json array to support data-driven test at runtime, however, I want to know any existing support for normal array looping directly and automatically.
Here is my string(separated by ',') that needs to get passed as request parameter:
"PHE,TSH,17_a_OHP,G6PD,MSMS,THALASSEMIA,DGT"
Because my string is dynamically produced at runtime, I want to loop it automatically and pass to other feature files, not manually,
Note that converting arrays into other "shapes" is easy in Karate. And in 0.9.3 we introduced the karate.mapWithKey() API, so you can do this:
* def string = 'PHE,TSH,17_a_OHP,G6PD,MSMS,THALASSEMIA,DGT'
* def array = string.split(',')
* def list = karate.mapWithKey(array, 'name')
* print list
So you can see, list is ready to use for data-driven features. Also note that you can use this in dynamic scenario outlines !

How to pass array of struct(User defined data type) as an input to call procedure in mule

In my project we have a requirement where we have to insert an array of struct as an input parameter.How i can achieve that.
I don't want to use the approach suggested here
https://dzone.com/articles/passing-java-arrays-in-oracle-stored-procedure-fro
I want to use the inbuilt objects given in mule.
we have to insert an array of struct as an input parameter
Where you want to insert this array ?
array of struct
can we consider the User defined data type as POJOs ( just java object?) ?
I want to use the inbuilt objects given in mule.
As I can see in the link, the example use Java + Mule component. Should I guess that you want to avoid Java code?
Please, elaborate your use case... hard to replicate

Noflo .fbp array initiallizer

I'm using noflo and am trying to send an array as an initiallizer. There doesn't seem to be a supported (or at least documented) way to do this.
I'm currently using:
'["Kicker"]' -> IN Nodes(strings/ParseJson)
'{"in":"go!"}' -> IN Config(strings/ParseJson)
Nodes() OUT -> NODES MyComponent(noflotest/Universe)
Config OUT -> CONFIG MyComponent()
Is there a better way to do this?
Currently arrays and other complicated data structures are not supported in the .fbp syntax. There is a feature request about this.
Right now you have three options:
If FBP parser accepts your string (see the matching rules), you can first send it to the strings/ParseJson component to turn it to the appropriate data structure
Reading the value from a JSON or YAML file and passing it through the appropriate parser component
Converting your graph to the JSON graph format

Writing simple dictionary using java & google dictionary api

http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q=test&sl=en&tl=en&restrict=pr%2Cde&client=te
(replace test with your favorite keyword)
using this i want to write simple dictionary....
problem - api give json output how i get it using java?
Simple Parsing
Per default, JSON will just produce a nested graph of maps and lists. Here is an example of default parsing:
import org.svenson.JSONParser;
// assume json to be a JSON datasets as String
Object o = JSONParser.defaultJSONParser().parse(json);
o will now contain either a map or a list instance, depending on whether the first symbol in the JSON is '{' or '['.