orderMngmntWebapp\src\orderMngr\domain\order\OrderRepository.java
| |
5 | |
package orderMngr.domain.order; |
| |
| |
import java.math.*;
import java.sql.*;
import java.util.*;
import static orderMngr.service.Database.*;
import ...
|
| |
13 | 11 |
public final class OrderRepository
- orderMngr.domain.order.OrderFactory_MockupsAPI_Test#createOrder: 38
|
14 | |
{ |
15 | |
public void create(Order order) |
16 | |
{ |
| 2 |
Path coverage: 1/2
A: 0
B: 2
|
17 | 2 |
String sql = "insert into order (number, customer_id) values (?, ?)";
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
18 | 2 |
int orderNo = order.getNumber();
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
19 | 2 |
executeInsertUpdateOrDelete(sql, orderNo, order.getCustomerId());
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
| |
21 | 2 |
for (OrderItem item : order.getItems()) {
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
22 | 4 |
executeInsertUpdateOrDelete(
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32x2
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61x2
|
23 | |
"insert into order_item (order_no, product_id, product_desc, quantity, unit_price) values (?, ?, ?, ?, ?)", |
24 | 2 |
orderNo, item.getProductId(), item.getProductDescription(), item.getQuantity(),
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
25 | 2 |
item.getUnitPrice());
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
26 | 2 |
}
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
27 | 2 |
}
- orderMngr.domain.order.OrderRepositoryTest#createOrder: 32
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#createOrder: 61
|
| |
29 | |
public void update(Order order) |
30 | |
{ |
31 | 2 |
String sql = "update order set customer_id=? where number=?";
- orderMngr.domain.order.OrderRepositoryTest#updateOrder: 50
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#updateOrder: 81
|
32 | 2 |
executeInsertUpdateOrDelete(sql, order.getCustomerId(), order.getNumber());
- orderMngr.domain.order.OrderRepositoryTest#updateOrder: 50
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#updateOrder: 81
|
33 | 2 |
}
- orderMngr.domain.order.OrderRepositoryTest#updateOrder: 50
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#updateOrder: 81
|
| |
35 | |
public void remove(Order order) |
36 | |
{ |
37 | 2 |
String sql = "delete from order where number=?";
- orderMngr.domain.order.OrderRepositoryTest#removeOrder: 62
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#removeOrder: 98
|
38 | 2 |
executeInsertUpdateOrDelete(sql, order.getNumber());
- orderMngr.domain.order.OrderRepositoryTest#removeOrder: 62
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#removeOrder: 98
|
39 | 2 |
}
- orderMngr.domain.order.OrderRepositoryTest#removeOrder: 62
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#removeOrder: 98
|
| |
41 | |
public Order findByNumber(int orderNumber) |
42 | |
{ |
43 | |
try { |
44 | 2 |
return loadOrder(orderNumber);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
45 | |
} |
46 | 0 |
catch (SQLException e) {
|
47 | 0 |
throw new RuntimeException(e);
|
48 | |
} |
49 | |
} |
| |
51 | |
private Order loadOrder(int orderNumber) throws SQLException |
52 | |
{ |
| 2 |
Path coverage: 1/2
A: 2
B: 0
|
53 | 2 |
ResultSet result = executeQuery("select customer_id from order where number=?", orderNumber);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
| |
55 | |
try { |
56 | 2 |
if (result.next()) {
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
57 | 2 |
String customerId = result.getString(1);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
58 | 2 |
Order order = new Order(orderNumber, customerId);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
59 | 2 |
loadOrderItems(order);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
60 | 2 |
return order;
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
61 | |
} |
| |
63 | 0 |
return null;
|
64 | |
} |
65 | |
finally { |
66 | 2 |
closeStatement(result);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
67 | |
} |
68 | |
} |
| |
70 | |
private void loadOrderItems(Order order) throws SQLException |
71 | |
{ |
| 2 |
Path coverage: 1/2
A: 0
B: 2
|
72 | 2 |
ResultSet result =
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
73 | 2 |
executeQuery(
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
74 | |
"select product_id, product_desc, quantity, unit_price from order_item where order_number=?", |
75 | 2 |
order.getNumber());
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
| |
77 | |
try { |
78 | 4 |
while (result.next()) {
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58x2
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169x2
|
79 | 2 |
String productId = result.getString(1);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
80 | 2 |
String productDescription = result.getString(2);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
81 | 2 |
int quantity = result.getInt(3);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
82 | 2 |
BigDecimal unitPrice = result.getBigDecimal(4);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
| |
84 | 2 |
OrderItem item = new OrderItem(order, productId, productDescription, quantity, unitPrice);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
85 | 2 |
order.getItems().add(item);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
86 | 2 |
}
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
87 | |
} |
88 | |
finally { |
89 | 2 |
closeStatement(result);
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
90 | 2 |
}
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
91 | 2 |
}
- orderMngr.domain.order.OrderFindersTest#findOrderByNumber: 58
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByNumber: 169
|
| |
93 | |
public List<Order> findByCustomer(String customerId) |
94 | |
{ |
| 2 |
Path coverage: 1/2
A: 0
B: 2
|
95 | 2 |
ResultSet result = executeQuery("select number from order where customer_id=?", customerId);
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
| |
97 | |
try { |
98 | 2 |
List<Order> orders = new ArrayList<>();
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
| |
100 | 4 |
while (result.next()) {
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85x2
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182x2
|
101 | 2 |
int orderNumber = result.getInt(1);
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
102 | 2 |
Order order = new Order(orderNumber, customerId);
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
103 | 2 |
loadOrderItems(order);
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
104 | 2 |
orders.add(order);
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
105 | 2 |
}
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
| |
107 | 2 |
return orders;
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
108 | |
} |
109 | 0 |
catch (SQLException e) {
|
110 | 0 |
throw new RuntimeException(e);
|
111 | |
} |
112 | |
finally { |
113 | 2 |
closeStatement(result);
- orderMngr.domain.order.OrderFindersTest#findOrderByCustomer: 85
- orderMngr.domain.order.OrderRepository_MockupsAPI_Test#findOrderByCustomer: 182
|
114 | |
} |
115 | |
} |
116 | |
} |