I've created new JIRA item as discussed with Mauro Talevi via email:
JBEHAVE-1204 <https://jbehave.atlassian.net/browse/JBEHAVE-1204>
On Wednesday, December 14, 2016 at 5:56:12 PM UTC+2, Ilya Skapchuk wrote:
>
> Hello community.
>
> On my current project we work with Jsons a lot.
>
> One day I got an idea that it will be great to be able to use Jsons as a
> test data which will be automatically converted to Java objects (DTOs) when
> you pass this data from story file.
>
> (Like ExamplesTableParametersConverter which automatically converts example
> tables/files with example tables to Java objects (DTOs) via @AsParameters
> annotation
> when you pass it from story file)
>
>
> We created our own converter called JsonConverter which allows to
> automatically convert Json strings/files to Java objects (DTOs). (
> ExamplesTableParametersConverter was taken as a basis wen we were
> creating it)
>
> *JsonConverter usage example:*
> We added new annotation (like @AsParameters) called @AsJson.
>
> *JBehave story:*
>
>
>
> *Then* actual data should be as dataFolder/dataFile.json data
>
> or
>
> * Then* actual data should be as {"variable1": "value1", "variable2":
> "value2"} data
>
> …
>
>
>
> *Java definition:*
>
>
>
> @Then(*"actual data should be as $expectedJson* *data"*)
> *public void *checkJsonData(*final *JsonDTO expectedJson) {
>
>
>
>
> *//assert expectedJson equals to actual json of JsonDTO.class type...
> *}
>
> …
>
>
>
> *Java DTO:*
>
>
>
> @AsJson
> *public class *JsonDTO {
>
>
> *private *String *variable1*;
>
> *private *String *variable2*;
>
>
> }
>
> …
>
>
>
> *MY QUESTIONS ARE:*
>
> 1. Is it worth to add JsonConverter to jbehave-core through pull request?
>
> 2. Is it better to use @AsParameters for JsonConverter instead of own @AsJson
> annotation to be able to convert both examples tables and Jsons to the same
> Java object (DTO). (*requires much more logic changes in jbehave-core code*).
>
>
> Link to existing Jbehave Parameters Converter
> <http://jbehave.org/reference/stable/parameter-converters.html>
>
>
--
You received this message because you are subscribed to the Google Groups
"JBehave Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/jbehave-dev/44cc552a-30f8-4e49-968b-3ccf812f0d82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.