Skip to content

Commit a924fe0

Browse files
committed
Changes after comments
Signed-off-by: Francisco Javier Tirado Sarti <ftirados@redhat.com>
1 parent 9c68ef2 commit a924fe0

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

api/src/main/java/io/serverlessworkflow/api/serializers/WorkflowSerializer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ public void serialize(Workflow workflow, JsonGenerator gen, SerializerProvider p
160160
}
161161

162162
if (workflow.getConstants() != null) {
163-
if (!workflow.getConstants().getConstantsDef().isEmpty()) {
164-
gen.writeObjectField("constants", workflow.getConstants().getConstantsDef());
163+
if (workflow.getConstants().getConstantsDef() != null
164+
&& !workflow.getConstants().getConstantsDef().isEmpty()) {
165+
gen.writeObjectField("constants", workflow.getConstants().getConstantsDef());
165166
} else if (workflow.getConstants().getRefValue() != null) {
166-
gen.writeStringField("constants", workflow.getConstants().getRefValue());
167+
gen.writeStringField("constants", workflow.getConstants().getRefValue());
167168
}
168169
}
169170

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,7 @@ public void testConstants(String workflowLocation) {
569569
JsonNode serbianTranslationNode = translationDogNode.get("Serbian");
570570
assertEquals("pas", serbianTranslationNode.asText());
571571
}
572-
573-
572+
574573
@ParameterizedTest
575574
@ValueSource(strings = {"/features/constantsRef.json", "/features/constantsRef.yml"})
576575
public void testConstantsRef(String workflowLocation) {
@@ -583,9 +582,8 @@ public void testConstantsRef(String workflowLocation) {
583582

584583
assertNotNull(workflow.getConstants());
585584
Constants constants = workflow.getConstants();
586-
assertNotNull(constants.getRefValue());
585+
assertEquals("constantValues.json", constants.getRefValue());
587586
}
588-
589587

590588
@ParameterizedTest
591589
@ValueSource(strings = {"/features/timeouts.json", "/features/timeouts.yml"})

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.serverlessworkflow.api.start.Start;
3333
import io.serverlessworkflow.api.states.SleepState;
3434
import io.serverlessworkflow.api.workflow.Auth;
35+
import io.serverlessworkflow.api.workflow.Constants;
3536
import io.serverlessworkflow.api.workflow.Events;
3637
import io.serverlessworkflow.api.workflow.Functions;
3738
import java.util.Arrays;
@@ -47,6 +48,7 @@ public void testSingleState() {
4748
.withName("test-workflow-name")
4849
.withVersion("1.0")
4950
.withStart(new Start().withSchedule(new Schedule().withInterval("PT1S")))
51+
.withConstants(new Constants("constantsValues.json"))
5052
.withStates(
5153
Arrays.asList(
5254
new SleepState()
@@ -62,11 +64,13 @@ public void testSingleState() {
6264

6365
assertNotNull(workflow);
6466
assertNotNull(workflow.getStart());
67+
Constants constants = workflow.getConstants();
68+
assertNotNull(constants);
69+
assertEquals("constantsValues.json", constants.getRefValue());
6570
assertEquals(1, workflow.getStates().size());
6671
State state = workflow.getStates().get(0);
6772
assertTrue(state instanceof SleepState);
6873
assertNotNull(state.getEnd());
69-
7074
assertNotNull(Workflow.toJson(workflow));
7175
assertNotNull(Workflow.toYaml(workflow));
7276
}

api/src/test/resources/features/constantsRef.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Custom secrets flow",
66
"expressionLang": "abc",
77
"start": "TestFunctionRefs",
8-
"constants": "contantsValues.json",
8+
"constants": "constantValues.json",
99
"states": [
1010
{
1111
"name": "TestFunctionRefs",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy