Testable Adapter class with MVP
The Adapter dual nature
Well, Adapter and its name suggest that it adapts the data to the view. But what happens if you only want to test the view nature of the adapter or the data handling methods. If you work directly with the class it can cause you a lot of headaches. That’s why you split the adapter class into two interfaces: Data & View
View & Data models
Dagger2 to the help
After that you can easily export the adapter from Dagger as it is done in the MainModule. You can also export only the data part of it or the view part and you can easily mock their implementations after that.
Now you can easily test and mock the adapter so your unit tests will be clearer. It is a neat idea and I really liked it.