use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class PredictionCodegenTest method isEmpty.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void isEmpty(KogitoBuildContext.Builder contextBuilder) {
KogitoBuildContext context = contextBuilder.build();
PredictionCodegen emptyCodeGenerator = PredictionCodegen.ofCollectedResources(context, Collections.emptyList());
assertThat(emptyCodeGenerator.isEmpty()).isTrue();
assertThat(emptyCodeGenerator.isEnabled()).isFalse();
Collection<GeneratedFile> emptyGeneratedFiles = emptyCodeGenerator.generate();
assertThat(emptyGeneratedFiles.size()).isEqualTo(0);
PredictionCodegen codeGenerator = PredictionCodegen.ofCollectedResources(context, CollectedResourceProducer.fromFiles(BASE_PATH, REGRESSION_FULL_SOURCE.toFile()));
assertThat(codeGenerator.isEmpty()).isFalse();
assertThat(codeGenerator.isEnabled()).isTrue();
Collection<GeneratedFile> generatedFiles = codeGenerator.generate();
assertThat(generatedFiles.size()).isGreaterThanOrEqualTo(1);
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class PredictionCodegenTest method generateAllFilesScorecard.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
void generateAllFilesScorecard(KogitoBuildContext.Builder contextBuilder) {
KogitoBuildContext context = contextBuilder.build();
PredictionCodegen codeGenerator = PredictionCodegen.ofCollectedResources(context, CollectedResourceProducer.fromFiles(BASE_PATH, SCORECARD_FULL_SOURCE.toFile()));
generateAllFiles(context, codeGenerator, 5, 3, 1, false);
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class PredictionCodegenTest method generateAllFilesRegression.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
void generateAllFilesRegression(KogitoBuildContext.Builder contextBuilder) {
KogitoBuildContext context = contextBuilder.build();
PredictionCodegen codeGenerator = PredictionCodegen.ofCollectedResources(context, CollectedResourceProducer.fromFiles(BASE_PATH, REGRESSION_FULL_SOURCE.toFile()));
generateAllFiles(context, codeGenerator, 5, 3, 1, false);
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class RuleUnitCompilerIT method checckPropertyReactvity.
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void checckPropertyReactvity(boolean usePropertyReactivity) throws Exception {
// KOGITO-5101
KogitoBuildContext context = newContext();
if (!usePropertyReactivity) {
context.setApplicationProperty(PropertySpecificOption.PROPERTY_NAME, PropertySpecificOption.DISABLED.toString());
}
Application application = createApplication(context, "org/kie/kogito/codegen/unit/RuleUnitNoPropReact.drl");
AdultUnit adults = new AdultUnit();
Person mario = new Person("Mario", 45);
adults.getPersons().add(mario);
RuleUnit<AdultUnit> unit = application.get(RuleUnits.class).create(AdultUnit.class);
RuleUnitInstance<AdultUnit> instance = unit.createInstance(adults);
instance.fire();
assertEquals(usePropertyReactivity ? 46 : 50, mario.getAge());
}
use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.
the class PathResolverTest method verifyFileResolver.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
void verifyFileResolver(final KogitoBuildContext.Builder contextBuilder) {
final String resource = "specs/__files/petstore.json";
final KogitoBuildContext context = contextBuilder.build();
final String classpathPath = requireNonNull(getClass().getClassLoader().getResource(resource)).getPath();
final OpenApiSpecDescriptor openApiSpecDescriptor = new OpenApiSpecDescriptor("file://" + classpathPath);
final PathResolver resolver = PathResolverFactory.newResolver(openApiSpecDescriptor, context);
assertThat(resolver).isInstanceOf(FileResolver.class);
final String path = resolver.resolve(openApiSpecDescriptor);
this.assertResolverPath(path);
}
Aggregations