Search in sources :

Example 1 with JaxrsApplicationParser

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

the class JaxrsApplicationTest method testExcludedType.

@Test
public void testExcludedType() {
    final Settings settings = TestUtils.settings();
    settings.setExcludeFilter(Arrays.asList(A.class.getName(), J.class.getName()), null);
    final JaxrsApplicationParser jaxrsApplicationParser = createJaxrsApplicationParser(settings);
    final JaxrsApplicationParser.Result result = jaxrsApplicationParser.tryParse(new SourceType<>(TestResource1.class));
    Assertions.assertNotNull(result);
    Assertions.assertTrue(!getTypes(result.discoveredTypes).contains(A.class));
    Assertions.assertTrue(getTypes(result.discoveredTypes).contains(JGenericArrayType.of(J[].class)));
}
Also used : JaxrsApplicationParser(cz.habarta.typescript.generator.parser.JaxrsApplicationParser) Test(org.junit.jupiter.api.Test)

Example 2 with JaxrsApplicationParser

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

the class JaxrsApplicationTest method testReturnedTypesFromResource.

@Test
public void testReturnedTypesFromResource() {
    JaxrsApplicationParser jaxrsApplicationParser = createJaxrsApplicationParser(TestUtils.settings());
    final JaxrsApplicationParser.Result result = jaxrsApplicationParser.tryParse(new SourceType<>(TestResource1.class));
    Assertions.assertNotNull(result);
    List<Type> types = getTypes(result.discoveredTypes);
    final List<Type> expectedTypes = Arrays.asList(A.class, new TypeReference<List<B>>() {
    }.getType(), C.class, new TypeReference<List<D>>() {
    }.getType(), List.class, E.class, new TypeReference<List<F>>() {
    }.getType(), G.class, new TypeReference<Map<String, H>>() {
    }.getType(), I.class, JGenericArrayType.of(J[].class), // types handled by DefaultTypeProcessor
    String.class, Boolean.class, Character.class, Number.class, Integer.class, int.class, void.class);
    assertHasSameItems(expectedTypes, types);
}
Also used : JGenericArrayType(cz.habarta.typescript.generator.type.JGenericArrayType) MediaType(jakarta.ws.rs.core.MediaType) Type(java.lang.reflect.Type) SourceType(cz.habarta.typescript.generator.parser.SourceType) JaxrsApplicationParser(cz.habarta.typescript.generator.parser.JaxrsApplicationParser) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.jupiter.api.Test)

Example 3 with JaxrsApplicationParser

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

the class JaxrsApplicationTest method createJaxrsApplicationParser.

private static JaxrsApplicationParser createJaxrsApplicationParser(Settings settings) {
    final TypeProcessor typeProcessor = new TypeScriptGenerator(settings).getCommonTypeProcessor();
    final JaxrsApplicationParser jaxrsApplicationParser = new JaxrsApplicationParser(settings, typeProcessor);
    return jaxrsApplicationParser;
}
Also used : JaxrsApplicationParser(cz.habarta.typescript.generator.parser.JaxrsApplicationParser)

Aggregations

JaxrsApplicationParser (cz.habarta.typescript.generator.parser.JaxrsApplicationParser)3 Test (org.junit.jupiter.api.Test)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 SourceType (cz.habarta.typescript.generator.parser.SourceType)1 JGenericArrayType (cz.habarta.typescript.generator.type.JGenericArrayType)1 MediaType (jakarta.ws.rs.core.MediaType)1 Type (java.lang.reflect.Type)1