Search in sources :

Example 1 with ApplicationSection

use of org.kie.kogito.codegen.api.ApplicationSection in project kogito-runtimes by kiegroup.

the class DecisionCodegenTest method assertNotEmptySectionCompilationUnit.

protected AbstractStringAssert<?> assertNotEmptySectionCompilationUnit(DecisionCodegen codeGenerator) {
    Optional<ApplicationSection> optionalApplicationSection = codeGenerator.section();
    assertThat(optionalApplicationSection).isNotEmpty();
    CompilationUnit compilationUnit = optionalApplicationSection.get().compilationUnit();
    assertThat(compilationUnit).isNotNull();
    return assertThat(compilationUnit.toString());
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ApplicationSection(org.kie.kogito.codegen.api.ApplicationSection)

Example 2 with ApplicationSection

use of org.kie.kogito.codegen.api.ApplicationSection in project kogito-runtimes by kiegroup.

the class PredictionCodegenTest method generateAllFiles.

private static void generateAllFiles(KogitoBuildContext context, PredictionCodegen codeGenerator, int expectedTotalFiles, int expectedJavaSources, int expectedRestEndpoints, boolean assertReflect) {
    Collection<GeneratedFile> generatedFiles = codeGenerator.generate();
    int expectedGeneratedFilesSize = expectedTotalFiles - (context.hasRESTForGenerator(codeGenerator) ? 0 : expectedRestEndpoints * 2);
    assertEquals(expectedGeneratedFilesSize, generatedFiles.size());
    assertEquals(expectedJavaSources, generatedFiles.stream().filter(generatedFile -> generatedFile.category().equals(GeneratedFileType.Category.SOURCE) && generatedFile.type().name().equals(PMML) && generatedFile.relativePath().endsWith(".java")).count());
    int expectedReflectResource = assertReflect ? 1 : 0;
    assertEquals(expectedReflectResource, generatedFiles.stream().filter(generatedFile -> generatedFile.category().equals(GeneratedFileType.Category.INTERNAL_RESOURCE) && generatedFile.type().name().equals(GeneratedFileType.INTERNAL_RESOURCE.name()) && generatedFile.relativePath().endsWith(REFLECT_JSON)).count());
    assertEndpoints(context, generatedFiles, expectedRestEndpoints, codeGenerator);
    Optional<ApplicationSection> optionalApplicationSection = codeGenerator.section();
    assertTrue(optionalApplicationSection.isPresent());
    CompilationUnit compilationUnit = optionalApplicationSection.get().compilationUnit();
    assertNotNull(compilationUnit);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ApplicationSection(org.kie.kogito.codegen.api.ApplicationSection) GeneratedFile(org.kie.kogito.codegen.api.GeneratedFile)

Aggregations

CompilationUnit (com.github.javaparser.ast.CompilationUnit)2 ApplicationSection (org.kie.kogito.codegen.api.ApplicationSection)2 GeneratedFile (org.kie.kogito.codegen.api.GeneratedFile)1