orderMngmntWebapp\src\orderMngr\domain\order\OrderFactory.java
 
/* * Copyright (c) 2006-2014 Rogério Liesenfeld * This file is subject to the terms of the MIT license (see LICENSE.txt). */
/*...*/
5 
package orderMngr.domain.order;
 
 
import java.math.*; import java.util.*;
import ...
 
108
public final class OrderFactory
  1. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
  2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
  3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
  4. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithEmptyItemList: 67
  5. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
  6. orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrder: 43
  7. orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrderWithMissingData: 108
11 
{
12 
   // Just for simplicity. In a real application, a more robust mechanism would be used for
13 
   // generating sequential order numbers, such as a database sequence or identity column.
141
   private static int nextOrderNo = 1;
     
    16 
       public Order createOrder(String customerId, List<OrderItem> items)
    17 
          throws MissingOrderItems, InvalidOrderItem, DuplicateOrderItem
    18 
       {
    4 Path coverage: 2/2 A: 2 B: 2
    197
          if (items.isEmpty()) {
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
    4. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
    5. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithEmptyItemList: 67
    6. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
    7. orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrderWithMissingData: 108
    202
             throw new MissingOrderItems();
    1. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithEmptyItemList: 67
    2. orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrderWithMissingData: 108
    21 
          }
     
    235
          validateOrderItems(items);
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
    4. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
    5. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
     
    252
          Order order = new Order(nextOrderNo++, customerId);
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
    262
          order.getItems().addAll(items);
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
     
    282
          new OrderRepository().create(order);
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
     
    302
          return order;
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
    31 
       }
     
    33 
       private void validateOrderItems(List<OrderItem> items) throws InvalidOrderItem, DuplicateOrderItem
    34 
       {
    5 Path coverage: 4/6 A: 1 B: 1 C: 0 D: 1 E: 0 F: 2
    355
          for (OrderItem item : items) {
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
    4. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
    5. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
    4. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
    5. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
    368
             if (item.getQuantity() <= 0 || item.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0) {
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
    4. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
    5. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
    4. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
    372
                throw new InvalidOrderItem("Quantity=" + item.getQuantity() + ", Unit Price=" + item.getUnitPrice());
    1. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
    38 
             }
    396
          }
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
     
    413
          if (new HashSet<>(items).size() < items.size()) {
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
    3. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
    421
             throw new DuplicateOrderItem();
    1. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
    43 
          }
    442
       }
    1. orderMngr.domain.order.OrderFactoryTest#createOrder: 33
    2. orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
    45 
    }