From a210c836ea19ff2c68011f1bcb85432ca092ac26 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Thu, 6 Jul 2023 10:45:08 +0200 Subject: [PATCH] [KOGITO-8525] Making plain Java test work --- .../api/di/DependencyInjectionAnnotator.java | 2 +- .../codegen/process/TagResourceGenerator.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/di/DependencyInjectionAnnotator.java b/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/di/DependencyInjectionAnnotator.java index d6f19bd3ffa..eb8c3126158 100644 --- a/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/di/DependencyInjectionAnnotator.java +++ b/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/di/DependencyInjectionAnnotator.java @@ -263,5 +263,5 @@ default Expression getOptionalInstance(String fieldName) { default > T withTagAnnotation(T node, NodeList attributes) { return node; - }; + } } diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/TagResourceGenerator.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/TagResourceGenerator.java index af0c6a835a6..0f5deecfb86 100644 --- a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/TagResourceGenerator.java +++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/TagResourceGenerator.java @@ -44,12 +44,14 @@ private TagResourceGenerator() { * @param process the {@link KogitoWorkflowProcess} to get the tags from */ static void addTags(CompilationUnit compilationUnit, KogitoWorkflowProcess process, KogitoBuildContext context) { - Map metadata = process.getMetaData(); - @SuppressWarnings("unchecked") - Collection tags = (Collection) metadata.getOrDefault(Metadata.TAGS, Set.of()); - String description = (String) metadata.get(Metadata.DESCRIPTION); - compilationUnit.findAll(ClassOrInterfaceDeclaration.class) - .forEach(cls -> addTags(process, tags, description, cls, context)); + if (context.hasDI()) { + Map metadata = process.getMetaData(); + @SuppressWarnings("unchecked") + Collection tags = (Collection) metadata.getOrDefault(Metadata.TAGS, Set.of()); + String description = (String) metadata.get(Metadata.DESCRIPTION); + compilationUnit.findAll(ClassOrInterfaceDeclaration.class) + .forEach(cls -> addTags(process, tags, description, cls, context)); + } } private static void addTags(KogitoWorkflowProcess process, Collection tags, String description, ClassOrInterfaceDeclaration cls, KogitoBuildContext context) {