From 3cf3669433595c0ddf72c12ca3cb284bb87c378e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Sugawara=20=28=E2=88=A9=EF=BD=80-=C2=B4=29?= =?UTF-8?q?=E2=8A=83=E2=94=81=E7=82=8E=E7=82=8E=E7=82=8E=E7=82=8E=E7=82=8E?= Date: Thu, 16 Nov 2023 10:50:27 -0800 Subject: [PATCH] Relax the service name validation to allow one char names --- .../amazon/smithy/aws/traits/SdkServiceIdValidator.java | 4 ++-- .../amazon/smithy/aws/traits/SdkServiceIdValidatorTest.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/SdkServiceIdValidator.java b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/SdkServiceIdValidator.java index 2e7101a52a6..9c97c30a4ed 100644 --- a/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/SdkServiceIdValidator.java +++ b/smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/SdkServiceIdValidator.java @@ -114,8 +114,8 @@ public static void validateServiceId(String serviceId) { messages.add(String.format("Must not case-insensitively end with `%s`", suffix)); }); - if (serviceId.length() < 2 || serviceId.length() > 50) { - messages.add("Must be between 2 and 50 characters long."); + if (serviceId.isEmpty() || serviceId.length() > 50) { + messages.add("Must be between 1 and 50 characters long."); } if (!messages.isEmpty()) { diff --git a/smithy-aws-traits/src/test/java/software/amazon/smithy/aws/traits/SdkServiceIdValidatorTest.java b/smithy-aws-traits/src/test/java/software/amazon/smithy/aws/traits/SdkServiceIdValidatorTest.java index 0321c121c78..1b6fa22272f 100644 --- a/smithy-aws-traits/src/test/java/software/amazon/smithy/aws/traits/SdkServiceIdValidatorTest.java +++ b/smithy-aws-traits/src/test/java/software/amazon/smithy/aws/traits/SdkServiceIdValidatorTest.java @@ -76,9 +76,9 @@ public void noTrailingWhitespace() { @Test public void doesNotAllowShortIds() { IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () -> - SdkServiceIdValidator.validateServiceId("F")); + SdkServiceIdValidator.validateServiceId("")); - assertThat(thrown.getMessage(), containsString("2 and 50")); + assertThat(thrown.getMessage(), containsString("1 and 50")); } @Test @@ -86,6 +86,6 @@ public void doesNotAllowLongIds() { IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () -> SdkServiceIdValidator.validateServiceId("Foobarbazqux Foobarbazqux Foobarbazqux Foobarbazqux")); - assertThat(thrown.getMessage(), containsString("2 and 50")); + assertThat(thrown.getMessage(), containsString("1 and 50")); } }