Search in sources :

Example 6 with KogitoGAV

use of org.kie.kogito.KogitoGAV in project kogito-runtimes by kiegroup.

the class DecisionModelEventTest method testGetters.

@Test
public void testGetters() {
    final KogitoGAV gav = new KogitoGAV("groupID", "artifactId", "version");
    final DecisionModelEvent e = new DecisionModelEvent(gav, "name", "namespace", new DecisionModelMetadata("http://www.omg.org/spec/DMN/20151101/dmn.xsd"), "definition");
    assertEquals(gav.getGroupId(), e.getGav().getGroupId());
    assertEquals(gav.getArtifactId(), e.getGav().getArtifactId());
    assertEquals(gav.getVersion(), e.getGav().getVersion());
    assertEquals("name", e.getName());
    assertEquals("namespace", e.getNamespace());
    assertEquals(ModelDomain.DECISION, e.getModelMetadata().getModelDomain());
    assertEquals("http://www.omg.org/spec/DMN/20151101/dmn.xsd", e.getModelMetadata().getSpecVersion());
    assertEquals("definition", e.getDefinition());
}
Also used : DecisionModelMetadata(org.kie.kogito.decision.DecisionModelMetadata) KogitoGAV(org.kie.kogito.KogitoGAV) DecisionModelEvent(org.kie.kogito.tracing.event.model.models.DecisionModelEvent) Test(org.junit.jupiter.api.Test)

Example 7 with KogitoGAV

use of org.kie.kogito.KogitoGAV in project kogito-runtimes by kiegroup.

the class KogitoQuarkusResourceUtils method kogitoBuildContext.

public static KogitoBuildContext kogitoBuildContext(Path outputTarget, Iterable<Path> paths, IndexView index, Dependency appArtifact) {
    // scan and parse paths
    AppPaths.BuildTool buildTool;
    if (System.getProperty("org.gradle.appname") == null) {
        buildTool = AppPaths.BuildTool.MAVEN;
    } else {
        buildTool = AppPaths.BuildTool.GRADLE;
    }
    AppPaths appPaths = AppPaths.fromQuarkus(outputTarget, paths, buildTool);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    KogitoBuildContext context = QuarkusKogitoBuildContext.builder().withApplicationPropertyProvider(new KogitoQuarkusApplicationPropertiesProvider()).withClassLoader(classLoader).withClassAvailabilityResolver(className -> classAvailabilityResolver(classLoader, index, className)).withClassSubTypeAvailabilityResolver(classSubTypeAvailabilityResolver(index)).withAppPaths(appPaths).withGAV(new KogitoGAV(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getVersion())).withSourceFileProcessBindNotifier(new SourceFileCodegenBindNotifier()).build();
    if (!context.hasClassAvailable(QuarkusKogitoBuildContext.QUARKUS_REST)) {
        LOGGER.info("Disabling REST generation because class '" + QuarkusKogitoBuildContext.QUARKUS_REST + "' is not available");
        context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "false");
    }
    if (!context.hasClassAvailable(QuarkusKogitoBuildContext.QUARKUS_DI)) {
        LOGGER.info("Disabling dependency injection generation because class '" + QuarkusKogitoBuildContext.QUARKUS_DI + "' is not available");
        context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_DI, "false");
    }
    return context;
}
Also used : AppPaths(org.drools.codegen.common.AppPaths) DotName(org.jboss.jandex.DotName) LoggerFactory(org.slf4j.LoggerFactory) AdditionalStaticResourceBuildItem(io.quarkus.vertx.http.deployment.spi.AdditionalStaticResourceBuildItem) GeneratedFileWriter(org.kie.kogito.codegen.core.utils.GeneratedFileWriter) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) ArrayList(java.util.ArrayList) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) CompositeIndex(org.jboss.jandex.CompositeIndex) Dependency(io.quarkus.maven.dependency.Dependency) ResourceReader(org.kie.memorycompiler.resources.ResourceReader) Path(java.nio.file.Path) SourceFileCodegenBindNotifier(org.kie.kogito.codegen.api.SourceFileCodegenBindNotifier) IndexView(org.jboss.jandex.IndexView) GeneratedResourceBuildItem(io.quarkus.deployment.builditem.GeneratedResourceBuildItem) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) Logger(org.slf4j.Logger) Files(java.nio.file.Files) Predicate(java.util.function.Predicate) Collection(java.util.Collection) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) PortablePath(org.drools.util.PortablePath) List(java.util.List) KogitoGAV(org.kie.kogito.KogitoGAV) QuarkusKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext) Paths(java.nio.file.Paths) ConfigProvider(org.eclipse.microprofile.config.ConfigProvider) Modifier(java.lang.reflect.Modifier) GeneratedFile(org.drools.codegen.common.GeneratedFile) GeneratedFileType(org.drools.codegen.common.GeneratedFileType) AppPaths(org.drools.codegen.common.AppPaths) KogitoGAV(org.kie.kogito.KogitoGAV) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) QuarkusKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext) SourceFileCodegenBindNotifier(org.kie.kogito.codegen.api.SourceFileCodegenBindNotifier)

Example 8 with KogitoGAV

use of org.kie.kogito.KogitoGAV in project kogito-runtimes by kiegroup.

the class ModelEventTest method testGetters.

@Test
public void testGetters() {
    final KogitoGAV gav = new KogitoGAV("groupID", "artifactId", "version");
    final ModelEvent e = new ModelEvent(gav, "name", new ModelMetadata(ModelDomain.DECISION) {
    }, ModelDomain.DECISION) {
    };
    assertEquals(gav.getGroupId(), e.getGav().getGroupId());
    assertEquals(gav.getArtifactId(), e.getGav().getArtifactId());
    assertEquals(gav.getVersion(), e.getGav().getVersion());
    assertEquals("name", e.getName());
}
Also used : KogitoGAV(org.kie.kogito.KogitoGAV) ModelMetadata(org.kie.kogito.event.ModelMetadata) Test(org.junit.jupiter.api.Test)

Example 9 with KogitoGAV

use of org.kie.kogito.KogitoGAV in project kogito-runtimes by kiegroup.

the class ConfigBeanGeneratorTest method generate.

@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
public void generate(KogitoBuildContext.Builder contextBuilder) {
    // null GAV
    assertThat(contextBuilder.build().getGAV()).isEmpty();
    Optional<MethodCallExpr> setGavNull = getGavMethodCallExpr(contextBuilder);
    setGavNull.ifPresent(methodCallExpr -> assertThat(methodCallExpr.toString()).contains("null"));
    // with GAV
    KogitoGAV kogitoGAV = new KogitoGAV("groupId", "artifactId", "version");
    contextBuilder.withGAV(kogitoGAV);
    Optional<MethodCallExpr> setGav = getGavMethodCallExpr(contextBuilder);
    setGav.ifPresent(methodCallExpr -> assertThat(methodCallExpr.toString()).contains(kogitoGAV.getGroupId()).contains(kogitoGAV.getArtifactId()).contains(kogitoGAV.getVersion()));
}
Also used : KogitoGAV(org.kie.kogito.KogitoGAV) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 10 with KogitoGAV

use of org.kie.kogito.KogitoGAV in project kogito-runtimes by kiegroup.

the class QuarkusModelEventEmitterTest method makeModel.

private DecisionModelResource makeModel() {
    final DecisionModelResource model = mock(DecisionModelResource.class);
    when(model.getGav()).thenReturn(new KogitoGAV("groupId", "artifactId", "version"));
    when(model.getModelName()).thenReturn("name");
    when(model.getNamespace()).thenReturn("namespace");
    when(model.getModelMetadata()).thenReturn(new DecisionModelMetadata("http://www.omg.org/spec/DMN/20151101/dmn.xsd"));
    when(model.get()).thenReturn("model");
    return model;
}
Also used : DecisionModelMetadata(org.kie.kogito.decision.DecisionModelMetadata) DecisionModelResource(org.kie.kogito.decision.DecisionModelResource) KogitoGAV(org.kie.kogito.KogitoGAV)

Aggregations

KogitoGAV (org.kie.kogito.KogitoGAV)10 Test (org.junit.jupiter.api.Test)4 DecisionModelMetadata (org.kie.kogito.decision.DecisionModelMetadata)3 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)2 AppPaths (org.drools.codegen.common.AppPaths)2 KogitoBuildContext (org.kie.kogito.codegen.api.context.KogitoBuildContext)2 QuarkusKogitoBuildContext (org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext)2 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)1 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)1 GeneratedBeanBuildItem (io.quarkus.arc.deployment.GeneratedBeanBuildItem)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 GeneratedResourceBuildItem (io.quarkus.deployment.builditem.GeneratedResourceBuildItem)1 NativeImageResourceBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem)1 Dependency (io.quarkus.maven.dependency.Dependency)1 AdditionalStaticResourceBuildItem (io.quarkus.vertx.http.deployment.spi.AdditionalStaticResourceBuildItem)1 IOException (java.io.IOException)1 Modifier (java.lang.reflect.Modifier)1