@@ -47,17 +47,10 @@ func TestBuilder_GuardPatternPreservesFalseBranchAnchor(t *testing.T) {
4747 oc := fb .buildFlowGraph (body , nil )
4848
4949 // Find the flow from the split to the tail log. It's the only one with
50- // an EnumerationCase Value==" false" that doesn't target an EndEvent.
50+ // a false branch case that doesn't target an EndEvent.
5151 var found * microflows.SequenceFlow
5252 for _ , f := range oc .Flows {
53- cv , ok := f .CaseValue .(microflows.EnumerationCase )
54- if ! ok {
55- if p , okp := f .CaseValue .(* microflows.EnumerationCase ); okp {
56- cv = * p
57- ok = true
58- }
59- }
60- if ! ok || cv .Value != "false" {
53+ if flowCaseString (f .CaseValue ) != "false" {
6154 continue
6255 }
6356 // Exclude flows pointing at an EndEvent.
@@ -85,3 +78,31 @@ func TestBuilder_GuardPatternPreservesFalseBranchAnchor(t *testing.T) {
8578 t .Errorf ("destination: got %d, want %d (Top)" , found .DestinationConnectionIndex , AnchorTop )
8679 }
8780}
81+
82+ func TestCaseValueForFlowUsesExpressionCaseForBooleanBranches (t * testing.T ) {
83+ for _ , tc := range []struct {
84+ value string
85+ want string
86+ }{
87+ {value : "true" , want : "true" },
88+ {value : "false" , want : "false" },
89+ } {
90+ got , ok := caseValueForFlow (tc .value ).(* microflows.ExpressionCase )
91+ if ! ok {
92+ t .Fatalf ("caseValueForFlow(%q) = %T, want *ExpressionCase" , tc .value , caseValueForFlow (tc .value ))
93+ }
94+ if got .Expression != tc .want {
95+ t .Fatalf ("caseValueForFlow(%q).Expression = %q, want %q" , tc .value , got .Expression , tc .want )
96+ }
97+ }
98+ }
99+
100+ func TestCaseValueForFlowKeepsEnumValuesAsEnumerationCase (t * testing.T ) {
101+ got , ok := caseValueForFlow ("Submitted" ).(microflows.EnumerationCase )
102+ if ! ok {
103+ t .Fatalf ("caseValueForFlow(enum) = %T, want EnumerationCase" , caseValueForFlow ("Submitted" ))
104+ }
105+ if got .Value != "Submitted" {
106+ t .Fatalf ("enum case value = %q, want Submitted" , got .Value )
107+ }
108+ }
0 commit comments