use of cz.habarta.typescript.generator.emitter.TsBooleanLiteral in project typescript-generator by vojtechhabarta.
the class DecoratorsTest method testDecoratorsOnParameterAndMethod.
@Test
public void testDecoratorsOnParameterAndMethod() {
final Settings settings = TestUtils.settings();
settings.outputFileType = TypeScriptFileType.implementationFile;
settings.outputKind = TypeScriptOutputKind.module;
settings.mapClasses = ClassMapping.asClasses;
settings.generateConstructors = true;
final TypeScriptGenerator typeScriptGenerator = new TypeScriptGenerator(settings);
final Model model = typeScriptGenerator.getModelParser().parseModel(City.class);
final TsModel tsModel = typeScriptGenerator.getModelCompiler().javaToTypeScript(model);
final TsBeanModel bean = tsModel.getBean(City.class);
final TsBeanModel bean2 = bean.withConstructor(bean.getConstructor().withParameters(Arrays.asList(bean.getConstructor().getParameters().get(0).withDecorators(Arrays.asList(new TsDecorator(new TsIdentifierReference("Inject"), Arrays.asList(new TsStringLiteral("token")))))))).withMethods(Arrays.asList(new TsMethodModel("greet", null, null, Collections.emptyList(), TsType.Void, Collections.emptyList(), null).withDecorators(Arrays.asList(new TsDecorator(new TsIdentifierReference("enumerable"), Arrays.asList(new TsBooleanLiteral(false)))))));
final TsModel tsModel2 = tsModel.withBeans(Arrays.asList(bean2));
final String output = emit(typeScriptGenerator.getEmitter(), tsModel2);
Assertions.assertTrue(output.contains("@Inject(\"token\")"));
Assertions.assertTrue(output.contains("@enumerable(false)"));
}
Aggregations