test: 收紧出库单创建契约校验
This commit is contained in:
@@ -7,7 +7,11 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("local")
|
||||
@@ -17,9 +21,17 @@ class IostorInvServiceLocalSpringTest {
|
||||
private IostorInvService iostorInvService;
|
||||
|
||||
@Test
|
||||
void createOutboundShouldRejectEmptyRequest() {
|
||||
void createOutboundShouldRejectEmptyDetails() {
|
||||
IostorInvCreateReqVO reqVO = new IostorInvCreateReqVO();
|
||||
reqVO.setBillType("OUTBOUND");
|
||||
reqVO.setStorId("stor-1");
|
||||
reqVO.setBizDate(LocalDateTime.now());
|
||||
reqVO.setDetails(Collections.emptyList());
|
||||
|
||||
assertThrows(ConstraintViolationException.class, () -> iostorInvService.createOutbound(reqVO));
|
||||
ConstraintViolationException exception = assertThrows(ConstraintViolationException.class,
|
||||
() -> iostorInvService.createOutbound(reqVO));
|
||||
|
||||
assertTrue(exception.getConstraintViolations().stream()
|
||||
.anyMatch(violation -> violation.getPropertyPath().toString().contains("details")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user