orderMngmntWebapp\src\orderMngr\domain\order\OrderFactory.java
| |
5 | |
package orderMngr.domain.order; |
| |
| |
import java.math.*;
import java.util.*;
import ...
|
| |
10 | 8 |
public final class OrderFactory
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithEmptyItemList: 67
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
- orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrder: 43
- orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrderWithMissingData: 108
|
11 | |
{ |
12 | |
|
13 | |
|
14 | 1 |
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
|
19 | 7 |
if (items.isEmpty()) {
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithEmptyItemList: 67
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
- orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrderWithMissingData: 108
|
20 | 2 |
throw new MissingOrderItems();
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithEmptyItemList: 67
- orderMngr.web.submitOrder.OrderEntryPage_MockupsAPI_Test#submitOrderWithMissingData: 108
|
21 | |
} |
| |
23 | 5 |
validateOrderItems(items);
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
|
| |
25 | 2 |
Order order = new Order(nextOrderNo++, customerId);
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
|
26 | 2 |
order.getItems().addAll(items);
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
|
| |
28 | 2 |
new OrderRepository().create(order);
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
|
| |
30 | 2 |
return order;
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- 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
|
35 | 5 |
for (OrderItem item : items) {
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
|
36 | 8 |
if (item.getQuantity() <= 0 || item.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0) {
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
|
37 | 2 |
throw new InvalidOrderItem("Quantity=" + item.getQuantity() + ", Unit Price=" + item.getUnitPrice());
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemUnitPrice: 83
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithInvalidItemQuantity: 75
|
38 | |
} |
39 | 6 |
}
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93x2
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38x2
|
| |
41 | 3 |
if (new HashSet<>(items).size() < items.size()) {
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
|
42 | 1 |
throw new DuplicateOrderItem();
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrderWithDuplicateItem: 93
|
43 | |
} |
44 | 2 |
}
- orderMngr.domain.order.OrderFactoryTest#createOrder: 33
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
|
45 | |
} |