### Question:
EnumGenerator extends SpecialFileGenerator { @Override public SingleResult generate(Class<?> javaClass) throws SingleFileGeneratorException { List<String> constants = new ArrayList<>(); for (Enum constant : ((Class<Enum<?>>) javaClass).getEnumConstants()) { constants.add(constant.name()); } StjsJavaScriptClassBuilder builder = new StjsJavaScriptClassBuilder(javaClass) .enumeration(javaClass, constants.toArray(new String[]{})).newLine(); Map<String, Object> enumConstValueGetters = getEnumConstValueGetters((Class<Enum<?>>) javaClass); for(String constantAndGetterName : enumConstValueGetters.keySet()) { builder.staticFunction(javaClass, constantAndGetterName) .code("return ").literal(enumConstValueGetters.get(constantAndGetterName)).semicolon() ._function(); } return new JavaScriptResult(builder.create()); }  @Override SingleResult generate(Class<?> javaClass); @Override boolean isGeneratable(Class<?> javaClass);  }### Answer:
@Test public void generateWithoutValues() throws SingleFileGeneratorException { EnumGenerator generator = new EnumGenerator(); String source = generator.generate(TestEnum.class).getSource(); assertThat(source, containsString("stjs.enumeration")); assertThat(source, containsString("'FIRST'")); assertThat(source, containsString("'SECOND'")); assertThat(source, containsString("'THIRD'")); }
@Test public void generateWithValues() throws SingleFileGeneratorException { EnumGenerator generator = new EnumGenerator(); String source = generator.generate(TestEnumWithValues.class).getSource(); assertThat(source, containsString("return 'Test'")); assertThat(source, containsString("return 'Bla'")); assertThat(source, containsString("return 42")); assertThat(source, containsString("return 17")); assertThat(source, containsString("return true")); assertThat(source, containsString("return false")); }