@Test public void removeAllTest() { Product p = new Product(tracker).setProductId("toto"); Product p2 = new Product(tracker).setProductId("tata"); productsTracker.add(p); productsTracker.add(p2); productsCart.add(p); productsCart.add(p2); assertEquals(2, tracker.getBusinessObjects().size()); assertEquals(2, tracker.Cart().getProductsList().size()); productsTracker.removeAll(); productsCart.removeAll(); assertEquals(0, tracker.getBusinessObjects().size()); assertEquals(0, tracker.Cart().getProductsList().size()); }
public void removeAll() { if (cart != null) { cart.getProductsList().clear(); } else { ArrayList<BusinessObject> objects = new ArrayList<>(); objects.addAll(tracker.getBusinessObjects().values()); for (BusinessObject obj : objects) { if (obj instanceof Product) { tracker.getBusinessObjects().remove(obj.getId()); } } } }
Products extends Helper { public void removeAll() { if (cart != null) { cart.getProductsList().clear(); } else { ArrayList<BusinessObject> objects = new ArrayList<>(); objects.addAll(tracker.getBusinessObjects().values()); for (BusinessObject obj : objects) { if (obj instanceof Product) { tracker.getBusinessObjects().remove(obj.getId()); } } } } }
Products extends Helper { public void removeAll() { if (cart != null) { cart.getProductsList().clear(); } else { ArrayList<BusinessObject> objects = new ArrayList<>(); objects.addAll(tracker.getBusinessObjects().values()); for (BusinessObject obj : objects) { if (obj instanceof Product) { tracker.getBusinessObjects().remove(obj.getId()); } } } } Products(Tracker tracker);   Products(Cart cart); }
Products extends Helper { public void removeAll() { if (cart != null) { cart.getProductsList().clear(); } else { ArrayList<BusinessObject> objects = new ArrayList<>(); objects.addAll(tracker.getBusinessObjects().values()); for (BusinessObject obj : objects) { if (obj instanceof Product) { tracker.getBusinessObjects().remove(obj.getId()); } } } } Products(Tracker tracker);   Products(Cart cart); Product add(Product product); Product add(String productId); Product add(String productId, String category1); Product add(String productId, String category1, String category2); Product add(String productId, String category1, String category2, String category3); Product add(String productId, String category1, String category2, String category3, String category4); Product add(String productId, String category1, String category2, String category3, String category4, String category5); Product add(String productId, String category1, String category2, String category3, String category4, String category5, String category6); void remove(String productId); void removeAll(); void sendViews(); }
Products extends Helper { public void removeAll() { if (cart != null) { cart.getProductsList().clear(); } else { ArrayList<BusinessObject> objects = new ArrayList<>(); objects.addAll(tracker.getBusinessObjects().values()); for (BusinessObject obj : objects) { if (obj instanceof Product) { tracker.getBusinessObjects().remove(obj.getId()); } } } } Products(Tracker tracker);   Products(Cart cart); Product add(Product product); Product add(String productId); Product add(String productId, String category1); Product add(String productId, String category1, String category2); Product add(String productId, String category1, String category2, String category3); Product add(String productId, String category1, String category2, String category3, String category4); Product add(String productId, String category1, String category2, String category3, String category4, String category5); Product add(String productId, String category1, String category2, String category3, String category4, String category5, String category6); void remove(String productId); void removeAll(); void sendViews();  }