001    package org.cocome.tradingsystem.systests.scenarios;
002    
003    import org.cocome.tradingsystem.systests.interfaces.IOrder;
004    import org.cocome.tradingsystem.systests.util.GeneratedStockItem;
005    
006    /**
007     * This test covers use cases 3 and 5. An order will be executed for some
008     * products and the roll in of the correct products will be handled.
009     * 
010     * @author Christian Pfaller
011     * @author $Author: hummel $
012     * @version $Revision: 1.1 $
013     * @lev.rating GREEN Rev: 64
014     */
015    
016    public class OrderAndReceiveProductsTest extends TestScenarioBase {
017    
018            /** Execute the test case. */
019            public void testScenario() throws Exception {
020                    StoreWrapper store = stores.get(0);
021    
022                    /***********************************************************************
023                     * use case 3 - order products
024                     **********************************************************************/
025    
026                    // manager selects a product which runs out of stock
027                    GeneratedStockItem item = store.getItemLowOnStock();
028    
029                    // create a new order for this product
030                    IOrder order = store.getStorePC().createOrder();
031                    int orderAmount = item.getMaxAmount() - item.getAmount();
032                    order.addOrderItem(item.getProduct().getProduct(), orderAmount);
033    
034                    // execute the order
035                    store.getStorePC().executeOrder(order);
036    
037                    /***********************************************************************
038                     * use case 4 - receive order products
039                     **********************************************************************/
040    
041                    // products arrive with attached orderId
042                    // Using orderId StockManager can get all information about the order
043                    // StoreManager checks if everything is correct
044                    // Assumption: Everything correct, so roll in order
045                    store.getStorePC().rollInOrder(order);
046    
047                    // check if product amount is increased as expected
048                    assertEquals(
049                                    "Amount of original order and retreived order should be equal",
050                                    item.getMaxAmount(), store.getStorePC().getAmount(
051                                                    item.getProduct().getProduct()));
052    
053            }
054    
055    }