优化
This commit is contained in:
+35
@@ -5,15 +5,21 @@ import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.firstleg.dto.ExceptionReleaseRequest;
|
||||
import com.baiyue.firstleg.dto.MeasurementReviewRequest;
|
||||
import com.baiyue.firstleg.service.AutomaticInboundCompletionService;
|
||||
import com.baiyue.firstleg.service.MeasurementReviewService;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@DisplayName("入库测量审核控制器契约")
|
||||
class InboundMeasurementReviewContractTest {
|
||||
@@ -40,11 +46,40 @@ class InboundMeasurementReviewContractTest {
|
||||
.contains("/api/platform/v1/inbounds/{inboundId}/measurements/reject:")
|
||||
.contains("firstleg:inbound:exception-release")
|
||||
.contains("Idempotency-Key")
|
||||
.contains("审核事务提交后服务端自动执行计费")
|
||||
.contains("接口不会伪造 WAIT_SPLIT")
|
||||
.contains("成功 data 为 FeeSnapshotResponse,nextStatus=WAIT_SPLIT")
|
||||
.contains("name: inboundId")
|
||||
.contains("schema: {type: string, pattern:")
|
||||
.doesNotContain("待客户确认");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("审核事务完成后才启动自动编排并返回真实费用快照")
|
||||
void shouldCompleteApprovedReviewAfterReviewTransactionReturns() {
|
||||
MeasurementReviewService review = mock(MeasurementReviewService.class);
|
||||
AutomaticInboundCompletionService completion = mock(AutomaticInboundCompletionService.class);
|
||||
PlatformInboundMeasurementReviewController controller = new PlatformInboundMeasurementReviewController();
|
||||
ReflectionTestUtils.setField(controller, "service", review);
|
||||
ReflectionTestUtils.setField(controller, "automaticCompletion", completion);
|
||||
AuthenticatedUser user = new AuthenticatedUser(9L, 0L, 0L, null,
|
||||
"客服", "PLATFORM", "WEB", Set.of("firstleg:inbound:measurement-review"));
|
||||
MeasurementReviewRequest request = new MeasurementReviewRequest(30L, 4, "通过");
|
||||
var fee = mock(com.baiyue.firstleg.dto.FbaPricingDtos.FeeSnapshotResponse.class);
|
||||
when(completion.completeApproved(10001L, 88L, 9L, "客服", 30L, 5)).thenReturn(fee);
|
||||
|
||||
var first = controller.approve(user, 10001L, 88L, "approve-1", request);
|
||||
var replay = controller.approve(user, 10001L, 88L, "approve-1", request);
|
||||
|
||||
assertThat(first.data()).isSameAs(fee);
|
||||
assertThat(replay.data()).isSameAs(fee);
|
||||
var ordered = inOrder(review, completion);
|
||||
ordered.verify(review).approve(10001L, 9L, "客服", 88L, "approve-1", request);
|
||||
ordered.verify(completion).completeApproved(10001L, 88L, 9L, "客服", 30L, 5);
|
||||
ordered.verify(review).approve(10001L, 9L, "客服", 88L, "approve-1", request);
|
||||
ordered.verify(completion).completeApproved(10001L, 88L, 9L, "客服", 30L, 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAuditAutomaticInboundCompletion() throws Exception {
|
||||
Method method = AutomaticInboundCompletionService.class.getDeclaredMethod("completeApproved",
|
||||
|
||||
Reference in New Issue
Block a user