use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class DecisionCloudEventMetaFactoryGeneratorTest method buildCodegen.
private static DecisionCodegen buildCodegen(boolean withCloudEvents) {
KogitoBuildContext context = QuarkusKogitoBuildContext.builder().withAddonsConfig(AddonsConfig.builder().withCloudEvents(withCloudEvents).build()).build();
Collection<CollectedResource> collectedResources = CollectedResourceProducer.fromPaths(Paths.get(MODEL_PATH).toAbsolutePath());
return DecisionCodegen.ofCollectedResources(context, collectedResources);
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class ApplicationGeneratorTest method compilationUnit.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void compilationUnit(KogitoBuildContext.Builder contextBuilder) {
final KogitoBuildContext context = contextBuilder.build();
final ApplicationContainerGenerator appGenerator = new ApplicationContainerGenerator(context);
assertCompilationUnit(appGenerator.getCompilationUnitOrThrow(), context.hasDI());
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class ApplicationGeneratorTest method disableRestGenerationOfSpecificGenerator.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void disableRestGenerationOfSpecificGenerator(KogitoBuildContext.Builder contextBuilder) {
final KogitoBuildContext context = contextBuilder.build();
final ApplicationGenerator appGenerator = new ApplicationGenerator(context);
final MockGenerator restGenerator = new MockGenerator(context, true);
assertThat(appGenerator.registerGeneratorIfEnabled(restGenerator)).isNotEmpty();
assertThat(appGenerator.getGenerators()).hasSize(1);
if (context.hasRESTForGenerator(restGenerator)) {
// disable REST
context.setApplicationProperty(KogitoBuildContext.generateRESTConfigurationKeyForResource(restGenerator.name()), "false");
assertThat(appGenerator.generateComponents()).isEmpty();
// enable REST
context.setApplicationProperty(KogitoBuildContext.generateRESTConfigurationKeyForResource(restGenerator.name()), "true");
assertThat(appGenerator.generateComponents()).isNotEmpty().hasSize(1).matches(files -> files.stream().anyMatch(gf -> REST_TYPE.equals(gf.type())));
} else {
assertThat(appGenerator.generateComponents()).isEmpty();
}
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class ApplicationGeneratorTest method disableGlobalRestGeneration.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void disableGlobalRestGeneration(KogitoBuildContext.Builder contextBuilder) {
final KogitoBuildContext context = contextBuilder.build();
final ApplicationGenerator appGenerator = new ApplicationGenerator(context);
final MockGenerator restGenerator = new MockGenerator(context, true);
assertThat(appGenerator.registerGeneratorIfEnabled(restGenerator)).isNotEmpty();
assertThat(appGenerator.getGenerators()).hasSize(1);
if (context.hasRESTForGenerator(restGenerator)) {
// globally disable REST
context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "false");
assertThat(appGenerator.generateComponents()).isEmpty();
// globally enable REST
context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "true");
assertThat(appGenerator.generateComponents()).isNotEmpty().hasSize(1).matches(files -> files.stream().anyMatch(gf -> REST_TYPE.equals(gf.type())));
} else {
assertThat(appGenerator.generateComponents()).isEmpty();
}
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class ApplicationGeneratorTest method compilationUnitWithCDI.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void compilationUnitWithCDI(KogitoBuildContext.Builder contextBuilder) {
final KogitoBuildContext context = contextBuilder.build();
final ApplicationContainerGenerator appGenerator = new ApplicationContainerGenerator(context);
assertCompilationUnit(appGenerator.getCompilationUnitOrThrow(), context.hasDI());
}
Aggregations