Skip to content

Commit 5f47903

Browse files
hjothamendixclaude
andcommitted
fixup: pin CastAction and InheritanceCase BSON field keys
Address PR #365 ako review B1 and B2 by pinning the BSON shape Studio Pro emits, rather than changing correct code based on a faulty premise. A BSON dump of the Control Centre app (Mendix 9.24) shows Studio Pro stores: Microflows$CastAction: VariableName = Account # not OutputVariableName ErrorHandlingType = Rollback Microflows$InheritanceCase: Value = Administration.Account # not Entity The current writer matches both. The parser already falls back to the alternative keys (OutputVariableName / Entity) for forward compatibility, so projects authored by future Mendix versions that ever rename these would still parse cleanly. Add two regression tests so the writer cannot be "fixed" back to the incorrect names without a CI failure: - TestSerializeCastAction_UsesVariableNameFieldKey - TestBuildSequenceFlowCase_InheritanceCase_UsesValueFieldKey Each asserts both the presence of the correct key and the absence of the alternative one, so a partial change is also caught. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 87a307f commit 5f47903

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

sdk/mpr/inheritance_roundtrip_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,45 @@ func TestCastAction_RoundtripVariableName(t *testing.T) {
6363
t.Fatalf("OutputVariable = %q, want SpecificInput", parsed.OutputVariable)
6464
}
6565
}
66+
67+
// TestSerializeCastAction_UsesVariableNameFieldKey pins the BSON field key
68+
// Studio Pro emits for Microflows$CastAction. Empirical evidence (BSON
69+
// dump of the Control Centre app on Mendix 9.24): Studio Pro stores the
70+
// output variable under "VariableName", not "OutputVariableName". The
71+
// parser falls back to "VariableName" when "OutputVariableName" is
72+
// absent so projects authored by Studio Pro still parse cleanly; the
73+
// writer must match Studio Pro's authored shape so projects we produce
74+
// open without surprises.
75+
func TestSerializeCastAction_UsesVariableNameFieldKey(t *testing.T) {
76+
action := &microflows.CastAction{
77+
BaseElement: model.BaseElement{ID: "cast-1"},
78+
OutputVariable: "SpecificInput",
79+
}
80+
doc := serializeMicroflowAction(action)
81+
if got := bsonGetKey(doc, "VariableName"); got != "SpecificInput" {
82+
t.Fatalf("VariableName = %v, want SpecificInput", got)
83+
}
84+
if got := bsonGetKey(doc, "OutputVariableName"); got != nil {
85+
t.Fatalf("OutputVariableName = %v, want absent (Studio Pro uses VariableName)", got)
86+
}
87+
}
88+
89+
// TestBuildSequenceFlowCase_InheritanceCase_UsesValueFieldKey pins the
90+
// BSON field key for Microflows$InheritanceCase. Empirical evidence
91+
// (BSON dump of the Control Centre app, Mendix 9.24): the entity
92+
// reference is stored under "Value" as a qualified-name string
93+
// (e.g. "Administration.Account"), not "Entity". The parser falls back
94+
// to "Entity" for forward compatibility; the writer must emit "Value"
95+
// so output matches Studio Pro's authored shape.
96+
func TestBuildSequenceFlowCase_InheritanceCase_UsesValueFieldKey(t *testing.T) {
97+
doc := buildSequenceFlowCase(&microflows.InheritanceCase{
98+
BaseElement: model.BaseElement{ID: "case-1"},
99+
EntityQualifiedName: "Sample.SpecializedInput",
100+
})
101+
if got := bsonGetKey(doc, "Value"); got != "Sample.SpecializedInput" {
102+
t.Fatalf("Value = %v, want Sample.SpecializedInput", got)
103+
}
104+
if got := bsonGetKey(doc, "Entity"); got != nil {
105+
t.Fatalf("Entity = %v, want absent (Studio Pro uses Value)", got)
106+
}
107+
}

0 commit comments

Comments
 (0)