As Karate supports type conversion, I was wondering if it is possible to write a custom type conversion in such a way that I could write something similar to this in my .feature file
customType customTypeResponse = response
which should have the same semantic as
yaml yamlResponse = response
but for customType instead of yaml.
I think I found the code enabling the custom type conversion. But I am not sure about the extensibility.
Thus the shortest way might be to use the Java interop enabling something like this
def customTypeResponse = CustomType.convert(response)
Please let me know of any possibiliy of type conversion.
Yes, I strongly suggest just using Java interop and not complicating it further for now. Maybe in the future we'll have a better way to do contribute custom syntax (hint: look for the Plugin interface and how karate-robot uses it).
Related
As far as I can tell, the Terraform SDK does not support an interface type. In my case I'm using a data resource to reach out to an API and pull JSON data. I would like to put that data in an attribute for later use in a resource but the problem is the JSON response has a large dictionary filled with different types. In GoLang this is no problem because you can set the map type to Interface{}. It would seem however that terraform only allows you to set the following types in a schema:
TypeInt
TypeString
TypeBool
TypeFloat
TypeInvalid
TypeList
TypeMap
Without support for interface how would you go about doing this correctly? The very ugly hack I have right now is converting everything to a string and then fixing the type once it is passed to the resource.
I asked on Hashicorp's forums and received a phenomenal answer here.
The synopsis is that casting to a string is currently the best solution. However there is a team working on making a new SDK design which would support newer capabilities to include arguments with dynamically chosen types.
I have gone through all possible solutions online to implement data provider facility using cucumber, but all are either incomplete or not working. Can anyone please suggest a working solution to read data from an external source such as an excel or CSV? How is it used in the step defs and feature file?
Exact code might be difficult to share at the moment. But following approach should work for you. Cucumber has Interface called as Transformer which you need to implement. THe transformer implementation should be accepted as step definitions arguments. E.g.,
#Given("your text <regex>")
public void someMethod(TransformerImpl transformerImpl) {
//your code goes here
}
The TranformerImpl is the implementation of Transformer interface. In that interface you will implement the logic of taking the csv file path or name and read its content and pass its data to the step definition as argument.
Let me know if this helps.
is there an equivalent of the new (-ish) JsonHttpClient that uses protobuf-net instead of JSON ? I realize that the old-style ProtobufServiceClient exists, but I'd like to replace it with something that uses HttpClient, instead of the old HttpWebRequest.
If such a client does not exist, how hard would it be to write one ? Should I just copy/paste JsonHttpClient.cs and change a few things, or is there a better way ?
No there isn't another ServiceClient for ProtoBuf other than ProtobufServiceClient. The easiest approach would be to take a copy of JsonHttpClient and modify it to use ProtoBuf, but JsonHttpClient wasn't designed to support multiple Content Types so it's not going to be as straight-forward as implementing a new ServiceClient.
Is it possible to get a list of all the arguments a constructor takes?
With the names and types of the parameters?
I want to automatically check the values of a JSON are good to use for building their equivalent as a class instance.
Preferably without macros... I have build a few, but I still find them quiet confusing.
Must work with neko and JS, if that maters.
Thanks.
I think you want to look at Runtime Type Information (rtti)
From the Haxe Manual: The Haxe compiler generates runtime type information (RTTI) for classes that are annotated or extend classes that are annotated with the #:rtti metadata. This information is stored as a XML string in a static field __rtti and can be processed through haxe.rtti.XmlParser. The resulting structure is described in RTTI structure.
Alternative; If you want to go with macros, this might be a good start
http://code.haxe.org/category/macros/add-parameters-as-fields.html
In my current work, I have written code generator using String Template without thinking about Parser ( I am instantiating Template files using direct Java Object). and code generator generator generates nice Java code.
Now, I have started to write Parser. B'coz of some nice editor features of xText, I am thinking to write parser in Xtext.
My question is "Is it possible to use code generator ( written using StringTemplate ) and Parse (written in Xtext) in same project?
Yes that's possible. Xtext offers a typed AST for the parsed files and you could easily pass them to your code generator (directly, iff they fulfil the same contract / interfaces, or indirectly by transforming them to the expected structure). Xtext does not impose any constraints on how you want to use the parsed information.