@Test public void testCutoff_race() { StockOpImpl operator = new StockOpImpl(); List<Stock> stocks = new ArrayList<Stock>(); List<Shipment> shipments = new ArrayList<Shipment>(); MockResult<Stock> newStocks = new MockResult<Stock>(); MockResult<Shipment> newShipments = new MockResult<Shipment>(); operator.cutoff(stocks, shipments, newStocks, newShipments); assertThat(newStocks.getResults().size(), is(0)); assertThat(newShipments.getResults().size(), is(0)); }
@CoGroup public void cutoff( @Key(group = "ITEM_CODE", order = "PURCHASED_DATE ASC") List<Stock> stocks, @Key(group = "ITEM_CODE", order = "SHIPPED_DATE ASC") List<Shipment> shipments, Result<Stock> newStocks, Result<Shipment> newShipments) { Iterator<Stock> eachStock = stocks.iterator(); Iterator<Shipment> eachShipment = shipments.iterator(); while (eachStock.hasNext()) { Stock stock = eachStock.next(); while (eachShipment.hasNext()) { if (stock.getQuantity() == 0) { break; } Shipment shipment = eachShipment.next(); shipment.setCost(stock.getCost()); newShipments.add(shipment); stock.getQuantityOption().add(-1); } newStocks.add(stock); } while (eachShipment.hasNext()) { Shipment shipment = eachShipment.next(); newShipments.add(shipment); } }
StockOp { @CoGroup public void cutoff( @Key(group = "ITEM_CODE", order = "PURCHASED_DATE ASC") List<Stock> stocks, @Key(group = "ITEM_CODE", order = "SHIPPED_DATE ASC") List<Shipment> shipments, Result<Stock> newStocks, Result<Shipment> newShipments) { Iterator<Stock> eachStock = stocks.iterator(); Iterator<Shipment> eachShipment = shipments.iterator(); while (eachStock.hasNext()) { Stock stock = eachStock.next(); while (eachShipment.hasNext()) { if (stock.getQuantity() == 0) { break; } Shipment shipment = eachShipment.next(); shipment.setCost(stock.getCost()); newShipments.add(shipment); stock.getQuantityOption().add(-1); } newStocks.add(stock); } while (eachShipment.hasNext()) { Shipment shipment = eachShipment.next(); newShipments.add(shipment); } } }
StockOp { @CoGroup public void cutoff( @Key(group = "ITEM_CODE", order = "PURCHASED_DATE ASC") List<Stock> stocks, @Key(group = "ITEM_CODE", order = "SHIPPED_DATE ASC") List<Shipment> shipments, Result<Stock> newStocks, Result<Shipment> newShipments) { Iterator<Stock> eachStock = stocks.iterator(); Iterator<Shipment> eachShipment = shipments.iterator(); while (eachStock.hasNext()) { Stock stock = eachStock.next(); while (eachShipment.hasNext()) { if (stock.getQuantity() == 0) { break; } Shipment shipment = eachShipment.next(); shipment.setCost(stock.getCost()); newShipments.add(shipment); stock.getQuantityOption().add(-1); } newStocks.add(stock); } while (eachShipment.hasNext()) { Shipment shipment = eachShipment.next(); newShipments.add(shipment); } }  }
StockOp { @CoGroup public void cutoff( @Key(group = "ITEM_CODE", order = "PURCHASED_DATE ASC") List<Stock> stocks, @Key(group = "ITEM_CODE", order = "SHIPPED_DATE ASC") List<Shipment> shipments, Result<Stock> newStocks, Result<Shipment> newShipments) { Iterator<Stock> eachStock = stocks.iterator(); Iterator<Shipment> eachShipment = shipments.iterator(); while (eachStock.hasNext()) { Stock stock = eachStock.next(); while (eachShipment.hasNext()) { if (stock.getQuantity() == 0) { break; } Shipment shipment = eachShipment.next(); shipment.setCost(stock.getCost()); newShipments.add(shipment); stock.getQuantityOption().add(-1); } newStocks.add(stock); } while (eachShipment.hasNext()) { Shipment shipment = eachShipment.next(); newShipments.add(shipment); } }  @Branch ShipmentStatus checkShipment(Shipment shipment); @CoGroup void cutoff(
            // 在庫は商品ごとにグルーピングして、さらに入荷順に並べる
            @Key(group = "ITEM_CODE", order = "PURCHASED_DATE ASC") List<Stock> stocks,
            // 注文も商品ごとにグルーピングして、さらに出荷順に並べる
            @Key(group = "ITEM_CODE", order = "SHIPPED_DATE ASC") List<Shipment> shipments,
            Result<Stock> newStocks,
            Result<Shipment> newShipments); }
StockOp { @CoGroup public void cutoff( @Key(group = "ITEM_CODE", order = "PURCHASED_DATE ASC") List<Stock> stocks, @Key(group = "ITEM_CODE", order = "SHIPPED_DATE ASC") List<Shipment> shipments, Result<Stock> newStocks, Result<Shipment> newShipments) { Iterator<Stock> eachStock = stocks.iterator(); Iterator<Shipment> eachShipment = shipments.iterator(); while (eachStock.hasNext()) { Stock stock = eachStock.next(); while (eachShipment.hasNext()) { if (stock.getQuantity() == 0) { break; } Shipment shipment = eachShipment.next(); shipment.setCost(stock.getCost()); newShipments.add(shipment); stock.getQuantityOption().add(-1); } newStocks.add(stock); } while (eachShipment.hasNext()) { Shipment shipment = eachShipment.next(); newShipments.add(shipment); } }  @Branch ShipmentStatus checkShipment(Shipment shipment); @CoGroup void cutoff(
            // 在庫は商品ごとにグルーピングして、さらに入荷順に並べる
            @Key(group = "ITEM_CODE", order = "PURCHASED_DATE ASC") List<Stock> stocks,
            // 注文も商品ごとにグルーピングして、さらに出荷順に並べる
            @Key(group = "ITEM_CODE", order = "SHIPPED_DATE ASC") List<Shipment> shipments,
            Result<Stock> newStocks,
            Result<Shipment> newShipments);  }