feat(wechat): 抽象通知发送器并完善自定义下单相关接口测试
This commit is contained in:
@@ -86,6 +86,16 @@ class WxCustomSpecifiedOrderApiTest extends WxCustomOrderApiTestSupport {
|
||||
.one();
|
||||
Assertions.assertThat(order).isNotNull();
|
||||
|
||||
PlayCouponDetailsEntity detailBeforeForceCancel = couponDetailsService.getById(couponDetailId);
|
||||
Assertions.assertThat(detailBeforeForceCancel).isNotNull();
|
||||
Assertions.assertThat(detailBeforeForceCancel.getUseState()).isEqualTo(CouponUseState.USED.getCode());
|
||||
Assertions.assertThat(detailBeforeForceCancel.getUseTime()).isNotNull();
|
||||
|
||||
PlayCouponDetailsEntity detailBeforeCancel = couponDetailsService.getById(couponDetailId);
|
||||
Assertions.assertThat(detailBeforeCancel).isNotNull();
|
||||
Assertions.assertThat(detailBeforeCancel.getUseState()).isEqualTo(CouponUseState.USED.getCode());
|
||||
Assertions.assertThat(detailBeforeCancel.getUseTime()).isNotNull();
|
||||
|
||||
String cancelPayload = "{" +
|
||||
"\"orderId\":\"" + order.getId() + "\"," +
|
||||
"\"refundReason\":\"测试取消\"," +
|
||||
@@ -106,9 +116,11 @@ class WxCustomSpecifiedOrderApiTest extends WxCustomOrderApiTestSupport {
|
||||
Assertions.assertThat(cancelled.getOrderStatus()).isEqualTo(OrderConstant.OrderStatus.CANCELLED.getCode());
|
||||
|
||||
PlayCouponDetailsEntity detail = couponDetailsService.getById(couponDetailId);
|
||||
Assertions.assertThat(detail).isNotNull();
|
||||
Assertions.assertThat(detail.getUseState())
|
||||
.as("取消指定单后优惠券应恢复为未使用")
|
||||
.isEqualTo(CouponUseState.UNUSED.getCode());
|
||||
Assertions.assertThat(detail.getUseTime()).isNull();
|
||||
} finally {
|
||||
CustomSecurityContextHolder.remove();
|
||||
}
|
||||
@@ -172,6 +184,11 @@ class WxCustomSpecifiedOrderApiTest extends WxCustomOrderApiTestSupport {
|
||||
Assertions.assertThat(order.getFinalAmount()).isEqualByComparingTo(expectedNet);
|
||||
Assertions.assertThat(order.getDiscountAmount()).isEqualByComparingTo(discount);
|
||||
|
||||
PlayCouponDetailsEntity detailAfterOrder = couponDetailsService.getById(couponDetailId);
|
||||
Assertions.assertThat(detailAfterOrder).isNotNull();
|
||||
Assertions.assertThat(detailAfterOrder.getUseState()).isEqualTo(CouponUseState.USED.getCode());
|
||||
Assertions.assertThat(detailAfterOrder.getUseTime()).isNotNull();
|
||||
|
||||
verify(wxCustomMpService).sendCreateOrderMessage(
|
||||
eq(ApiTestDataSeeder.DEFAULT_TENANT_ID),
|
||||
eq(ApiTestDataSeeder.DEFAULT_CLERK_OPEN_ID),
|
||||
@@ -194,6 +211,10 @@ class WxCustomSpecifiedOrderApiTest extends WxCustomOrderApiTestSupport {
|
||||
Assertions.assertThat(order.getEstimatedRevenue()).isEqualByComparingTo(expectedRevenue);
|
||||
|
||||
assertCouponUsed(couponDetailId);
|
||||
PlayCouponDetailsEntity detailAfterComplete = couponDetailsService.getById(couponDetailId);
|
||||
Assertions.assertThat(detailAfterComplete).isNotNull();
|
||||
Assertions.assertThat(detailAfterComplete.getUseState()).isEqualTo(CouponUseState.USED.getCode());
|
||||
Assertions.assertThat(detailAfterComplete.getUseTime()).isNotNull();
|
||||
} finally {
|
||||
CustomSecurityContextHolder.remove();
|
||||
}
|
||||
@@ -273,9 +294,11 @@ class WxCustomSpecifiedOrderApiTest extends WxCustomOrderApiTestSupport {
|
||||
Assertions.assertThat(cancelled.getOrderStatus()).isEqualTo(OrderConstant.OrderStatus.CANCELLED.getCode());
|
||||
|
||||
PlayCouponDetailsEntity detail = couponDetailsService.getById(couponDetailId);
|
||||
Assertions.assertThat(detail).isNotNull();
|
||||
Assertions.assertThat(detail.getUseState())
|
||||
.as("强制取消指定单后优惠券应恢复为未使用")
|
||||
.isEqualTo(CouponUseState.UNUSED.getCode());
|
||||
Assertions.assertThat(detail.getUseTime()).isNull();
|
||||
} finally {
|
||||
CustomSecurityContextHolder.remove();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user