Search in sources :

Example 6 with Model

use of cz.habarta.typescript.generator.parser.Model in project typescript-generator by vojtechhabarta.

the class NumberEnumTest method testParser.

@Test
public void testParser() {
    final Settings settings = TestUtils.settings();
    final ModelParser parser = new TypeScriptGenerator(settings).getModelParser();
    final Model model = parser.parseModel(SomeCode.class);
    Assert.assertEquals(1, model.getEnums().size());
    final EnumModel enumModel = model.getEnums().get(0);
    Assert.assertEquals(EnumKind.NumberBased, enumModel.getKind());
    Assert.assertEquals(2, enumModel.getMembers().size());
    Assert.assertEquals(10, ((Number) enumModel.getMembers().get(0).getEnumValue()).intValue());
    Assert.assertEquals(11, ((Number) enumModel.getMembers().get(1).getEnumValue()).intValue());
}
Also used : EnumModel(cz.habarta.typescript.generator.parser.EnumModel) EnumModel(cz.habarta.typescript.generator.parser.EnumModel) Model(cz.habarta.typescript.generator.parser.Model) ModelParser(cz.habarta.typescript.generator.parser.ModelParser) Test(org.junit.Test)

Aggregations

Model (cz.habarta.typescript.generator.parser.Model)6 ModelCompiler (cz.habarta.typescript.generator.compiler.ModelCompiler)5 TsModel (cz.habarta.typescript.generator.emitter.TsModel)5 Jackson2Parser (cz.habarta.typescript.generator.parser.Jackson2Parser)4 Test (org.junit.Test)3 EmitterExtension (cz.habarta.typescript.generator.emitter.EmitterExtension)2 JsonSerialize (com.fasterxml.jackson.databind.annotation.JsonSerialize)1 Converter (com.fasterxml.jackson.databind.util.Converter)1 DefaultTypeProcessor (cz.habarta.typescript.generator.DefaultTypeProcessor)1 Settings (cz.habarta.typescript.generator.Settings)1 TypeProcessor (cz.habarta.typescript.generator.TypeProcessor)1 ModelTransformer (cz.habarta.typescript.generator.compiler.ModelTransformer)1 SymbolTable (cz.habarta.typescript.generator.compiler.SymbolTable)1 EmitterExtensionFeatures (cz.habarta.typescript.generator.emitter.EmitterExtensionFeatures)1 EnumConstantsExtension (cz.habarta.typescript.generator.ext.EnumConstantsExtension)1 BeanModel (cz.habarta.typescript.generator.parser.BeanModel)1 EnumModel (cz.habarta.typescript.generator.parser.EnumModel)1 ModelParser (cz.habarta.typescript.generator.parser.ModelParser)1 PropertyModel (cz.habarta.typescript.generator.parser.PropertyModel)1 Field (java.lang.reflect.Field)1