fix: prevent duplicate delivery assignments
This commit is contained in:
@@ -69,6 +69,18 @@ class DeliveryAssignmentServiceTests {
|
||||
.hasMessageContaining("自提订单无需派单");
|
||||
}
|
||||
|
||||
@Test
|
||||
void cannotAssignSameGoodsOrderTwice() {
|
||||
TestFixture fixture = new TestFixture();
|
||||
GoodsOrderResponse order = fixture.preparedDeliveryOrder();
|
||||
DeliveryUserResponse rider = fixture.rider();
|
||||
|
||||
fixture.assignmentService.assignGoodsOrder(order.getId(), rider.getId());
|
||||
|
||||
assertThatThrownBy(() -> fixture.assignmentService.assignGoodsOrder(order.getId(), rider.getId()))
|
||||
.hasMessageContaining("订单已派单");
|
||||
}
|
||||
|
||||
private static class TestFixture {
|
||||
private final ProductService productService = new ProductService();
|
||||
private final GoodsOrderService goodsOrderService = new GoodsOrderService(productService);
|
||||
|
||||
Reference in New Issue
Block a user