@Test void cantAddProductWithNegativePrice() { String name = "test"; int price = -123; assertThrows(IllegalArgumentException.class, () -> warehouse.addProduct(name, price)); }
public void addProduct(String name, int price) throws WarehouseException { if (price < 0) { throw new IllegalArgumentException("The product's price cannot be negative."); } Product product = new Product(name, price); productDao.addProduct(product); }
Warehouse { public void addProduct(String name, int price) throws WarehouseException { if (price < 0) { throw new IllegalArgumentException("The product's price cannot be negative."); } Product product = new Product(name, price); productDao.addProduct(product); } }
Warehouse { public void addProduct(String name, int price) throws WarehouseException { if (price < 0) { throw new IllegalArgumentException("The product's price cannot be negative."); } Product product = new Product(name, price); productDao.addProduct(product); } Warehouse(
        ProductDao productDao,
        CustomerDao customerDao,
        InventoryDao inventoryDao,
        OrderDao orderDao,
        ReportGeneration reportGeneration); }
Warehouse { public void addProduct(String name, int price) throws WarehouseException { if (price < 0) { throw new IllegalArgumentException("The product's price cannot be negative."); } Product product = new Product(name, price); productDao.addProduct(product); } Warehouse(
        ProductDao productDao,
        CustomerDao customerDao,
        InventoryDao inventoryDao,
        OrderDao orderDao,
        ReportGeneration reportGeneration); Collection<Product> getProducts(); Product getProduct(int id); Collection<Customer> getCustomers(); Customer getCustomer(int id); Collection<Order> getOrders(); Order getOrder(int id); void addProduct(String name, int price); void addOrder(int customerId, Map<Integer, Integer> quantities); Report generateReport(Report.Type type); }
Warehouse { public void addProduct(String name, int price) throws WarehouseException { if (price < 0) { throw new IllegalArgumentException("The product's price cannot be negative."); } Product product = new Product(name, price); productDao.addProduct(product); } Warehouse(
        ProductDao productDao,
        CustomerDao customerDao,
        InventoryDao inventoryDao,
        OrderDao orderDao,
        ReportGeneration reportGeneration); Collection<Product> getProducts(); Product getProduct(int id); Collection<Customer> getCustomers(); Customer getCustomer(int id); Collection<Order> getOrders(); Order getOrder(int id); void addProduct(String name, int price); void addOrder(int customerId, Map<Integer, Integer> quantities); Report generateReport(Report.Type type);  }