1111import org .commonmark .testutil .RenderingTestCase ;
1212import org .junit .jupiter .api .Test ;
1313
14+ import java .util .HashMap ;
1415import java .util .List ;
1516import java .util .Map ;
1617import java .util .Set ;
@@ -46,8 +47,10 @@ private void assertRenderingCustomTitles(String source, String expectedResult) {
4647
4748 @ Test
4849 public void customType () {
50+ var customTypes = new HashMap <>(AlertsExtension .STANDARD_TYPES );
51+ customTypes .put ("INFO" , "Information" );
4952 var extension = AlertsExtension .builder ()
50- .addCustomType ( "INFO" , "Information" )
53+ .setAllowedTypes ( customTypes )
5154 .build ();
5255
5356 var parser = Parser .builder ().extensions (Set .of (extension )).build ();
@@ -63,9 +66,11 @@ public void customType() {
6366 @ Test
6467 public void multipleCustomTypes () {
6568 var extension = AlertsExtension .builder ()
66- .addCustomType ("INFO" , "Information" )
67- .addCustomType ("SUCCESS" , "Success!" )
68- .addCustomType ("DANGER" , "Danger!" )
69+ .setAllowedTypes (Map .ofEntries (
70+ Map .entry ("INFO" , "Information" ),
71+ Map .entry ("SUCCESS" , "Success!" ),
72+ Map .entry ("DANGER" , "Danger!" )
73+ ))
6974 .build ();
7075
7176 var parser = Parser .builder ().extensions (Set .of (extension )).build ();
@@ -88,8 +93,10 @@ public void multipleCustomTypes() {
8893
8994 @ Test
9095 public void standardTypesWithCustomConfigured () {
96+ var customTypes = new HashMap <>(AlertsExtension .STANDARD_TYPES );
97+ customTypes .put ("INFO" , "Information" );
9198 var extension = AlertsExtension .builder ()
92- .addCustomType ( "INFO" , "Information" )
99+ .setAllowedTypes ( customTypes )
93100 .build ();
94101
95102 var parser = Parser .builder ().extensions (Set .of (extension )).build ();
@@ -104,8 +111,10 @@ public void standardTypesWithCustomConfigured() {
104111
105112 @ Test
106113 public void overrideStandardTypeTitle () {
114+ var customTypes = new HashMap <>(AlertsExtension .STANDARD_TYPES );
115+ customTypes .put ("NOTE" , "Nota" );
107116 var extension = AlertsExtension .builder ()
108- .addCustomType ( "NOTE" , "Nota" )
117+ .setAllowedTypes ( customTypes )
109118 .build ();
110119
111120 var parser = Parser .builder ().extensions (Set .of (extension )).build ();
@@ -123,19 +132,19 @@ public void overrideStandardTypeTitle() {
123132 @ Test
124133 public void customTypeMustBeUppercase () {
125134 assertThrows (IllegalArgumentException .class , () ->
126- AlertsExtension .builder ().addCustomType ( "info" , "Information" ).build ());
135+ AlertsExtension .builder ().setAllowedTypes ( Map . of ( "info" , "Information" ) ).build ());
127136 }
128137
129138 @ Test
130139 public void customTypeMustNotBeEmpty () {
131140 assertThrows (IllegalArgumentException .class , () ->
132- AlertsExtension .builder ().addCustomType ( "" , "Title" ).build ());
141+ AlertsExtension .builder ().setAllowedTypes ( Map . of ( "" , "Title" ) ).build ());
133142 }
134143
135144 @ Test
136145 public void customTypeTitleMustNotBeEmpty () {
137146 assertThrows (IllegalArgumentException .class , () ->
138- AlertsExtension .builder ().addCustomType ( "INFO" , "" ).build ());
147+ AlertsExtension .builder ().setAllowedTypes ( Map . of ( "INFO" , "" ) ).build ());
139148 }
140149
141150 @ Test
@@ -431,8 +440,10 @@ public void alertParsedAsAlertNode() {
431440
432441 @ Test
433442 public void customTypeParsedAsAlertNode () {
443+ var customTypes = new HashMap <>(AlertsExtension .STANDARD_TYPES );
444+ customTypes .put ("INFO" , "Information" );
434445 var extension = AlertsExtension .builder ()
435- .addCustomType ( "INFO" , "Information" )
446+ .setAllowedTypes ( customTypes )
436447 .build ();
437448
438449 var parser = Parser .builder ().extensions (Set .of (extension )).build ();
0 commit comments