YAML files used by APE are plain DBunit DataSets meaning, they are db / row oriented (rdbms entities, not Java objects). You need to refer to other entries using foreign keys, as you would do in plain SQL. I hope I got your concern right
Nope you didn't
in plain sql i would:
insert into A(id) values(1);
insert into B(id, a_id) values(2,1);
update table A where id = 1 set b_id = 2;
given there are foreign keys between a_id and A and b_id and B that's the only way to this (unless you consider turning off the foreign keys alltogether)
how can I do that using yml in APE?
Ok, got me
Not sure if it's even possible with pure YAML, because it's more something like chicken-egg problem (not that it's not doable, only to describe how YAML parsers are working)
I'm afraid you need to define the alias first before you reference to it, so something like this won't work
- id: 2
- id: &b_id 1
On the other hand I can't really see how dbunit would process such data set, when it's anyway going row-by-row. Conclusion: turning off integrity check might be the only option if you want to use single data set.
However, you can provide two data sets, one with raw data and second one with updated relationships. For this purpose you should define insert strategy as @SeedDataUsing(REFRESH) - this will update existing rows and insert those which are not existing yet (if any)
However, you can provide two data sets, one with raw data and second one with updated relationships.
That sounds like a solution.
For this purpose you should define insert strategy as @SeedDataUsing(REFRESH) - this will update existing rows and insert those which are not existing yet (if any)
Mmm... an internet search didn't help me find @SeedDataUsing annotation.
I had a look at the source code but I still wonder how to make it work? I mean: I need to have e.g.
I can't do it on one test method, can I? It wouldn't look good to split it between class annotation and method annotation too, right? How to handle it then?
How about having such a construct?
the order of data sets should be preserved.
You can also put @SeedDataUsing on the class levelso it will become the default if not defined otherwise on the method level.