diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/shapes/EnumShape.java b/smithy-model/src/main/java/software/amazon/smithy/model/shapes/EnumShape.java index 51748f65241..e8ade4e81f1 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/shapes/EnumShape.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/shapes/EnumShape.java @@ -294,6 +294,7 @@ public EnumShape build() { */ private void addSyntheticEnumTrait() { SyntheticEnumTrait.Builder builder = SyntheticEnumTrait.builder(); + builder.sourceLocation(getSourceLocation()); for (MemberShape member : members.get().values()) { try { builder.addEnum(EnumShape.enumDefinitionFromMember(member)); diff --git a/smithy-model/src/test/java/software/amazon/smithy/model/shapes/EnumShapeTest.java b/smithy-model/src/test/java/software/amazon/smithy/model/shapes/EnumShapeTest.java index 588f34a278a..2cb101c76ab 100644 --- a/smithy-model/src/test/java/software/amazon/smithy/model/shapes/EnumShapeTest.java +++ b/smithy-model/src/test/java/software/amazon/smithy/model/shapes/EnumShapeTest.java @@ -17,6 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Map; @@ -400,10 +401,13 @@ public void canConvertBaseString() { StringShape string = StringShape.builder() .id("ns.foo#bar") .addTrait(trait) + .source("bar.smithy", 1, 1) .build(); Optional optionalEnum = EnumShape.fromStringShape(string); assertTrue(optionalEnum.isPresent()); - assertEquals(trait.getValues(), optionalEnum.get().expectTrait(SyntheticEnumTrait.class).getValues()); + SyntheticEnumTrait syntheticEnumTrait = optionalEnum.get().expectTrait(SyntheticEnumTrait.class); + assertEquals(trait.getValues(), syntheticEnumTrait.getValues()); + assertNotNull(syntheticEnumTrait.getSourceLocation()); assertEquals(optionalEnum.get().getMember("foo").get(), MemberShape.builder()