-
Notifications
You must be signed in to change notification settings - Fork 148
Description
There is a group of methods in the JmixDataRepository, such as the following
T getById(ID id, @nullable FetchPlan fetchPlan);
These methods contain a FetchPlan object as a parameter.
The first problem is that we need to inject additional bean to solve the single problem (getting data from repository). This is the FetchPlans bean, so we need two beans to call a single method. At the same time the FetchPlans bean is the single bean that provides fetch plans.
The second problem is the testability of the beans that use the repositories. This issue is due to FetchPlans API. It is a fluent-style API, which is not suitable for unit testing (for mocking and stubbing).
This problem is exacerbated by the fact that the FetchPlan class has no any public constructor. As a result, the mocking of the FetchPlan class requires the objenesis libruary that as a consequence looks like a smell of architecture problems.
The preposition is to modify JmixDataRepository API in order to avoid using the additional bean. It looks like a good way is to use lambdas like in the DataManager fluent-style API(FetchPlanBuilder).
Using lambdas supports an ability to mocking and subbing the data repository bean (lambda can be made as a static field that can be used in the test). Additionally, using lambdas for fetch plans is a very popular and appopriate way that is practiced with using the DataManager.
Metadata
Metadata
Assignees
Type
Projects
Status