Skip to content

Commit

Permalink
Add source location to Enum synthetic trait
Browse files Browse the repository at this point in the history
  • Loading branch information
daddykotex committed Jan 12, 2023
1 parent 8e68395 commit b116c8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -400,10 +401,13 @@ public void canConvertBaseString() {
StringShape string = StringShape.builder()
.id("ns.foo#bar")
.addTrait(trait)
.source("bar.smithy", 1, 1)
.build();
Optional<EnumShape> 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()
Expand Down

0 comments on commit b116c8f

Please sign in to comment.