2024 Nov 06 8:53 AM - edited 2024 Nov 06 8:53 AM
Hi,
I have a managed RAP entity with a behavior implementation method that tries to read active and draft entities. I already know it works in practice through testing it in my Fiori app.
In my unit test for the class, I mock the entities using the test double framework and call my method, which should be able to read entities inserted into the cds or sql test double frameworks. For active entities, my method works with no problem and is able to get a READ result.
However, for draft entities, I could not find a way to create them using the test double framework and our READ gets no result. I tried to insert the persistent draft table as a dependency in the CDS test environment and to insert it through the sql test environment instead, as well, but this did not result in a READ result in the method.
The only thing that did work was a workaround/hack to insert the data I wanted into the CDS test environment as an active entity and then execute the EDIT method on it.
I also could not find any tutorial or documentation about this. The only thing I found was a blog post where someone used the same workaround as me:
But I wanted to know if there is a "best practice" for doing this or if it is actually intended to use the EDIT workaround.
Thank you,
Zena
Request clarification before answering.
User | Count |
---|---|
76 | |
30 | |
10 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.