Skip to content

Commit fc2e657

Browse files
authored
[Fix #1553] Initialize call field in generated Callxxx classes (#1555)
When using DSL, the call field is not set unless the DSL method implementation invokes either setCall or withCall, which current implementation is not actually doing, leading to the reported issue. Rather than changing a lot of fluent dsl classes both in sdk and experimental (recently moved to QFlow) it is better to fix in just one place, the generator of the problematic types. Signed-off-by: Francisco Javier Tirado Sarti <ftirados@ibm.com>
1 parent 3e58940 commit fc2e657

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package io.serverlessworkflow.api;
1717

18-
import static io.serverlessworkflow.api.WorkflowReader.readWorkflow;
1918
import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath;
2019
import static io.serverlessworkflow.api.WorkflowReader.validation;
2120
import static io.serverlessworkflow.api.WorkflowWriter.workflowAsBytes;
@@ -30,9 +29,13 @@
3029
import java.io.IOException;
3130
import org.junit.jupiter.params.ParameterizedTest;
3231
import org.junit.jupiter.params.provider.ValueSource;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
3334

3435
public class FeaturesTest {
3536

37+
private static final Logger logger = LoggerFactory.getLogger(FeaturesTest.class);
38+
3639
@ParameterizedTest
3740
@ValueSource(
3841
strings = {
@@ -71,8 +74,11 @@ private static Workflow writeAndReadInMemory(Workflow workflow) throws IOExcepti
7174
writeWorkflow(out, workflow, WorkflowFormat.JSON);
7275
bytes = out.toByteArray();
7376
}
77+
if (logger.isDebugEnabled()) {
78+
logger.debug("Workflow string representation is {}", new String(bytes));
79+
}
7480
try (ByteArrayInputStream in = new ByteArrayInputStream(bytes)) {
75-
return readWorkflow(in, WorkflowFormat.JSON);
81+
return validation().read(in, WorkflowFormat.JSON);
7682
}
7783
}
7884

generators/types/src/main/java/io/serverlessworkflow/generator/CustomAnnotator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.fasterxml.jackson.databind.JsonNode;
1919
import com.sun.codemodel.JDefinedClass;
20+
import com.sun.codemodel.JExpr;
2021
import com.sun.codemodel.JFieldVar;
2122
import io.serverlessworkflow.annotations.AdditionalProperties;
2223
import jakarta.validation.constraints.Pattern;
@@ -40,7 +41,9 @@ public void additionalPropertiesField(JFieldVar field, JDefinedClass clazz, Stri
4041
public void propertyField(
4142
JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) {
4243
if (propertyNode.has(CONST)) {
43-
field.annotate(Pattern.class).param("regexp", propertyNode.get(CONST).asText());
44+
String callValue = propertyNode.get(CONST).asText();
45+
field.annotate(Pattern.class).param("regexp", callValue);
46+
field.init(JExpr.lit(callValue));
4447
}
4548
}
4649
}

0 commit comments

Comments
 (0)