mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
refactor(core): build every Smithy validation error through SmithyValidationErrors (#5910)
SmithyValidationErrors gains named factories for the three common codes (validationException, validationError, badRequest) and a single-violation overload of each. The "N validation errors detected" builders outside SES (CloudFormation, Cognito, DynamoDB, EventBridge, Firehose, IAM, IoT, KMS, Lambda, Rekognition, SSM) and the remaining hand-written "1 validation error detected" messages in SES move onto it. No message changes.
This commit is contained in:
1 parent
63af5cd299
commit
b55014ddef
38 files changed
+212
-187
No files matched your search
@@ -29,6 +29,22 @@ class SmithyValidationErrorsTest {
|
||||
assertEquals(400, e.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void namedFactories_carryTheirProtocolsCode() {
|
||||
assertEquals("ValidationException", SmithyValidationErrors.validationException(List.of("v")).getErrorCode());
|
||||
assertEquals("ValidationError", SmithyValidationErrors.validationError(List.of("v")).getErrorCode());
|
||||
assertEquals("BadRequestException", SmithyValidationErrors.badRequest(List.of("v")).getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void stringOverloads_reportOneViolation() {
|
||||
String expected = "1 validation error detected: v";
|
||||
assertEquals(expected, SmithyValidationErrors.badRequest("v").getMessage());
|
||||
assertEquals(expected, SmithyValidationErrors.validationError("v").getMessage());
|
||||
assertEquals(expected, SmithyValidationErrors.validationException("v").getMessage());
|
||||
assertEquals(expected, SmithyValidationErrors.exception("InvalidParameterException", "v").getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void noViolations_isAProgrammingError() {
|
||||
assertThrows(IllegalArgumentException.class, () -> SmithyValidationErrors.message(List.of()));
|
||||
|
||||
Reference in new issue
Block a user