use of org.drools.codegen.common.GeneratedFile in project kogito-runtimes by kiegroup.
the class CodegenSvgTest method testExportedSVGRenamedAndMoved.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void testExportedSVGRenamedAndMoved(KogitoBuildContext.Builder contextBuilder) {
KogitoBuildContext context = contextBuilder.withAddonsConfig(AddonsConfig.builder().withProcessSVG(true).build()).build();
Collection<CollectedResource> collectedResources = CollectedResourceProducer.fromPaths(BASE_PATH);
assertThat(collectedResources.stream().anyMatch(f -> f.resource().getSourcePath().endsWith(TEST_PROCESS_SOURCE))).isTrue();
assertThat(collectedResources.stream().anyMatch(f -> f.resource().getSourcePath().endsWith(TEST_PROCESS_GENERATED_SVG_SOURCE))).isTrue();
assertThat(collectedResources.stream().anyMatch(f -> f.resource().getSourcePath().endsWith(String.format(ProcessCodegen.SVG_EXPORT_NAME_EXPRESION, "hiring")))).isTrue();
ProcessCodegen codeGenerator = ProcessCodegen.ofCollectedResources(context, collectedResources);
Collection<GeneratedFile> generatedFiles = codeGenerator.generate();
assertThat(generatedFiles).isNotEmpty();
List<GeneratedFile> resources = generatedFiles.stream().filter(generatedFile -> generatedFile.type().equals(GeneratedFileType.INTERNAL_RESOURCE)).collect(Collectors.toList());
assertThat(resources.size()).isEqualTo(1);
assertThat("META-INF/processSVG/" + TEST_PROCESS_ID + ".svg").isEqualTo(resources.get(0).relativePath());
}
use of org.drools.codegen.common.GeneratedFile in project kogito-runtimes by kiegroup.
the class CodegenSvgTest method testWithoutSVGAddonNoRenamedAndMoved.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void testWithoutSVGAddonNoRenamedAndMoved(KogitoBuildContext.Builder contextBuilder) {
KogitoBuildContext context = contextBuilder.withAddonsConfig(AddonsConfig.builder().withProcessSVG(false).build()).build();
Collection<CollectedResource> collectedResources = CollectedResourceProducer.fromPaths(BASE_PATH);
assertThat(collectedResources.stream().anyMatch(f -> f.resource().getSourcePath().endsWith(TEST_PROCESS_SOURCE))).isTrue();
assertThat(collectedResources.stream().anyMatch(f -> f.resource().getSourcePath().endsWith(TEST_PROCESS_GENERATED_SVG_SOURCE))).isTrue();
ProcessCodegen codeGenerator = ProcessCodegen.ofCollectedResources(context, collectedResources);
Collection<GeneratedFile> generatedFiles = codeGenerator.generate();
assertThat(generatedFiles).isNotEmpty();
List<GeneratedFile> resources = generatedFiles.stream().filter(generatedFile -> generatedFile.type().equals(GeneratedFileType.INTERNAL_RESOURCE)).collect(Collectors.toList());
assertThat(resources.size()).isZero();
}
use of org.drools.codegen.common.GeneratedFile in project kogito-runtimes by kiegroup.
the class DroolsModelBuilder method generateCanonicalModelSources.
public Collection<GeneratedFile> generateCanonicalModelSources() {
List<GeneratedFile> modelFiles = new ArrayList<>();
List<org.drools.modelcompiler.builder.GeneratedFile> legacyModelFiles = new ArrayList<>();
for (KogitoPackageSources pkgSources : modelBuilder.getPackageSources()) {
pkgSources.collectGeneratedFiles(legacyModelFiles);
modelFiles.addAll(generateInternalResource(pkgSources));
}
modelFiles.addAll(convertGeneratedRuleFile(legacyModelFiles));
return modelFiles;
}
use of org.drools.codegen.common.GeneratedFile in project kogito-runtimes by kiegroup.
the class AbstractProtoGenerator method generateProtoFiles.
@Override
public Collection<GeneratedFile> generateProtoFiles() {
List<GeneratedFile> generatedFiles = new ArrayList<>();
modelClasses.stream().map(this::generateModelClassProto).filter(Optional::isPresent).map(Optional::get).forEach(generatedFiles::add);
try {
this.generateProtoListingFile(generatedFiles).ifPresent(generatedFiles::add);
} catch (IOException e) {
throw new UncheckedIOException("Error during proto listing file creation", e);
}
return generatedFiles;
}
Aggregations