domain as argument #486
-
Hi, I have a question regarding passing domain from service class to different domain. currently my code is:
OpportunitiesService:
OpportunitiesServiceImpl:
Opportunities:
I think this is working fine, but currently I'm struggling with related service test class:
fflib_ApexMocks.ApexMocksException: EXPECTED COUNT: 1 So, my question is if it is a good approach to pass InvoiceLocationSectors domain to Opportunities domain to do the filtering or it would be better to update the record in implementation class? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hi @klipus Would I typically would do, is that you use a getter method to extract the data from the domain into a map with primitive data types and pass that into a setter method of the other domain. Then you have the highest possibility of re-use for both methods. Something like this:
Note: try to avoid methods like |
Beta Was this translation helpful? Give feedback.
-
@klipus -- going back to your original question and issue about the problem that you are having with the unit test, I am assuming that you are using the ApplicationFactory pattern and thus are utilizing an Application.cls in your codebase. You mentioned in you exert that your test method was the following:
When you defined oppDomainMock did you also tell the Application.Domain factory about the mock via Application.Domain.setMock() method (ref)?? Would you also please provide the full unit test method? In general, I am not seeing anything obviously wrong with the original implementation that you have setup. It is acceptable to pass one domain interface to another domain and generally is a simpler approach. |
Beta Was this translation helpful? Give feedback.
@klipus -- going back to your original question and issue about the problem that you are having with the unit test, I am assuming that you are using the ApplicationFactory pattern and thus are utilizing an Application.cls in your codebase. You mentioned in you exert that your test method was the following: