use of com.dockerx.reactive.orderstock.stock.StockMaintain in project Java-9-Spring-Webflux by kkTranslation.
the class TestStockMaintain method teststockRemoval.
@Test
public void teststockRemoval() throws InterruptedException {
Stock stock = new Stock();
SubmissionPublisher<Order> p = new SubmissionPublisher<>();
p.subscribe(new StockMaintain(stock));
Product product = new Product();
stock.store(product, 40);
OrderItem item = new OrderItem();
item.setProduct(product);
item.setAmount(10);
Order order = new Order();
List<OrderItem> items = new LinkedList<>();
items.add(item);
order.setItems(items);
for (int i = 0; i < 10; i++) p.submit(order);
log.info("所有订单已经提交完毕");
for (int j = 0; j < 10; j++) {
log.info("Sleeping a bit...");
Thread.sleep(50);
}
p.close();
log.info("Publisher已关闭");
}
Aggregations