Copilot commented on code in PR #4303:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4303#discussion_r3332636274
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/ProcessCodegen.java:
##########
@@ -187,6 +187,30 @@ private static void
notifySourceFileCodegenBindListeners(KogitoBuildContext cont
.ifPresent(notifier -> processes.forEach(p ->
notifier.notify(new SourceFileCodegenBindEvent(p.getId(),
resource.getSourcePath()))));
}
+ /**
+ * Injects recordArgs metadata into a process if the global property is
enabled.
+ * This allows the global property
kogito.processes.service-tasks.record-io to control
+ * input/output argument recording for all service tasks in the process.
+ */
+ private void injectRecordArgsMetadataIfNeeded(WorkflowProcess process) {
+ // Property name for global service task I/O recording
+ String RECORD_SERVICE_TASK_ARGS_PROPERTY =
"kogito.processes.service-tasks.record-io";
+ String RECORD_ARGS = "recordArgs";
+
+ boolean globalRecordArgs =
context().getApplicationProperty(RECORD_SERVICE_TASK_ARGS_PROPERTY,
Boolean.class)
+ .orElse(false);
+
+ if (!globalRecordArgs) {
+ return;
+ }
+
+ // Only inject if process doesn't already have recordArgs metadata
+ if (process.getMetaData().get(RECORD_ARGS) == null) {
+ ((WorkflowProcessImpl) process).setMetaData(RECORD_ARGS, true);
+ LOGGER.debug("Injected recordArgs=true metadata into process: {}",
process.getId());
Review Comment:
The method defines uppercase "constant-like" local variables that are not
`final`. This reads like class constants and makes the code harder to
scan/maintain. Prefer `final` lowerCamel locals (or class-level constants) and
reuse the updated variable names in the rest of the method.
##########
api/kogito-api/src/test/java/org/kie/kogito/internal/process/workitem/WorkItemRecordParametersTest.java:
##########
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.internal.process.workitem;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.kie.api.definition.process.NodeContainer;
+import org.kie.kogito.internal.process.runtime.KogitoNode;
+import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static
org.kie.kogito.internal.process.workitem.WorkItemRecordParameters.RECORD_ARGS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class WorkItemRecordParametersTest {
+
+ @Mock
+ private KogitoWorkItem workItem;
+
+ @Mock
+ private KogitoNodeInstance nodeInstance;
+
+ @Mock
+ private KogitoNode node;
+
+ @Mock
+ private NodeContainer processContainer;
+
Review Comment:
Unused mock field `processContainer` isn't referenced by any test and may
trigger unused-field checks in some build setups. Remove it to keep the test
focused.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]