22
33package com.courier.models
44
5+ import com.courier.core.JsonValue
56import com.courier.core.jsonMapper
67import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
8+ import kotlin.jvm.optionals.getOrNull
79import org.assertj.core.api.Assertions.assertThat
810import org.junit.jupiter.api.Test
911
@@ -13,9 +15,95 @@ internal class ElementalChannelNodeWithTypeTest {
1315 fun create () {
1416 val elementalChannelNodeWithType =
1517 ElementalChannelNodeWithType .builder()
18+ .addChannel(" string" )
19+ .if_(" if" )
20+ .loop(" loop" )
21+ .ref(" ref" )
22+ .channel(" email" )
23+ .addElement(
24+ ElementalNodeNonChannel .UnionMember0 .builder()
25+ .addChannel(" string" )
26+ .if_(" if" )
27+ .loop(" loop" )
28+ .ref(" ref" )
29+ .align(ElementalTextNode .Align .LEFT )
30+ .bold(" bold" )
31+ .color(" color" )
32+ .content(" content" )
33+ .fontSize(" font_size" )
34+ .format(ElementalTextNode .Format .MARKDOWN )
35+ .italic(" italic" )
36+ .lineHeight(" line_height" )
37+ .locales(
38+ Locales .builder()
39+ .putAdditionalProperty(
40+ " foo" ,
41+ JsonValue .from(mapOf (" content" to " content" )),
42+ )
43+ .build()
44+ )
45+ .strikethrough(" strikethrough" )
46+ .textStyle(TextStyle .TEXT )
47+ .underline(" underline" )
48+ .type(ElementalNodeNonChannel .UnionMember0 .Type .TEXT )
49+ .build()
50+ )
51+ .fontSize(" font_size" )
52+ .lineHeight(" line_height" )
53+ .padding(" padding" )
54+ .raw(
55+ ElementalChannelNode .Raw .builder()
56+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
57+ .build()
58+ )
1659 .type(ElementalChannelNodeWithType .Type .CHANNEL )
1760 .build()
1861
62+ assertThat(elementalChannelNodeWithType.channels().getOrNull()).containsExactly(" string" )
63+ assertThat(elementalChannelNodeWithType.if_()).contains(" if" )
64+ assertThat(elementalChannelNodeWithType.loop()).contains(" loop" )
65+ assertThat(elementalChannelNodeWithType.ref()).contains(" ref" )
66+ assertThat(elementalChannelNodeWithType.channel()).contains(" email" )
67+ assertThat(elementalChannelNodeWithType.elements().getOrNull())
68+ .containsExactly(
69+ ElementalNodeNonChannel .ofUnionMember0(
70+ ElementalNodeNonChannel .UnionMember0 .builder()
71+ .addChannel(" string" )
72+ .if_(" if" )
73+ .loop(" loop" )
74+ .ref(" ref" )
75+ .align(ElementalTextNode .Align .LEFT )
76+ .bold(" bold" )
77+ .color(" color" )
78+ .content(" content" )
79+ .fontSize(" font_size" )
80+ .format(ElementalTextNode .Format .MARKDOWN )
81+ .italic(" italic" )
82+ .lineHeight(" line_height" )
83+ .locales(
84+ Locales .builder()
85+ .putAdditionalProperty(
86+ " foo" ,
87+ JsonValue .from(mapOf (" content" to " content" )),
88+ )
89+ .build()
90+ )
91+ .strikethrough(" strikethrough" )
92+ .textStyle(TextStyle .TEXT )
93+ .underline(" underline" )
94+ .type(ElementalNodeNonChannel .UnionMember0 .Type .TEXT )
95+ .build()
96+ )
97+ )
98+ assertThat(elementalChannelNodeWithType.fontSize()).contains(" font_size" )
99+ assertThat(elementalChannelNodeWithType.lineHeight()).contains(" line_height" )
100+ assertThat(elementalChannelNodeWithType.padding()).contains(" padding" )
101+ assertThat(elementalChannelNodeWithType.raw())
102+ .contains(
103+ ElementalChannelNode .Raw .builder()
104+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
105+ .build()
106+ )
19107 assertThat(elementalChannelNodeWithType.type())
20108 .contains(ElementalChannelNodeWithType .Type .CHANNEL )
21109 }
@@ -25,6 +113,47 @@ internal class ElementalChannelNodeWithTypeTest {
25113 val jsonMapper = jsonMapper()
26114 val elementalChannelNodeWithType =
27115 ElementalChannelNodeWithType .builder()
116+ .addChannel(" string" )
117+ .if_(" if" )
118+ .loop(" loop" )
119+ .ref(" ref" )
120+ .channel(" email" )
121+ .addElement(
122+ ElementalNodeNonChannel .UnionMember0 .builder()
123+ .addChannel(" string" )
124+ .if_(" if" )
125+ .loop(" loop" )
126+ .ref(" ref" )
127+ .align(ElementalTextNode .Align .LEFT )
128+ .bold(" bold" )
129+ .color(" color" )
130+ .content(" content" )
131+ .fontSize(" font_size" )
132+ .format(ElementalTextNode .Format .MARKDOWN )
133+ .italic(" italic" )
134+ .lineHeight(" line_height" )
135+ .locales(
136+ Locales .builder()
137+ .putAdditionalProperty(
138+ " foo" ,
139+ JsonValue .from(mapOf (" content" to " content" )),
140+ )
141+ .build()
142+ )
143+ .strikethrough(" strikethrough" )
144+ .textStyle(TextStyle .TEXT )
145+ .underline(" underline" )
146+ .type(ElementalNodeNonChannel .UnionMember0 .Type .TEXT )
147+ .build()
148+ )
149+ .fontSize(" font_size" )
150+ .lineHeight(" line_height" )
151+ .padding(" padding" )
152+ .raw(
153+ ElementalChannelNode .Raw .builder()
154+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
155+ .build()
156+ )
28157 .type(ElementalChannelNodeWithType .Type .CHANNEL )
29158 .build()
30159
0 commit comments