### Question:
EnumGenerator implements Runnable { @Override public void run() { if (!enumTrait.hasNames()) { generateUnnamedEnum(); } else { generateNamedEnum(); } } EnumGenerator(StringShape shape, Symbol symbol, TypeScriptWriter writer); @Override void run();  }### Answer:
@Test public void generatesNamedEnums() { EnumTrait trait = EnumTrait.builder() .addEnum(EnumDefinition.builder().value("FOO").name("FOO").build()) .addEnum(EnumDefinition.builder().value("BAR").name("BAR").build()) .build(); StringShape shape = StringShape.builder().id("com.foo#Baz").addTrait(trait).build(); TypeScriptWriter writer = new TypeScriptWriter("foo"); Symbol symbol = TypeScriptCodegenPlugin.createSymbolProvider(Model.builder().build()).toSymbol(shape); new EnumGenerator(shape, symbol, writer).run(); assertThat(writer.toString(), containsString("export enum Baz {")); assertThat(writer.toString(), containsString("FOO = \"FOO\"")); assertThat(writer.toString(), containsString("BAR = \"BAR\",")); }
@Test public void generatesUnnamedEnums() { EnumTrait trait = EnumTrait.builder() .addEnum(EnumDefinition.builder().value("FOO").build()) .addEnum(EnumDefinition.builder().value("BAR").build()) .build(); StringShape shape = StringShape.builder().id("com.foo#Baz").addTrait(trait).build(); TypeScriptWriter writer = new TypeScriptWriter("foo"); Symbol symbol = TypeScriptCodegenPlugin.createSymbolProvider(Model.builder().build()).toSymbol(shape); new EnumGenerator(shape, symbol, writer).run(); assertThat(writer.toString(), containsString("export type Baz = \"BAR\" | \"FOO\"")); }