Search in sources :

Example 1 with BeanModel

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

the class Jackson2ParserTest method testRegisteredSubtypeName.

@Test
public void testRegisteredSubtypeName() {
    final Jackson2Parser jacksonParser = getJackson2Parser();
    final Model model = jacksonParser.parseModel(SubTypeDiscriminatedByName5.class);
    final BeanModel bean5 = model.getBean(SubTypeDiscriminatedByName5.class);
    Assertions.assertEquals("NamedByModule", bean5.getDiscriminantLiteral());
}
Also used : Jackson2Parser(cz.habarta.typescript.generator.parser.Jackson2Parser) BeanModel(cz.habarta.typescript.generator.parser.BeanModel) BeanModel(cz.habarta.typescript.generator.parser.BeanModel) EnumModel(cz.habarta.typescript.generator.parser.EnumModel) Model(cz.habarta.typescript.generator.parser.Model) Test(org.junit.jupiter.api.Test)

Example 2 with BeanModel

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

the class Jackson2ParserTest method testChangedNameProperty.

@Test
public void testChangedNameProperty() {
    final Jackson2Parser jacksonParser = getJackson2Parser();
    final Model model = jacksonParser.parseModel(DummyBeanJackson2.class);
    Assertions.assertTrue(model.getBeans().size() > 0);
    final BeanModel beanModel = model.getBeans().get(0);
    Assertions.assertEquals("DummyBeanJackson2", beanModel.getOrigin().getSimpleName());
    Assertions.assertTrue(beanModel.getProperties().size() > 0);
    Assertions.assertEquals("changedNameProperty", beanModel.getProperties().get(0).getName());
}
Also used : Jackson2Parser(cz.habarta.typescript.generator.parser.Jackson2Parser) BeanModel(cz.habarta.typescript.generator.parser.BeanModel) BeanModel(cz.habarta.typescript.generator.parser.BeanModel) EnumModel(cz.habarta.typescript.generator.parser.EnumModel) Model(cz.habarta.typescript.generator.parser.Model) Test(org.junit.jupiter.api.Test)

Example 3 with BeanModel

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

the class Jackson2ParserTest method testConflictingJsonTypeInfoProperty.

@Test
public void testConflictingJsonTypeInfoProperty() {
    final Jackson2Parser jacksonParser = getJackson2Parser();
    final Model model = jacksonParser.parseModel(InheritedClass.class);
    Assertions.assertTrue(model.getBeans().size() > 0);
    final BeanModel beanModel = model.getBeans().get(0);
    Assertions.assertEquals(1, beanModel.getProperties().size());
}
Also used : Jackson2Parser(cz.habarta.typescript.generator.parser.Jackson2Parser) BeanModel(cz.habarta.typescript.generator.parser.BeanModel) BeanModel(cz.habarta.typescript.generator.parser.BeanModel) EnumModel(cz.habarta.typescript.generator.parser.EnumModel) Model(cz.habarta.typescript.generator.parser.Model) Test(org.junit.jupiter.api.Test)

Example 4 with BeanModel

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

the class OptionalAnnotationTest method testModel.

private void testModel(Model model, boolean optional) {
    Assertions.assertEquals(1, model.getBeans().size());
    BeanModel beanModel = model.getBeans().get(0);
    Assertions.assertEquals(2, beanModel.getProperties().size());
    for (PropertyModel propertyModel : beanModel.getProperties()) {
        Assertions.assertEquals(optional, propertyModel.isOptional());
    }
}
Also used : BeanModel(cz.habarta.typescript.generator.parser.BeanModel) PropertyModel(cz.habarta.typescript.generator.parser.PropertyModel)

Example 5 with BeanModel

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

the class JaxrsApplicationTest method testWithParsing.

private void testWithParsing(List<SourceType<Type>> types, boolean exactMatch) {
    final Model model = new TypeScriptGenerator(TestUtils.settings()).getModelParser().parseModel(types);
    final ArrayList<Class<?>> classes = new ArrayList<>();
    for (BeanModel beanModel : model.getBeans()) {
        classes.add(beanModel.getOrigin());
    }
    final List<Class<?>> expectedClasses = Arrays.asList(A.class, B.class, C.class, D.class, E.class, F.class, G.class, H.class, I.class, J.class);
    if (exactMatch) {
        assertHasSameItems(expectedClasses, classes);
    } else {
        Assertions.assertTrue(classes.containsAll(expectedClasses));
    }
}
Also used : BeanModel(cz.habarta.typescript.generator.parser.BeanModel) BeanModel(cz.habarta.typescript.generator.parser.BeanModel) Model(cz.habarta.typescript.generator.parser.Model) ArrayList(java.util.ArrayList)

Aggregations

BeanModel (cz.habarta.typescript.generator.parser.BeanModel)18 Model (cz.habarta.typescript.generator.parser.Model)10 TsBeanModel (cz.habarta.typescript.generator.emitter.TsBeanModel)8 ArrayList (java.util.ArrayList)8 EnumModel (cz.habarta.typescript.generator.parser.EnumModel)7 Test (org.junit.jupiter.api.Test)7 Jackson2Parser (cz.habarta.typescript.generator.parser.Jackson2Parser)6 TsType (cz.habarta.typescript.generator.TsType)5 TsModel (cz.habarta.typescript.generator.emitter.TsModel)5 PropertyModel (cz.habarta.typescript.generator.parser.PropertyModel)5 List (java.util.List)5 TsPropertyModel (cz.habarta.typescript.generator.emitter.TsPropertyModel)4 Type (java.lang.reflect.Type)4 ModelCompiler (cz.habarta.typescript.generator.compiler.ModelCompiler)3 EmitterExtensionFeatures (cz.habarta.typescript.generator.emitter.EmitterExtensionFeatures)3 ModelTransformer (cz.habarta.typescript.generator.compiler.ModelTransformer)2 SymbolTable (cz.habarta.typescript.generator.compiler.SymbolTable)2 TsEnumModel (cz.habarta.typescript.generator.emitter.TsEnumModel)2 TsMethodModel (cz.habarta.typescript.generator.emitter.TsMethodModel)2 TsParameterModel (cz.habarta.typescript.generator.emitter.TsParameterModel)2