Skip to content

Commit

Permalink
handles tuple diagram gen with sequence of primitives fields (#947)
Browse files Browse the repository at this point in the history
Initially, tuple type whose fields are sequence of primitives generate the wrong plantuml diagram. This PR fixes that.
  • Loading branch information
nofun97 authored Jul 10, 2020
1 parent 5b55656 commit 3139d28
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/datamodeldiagram/datamodelview.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ func (v *DataModelView) DrawTuple(
Count: 1,
}
}
} else {
v.StringBuilder.WriteString(collectionString)
}
} else {
v.StringBuilder.WriteString(fmt.Sprintf("+ %s : %s\n", attrName, strings.ToLower(attrType.GetPrimitive().String())))
Expand Down
28 changes: 28 additions & 0 deletions pkg/datamodeldiagram/datamodelview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,32 @@ func TestDrawTuple(t *testing.T) {
)
},
)

assertDraw(t,
`class "typeName" as _0 << (D,orchid) >> {
+ attr1 : **Sequence <string>**
+ attr2 : **Set <int>**
+ attr3 : **List <bool>**
}
`,
"typeName",
func(v *DataModelView, relationshipMap map[string]map[string]RelationshipParam) {
v.DrawTuple(
EntityViewParam{
EntityColor: "orchid",
EntityHeader: "D",
EntityName: "typeName",
EntityAlias: "",
},
syslwrapper.MakeTuple(
map[string]*sysl.Type{
"attr1": syslwrapper.MakeSequence(syslwrapper.MakePrimitive("string")),
"attr2": syslwrapper.MakeSet(syslwrapper.MakePrimitive("int")),
"attr3": syslwrapper.MakeList(syslwrapper.MakePrimitive("bool")),
},
).Type.(*sysl.Type_Tuple_).Tuple,
relationshipMap,
)
},
)
}
8 changes: 8 additions & 0 deletions pkg/syslwrapper/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ func MakeSet(setType *sysl.Type) *sysl.Type {
}
}

func MakeSequence(seqType *sysl.Type) *sysl.Type {
return &sysl.Type{
Type: &sysl.Type_Sequence{
Sequence: seqType,
},
}
}

func MakeNoType() *sysl.Type {
return &sysl.Type{
Type: &sysl.Type_NoType_{
Expand Down

0 comments on commit 3139d28

Please sign in to comment.