Search in sources :

Example 1 with Product

use of com.dockerx.reactive.orderstock.product.Product 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已关闭");
}
Also used : Order(com.dockerx.reactive.orderstock.product.Order) SubmissionPublisher(java.util.concurrent.SubmissionPublisher) OrderItem(com.dockerx.reactive.orderstock.product.OrderItem) Product(com.dockerx.reactive.orderstock.product.Product) StockMaintain(com.dockerx.reactive.orderstock.stock.StockMaintain) Stock(com.dockerx.reactive.orderstock.stock.Stock) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

Order (com.dockerx.reactive.orderstock.product.Order)1 OrderItem (com.dockerx.reactive.orderstock.product.OrderItem)1 Product (com.dockerx.reactive.orderstock.product.Product)1 Stock (com.dockerx.reactive.orderstock.stock.Stock)1 StockMaintain (com.dockerx.reactive.orderstock.stock.StockMaintain)1 LinkedList (java.util.LinkedList)1 SubmissionPublisher (java.util.concurrent.SubmissionPublisher)1 Test (org.junit.Test)1