mercredi 16 décembre 2020

Simpler @DataJpaTest tests for Entities with many non-optional associations?

I am testing some entities with a lot of @[Many|One]ToOne(optional = false) associations (no cascading).

To avoid TransientPropertyValueException I am persisting (EnterpriseManager::persist) each direct and indirect association manually before targetting the actual Entity. It is a really pain, in some cases I need to persist 12+ associated entities before running the test.

Is there any way to avoid or simplify the need to persist all non-optional associations before saving an Entity during a @DataJpaTest?

Aucun commentaire:

Enregistrer un commentaire