Search in sources :

Example 1 with TypeProcessor

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

the class BeanPropertyPathExtensionTest method basicTest.

@Test
public void basicTest() throws Exception {
    final StringBuilder data = new StringBuilder();
    final EmitterExtension.Writer writer = new EmitterExtension.Writer() {

        @Override
        public void writeIndentedLine(String line) {
            data.append(line + "\n");
        }
    };
    final Settings settings = new Settings();
    settings.sortDeclarations = true;
    final TypeProcessor typeProcessor = new DefaultTypeProcessor();
    final Model model = new Jackson2Parser(settings, typeProcessor).parseModel(ClassA.class);
    final TsModel tsModel = new ModelCompiler(settings, typeProcessor).javaToTypeScript(model);
    new BeanPropertyPathExtension().emitElements(writer, settings, false, tsModel);
    String dataStr = data.toString();
    final String expected = Utils.readString(getClass().getResourceAsStream("/ext/expected.ts"), "\n");
    Assert.assertEquals(expected.trim(), dataStr.trim());
}
Also used : Jackson2Parser(cz.habarta.typescript.generator.parser.Jackson2Parser) EmitterExtension(cz.habarta.typescript.generator.emitter.EmitterExtension) DefaultTypeProcessor(cz.habarta.typescript.generator.DefaultTypeProcessor) TsModel(cz.habarta.typescript.generator.emitter.TsModel) ModelCompiler(cz.habarta.typescript.generator.compiler.ModelCompiler) TypeProcessor(cz.habarta.typescript.generator.TypeProcessor) DefaultTypeProcessor(cz.habarta.typescript.generator.DefaultTypeProcessor) Model(cz.habarta.typescript.generator.parser.Model) TsModel(cz.habarta.typescript.generator.emitter.TsModel) Settings(cz.habarta.typescript.generator.Settings) Test(org.junit.Test)

Aggregations

DefaultTypeProcessor (cz.habarta.typescript.generator.DefaultTypeProcessor)1 Settings (cz.habarta.typescript.generator.Settings)1 TypeProcessor (cz.habarta.typescript.generator.TypeProcessor)1 ModelCompiler (cz.habarta.typescript.generator.compiler.ModelCompiler)1 EmitterExtension (cz.habarta.typescript.generator.emitter.EmitterExtension)1 TsModel (cz.habarta.typescript.generator.emitter.TsModel)1 Jackson2Parser (cz.habarta.typescript.generator.parser.Jackson2Parser)1 Model (cz.habarta.typescript.generator.parser.Model)1 Test (org.junit.Test)1