@Test public void testFindFirstSourceProduct_IgnoreIndependent() throws Exception { Product toBeClosedProduct = new Product("ToBeClosed", "Type", 100, 100); Product dependingProduct = new Product("dependingProduct", "Type", 100, 100); Product dependentProduct = createDependentProduct(dependingProduct); HashSet<Product> stillOpen = new HashSet<>(Collections.singletonList(dependentProduct)); stillOpen.add(dependingProduct); Product firstSourceProduct = CloseProductAction.findFirstSourceProduct(toBeClosedProduct, stillOpen); assertNull(firstSourceProduct); }
static Product findFirstSourceProduct(Product productToClose, Set<Product> productsStillOpen) { Product firstSourceProduct = findFirstDirectSourceProduct(productToClose, productsStillOpen); if (firstSourceProduct != null) { return firstSourceProduct; } return findFirstExpressionSourceProduct(productToClose, productsStillOpen); }
CloseProductAction extends AbstractAction implements ContextAwareAction, LookupListener { static Product findFirstSourceProduct(Product productToClose, Set<Product> productsStillOpen) { Product firstSourceProduct = findFirstDirectSourceProduct(productToClose, productsStillOpen); if (firstSourceProduct != null) { return firstSourceProduct; } return findFirstExpressionSourceProduct(productToClose, productsStillOpen); } }
CloseProductAction extends AbstractAction implements ContextAwareAction, LookupListener { static Product findFirstSourceProduct(Product productToClose, Set<Product> productsStillOpen) { Product firstSourceProduct = findFirstDirectSourceProduct(productToClose, productsStillOpen); if (firstSourceProduct != null) { return firstSourceProduct; } return findFirstExpressionSourceProduct(productToClose, productsStillOpen); } CloseProductAction();  CloseProductAction(Lookup actionContext);  CloseProductAction(List<Product> products); }
CloseProductAction extends AbstractAction implements ContextAwareAction, LookupListener { static Product findFirstSourceProduct(Product productToClose, Set<Product> productsStillOpen) { Product firstSourceProduct = findFirstDirectSourceProduct(productToClose, productsStillOpen); if (firstSourceProduct != null) { return firstSourceProduct; } return findFirstExpressionSourceProduct(productToClose, productsStillOpen); } CloseProductAction();  CloseProductAction(Lookup actionContext);  CloseProductAction(List<Product> products); @Override Action createContextAwareInstance(Lookup actionContext); @Override void resultChanged(LookupEvent lookupEvent); @Override void actionPerformed(ActionEvent e); Boolean execute(); static Boolean closeProducts(Set<Product> products); }
CloseProductAction extends AbstractAction implements ContextAwareAction, LookupListener { static Product findFirstSourceProduct(Product productToClose, Set<Product> productsStillOpen) { Product firstSourceProduct = findFirstDirectSourceProduct(productToClose, productsStillOpen); if (firstSourceProduct != null) { return firstSourceProduct; } return findFirstExpressionSourceProduct(productToClose, productsStillOpen); } CloseProductAction();  CloseProductAction(Lookup actionContext);  CloseProductAction(List<Product> products); @Override Action createContextAwareInstance(Lookup actionContext); @Override void resultChanged(LookupEvent lookupEvent); @Override void actionPerformed(ActionEvent e); Boolean execute(); static Boolean closeProducts(Set<Product> products);  }