提交
This commit is contained in:
+13
@@ -10,6 +10,19 @@ import java.util.List;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
class ProcurementRequestBoundaryTest {
|
||||
@Test void purchaseCategoryMayBeOmittedOrBlankButCannotExceedLimit() throws Exception {
|
||||
var json = new ObjectMapper();
|
||||
try (var factory = jakarta.validation.Validation.buildDefaultValidatorFactory()) {
|
||||
var validator = factory.getValidator();
|
||||
for (String category : List.of("null", "\"\"", "\"sample\"")) {
|
||||
var request = json.readValue("{\"purchaseCategory\":" + category + "}", OverseasProcurementRequests.Create.class);
|
||||
assertThat(validator.validate(request)).noneMatch(v -> "purchaseCategory".equals(v.getPropertyPath().toString()));
|
||||
}
|
||||
var oversized = json.readValue("{\"purchaseCategory\":\"" + "x".repeat(129) + "\"}", OverseasProcurementRequests.Create.class);
|
||||
assertThat(validator.validate(oversized)).anyMatch(v -> "purchaseCategory".equals(v.getPropertyPath().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test void createRejectsMultiProductAndBatchExtensionsWithApplicationJacksonDefaults() {
|
||||
new org.springframework.boot.test.context.runner.ApplicationContextRunner()
|
||||
.withConfiguration(org.springframework.boot.autoconfigure.AutoConfigurations.of(
|
||||
|
||||
Reference in New Issue
Block a user