Let assume I have two simple model classes: Product
and Brand
It is obvious I have a query method in Product
class like this
Product product = Product.findById(123);
What if, I want to query products by brand?
ArrayList<Product> products = Product.findByBrand(234);
// or
ArrayList<Product> products = Product.findByBrand(new Brand("ABC", 234));
Assume 234 is the brand ID in the database.
I assume the 2nd way of writing make the method more easy to test as I can mock the Brand
class in my unit test, right?