1717package org .springframework .cloud .function .context .config ;
1818
1919import java .util .HashMap ;
20+ import java .util .List ;
2021import java .util .Map ;
2122import java .util .function .Function ;
2223
@@ -98,7 +99,7 @@ public void testDefaultRouting() {
9899
99100 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
100101 @ Test
101- public void testInvocationWithMessageAndHeader () {
102+ public void testInvocationWithMessageAndStringHeader () {
102103 FunctionCatalog functionCatalog = this .configureCatalog ();
103104 Function function = functionCatalog .lookup (RoutingFunction .FUNCTION_NAME );
104105 assertThat (function ).isNotNull ();
@@ -107,6 +108,57 @@ public void testInvocationWithMessageAndHeader() {
107108 assertThat (function .apply (message )).isEqualTo ("olleh" );
108109 }
109110
111+ @ SuppressWarnings ({ "unchecked" , "rawtypes" })
112+ @ Test
113+ public void testInvocationWithMessageAndListOfSingleElementHeader () {
114+ FunctionCatalog functionCatalog = this .configureCatalog ();
115+ Function function = functionCatalog .lookup (RoutingFunction .FUNCTION_NAME );
116+ assertThat (function ).isNotNull ();
117+ Message <String > message = MessageBuilder .withPayload ("hello" )
118+ .setHeader (FunctionProperties .PREFIX + ".definition" , List .of ("reverse" ))
119+ .build ();
120+ assertThat (function .apply (message )).isEqualTo ("olleh" );
121+ }
122+
123+ @ SuppressWarnings ({ "unchecked" , "rawtypes" })
124+ @ Test
125+ public void testCompositionWithMessageAndListOfMultipleElementsHeader () {
126+ FunctionCatalog functionCatalog = this .configureCatalog ();
127+ Function function = functionCatalog .lookup (RoutingFunction .FUNCTION_NAME );
128+ assertThat (function ).isNotNull ();
129+ Message <String > message = MessageBuilder .withPayload ("hello" )
130+ .setHeader (FunctionProperties .PREFIX + ".definition" ,
131+ List .of ("reverse" , "uppercase" ))
132+ .build ();
133+ assertThat (function .apply (message )).isEqualTo ("OLLEH" );
134+ }
135+
136+ @ SuppressWarnings ({ "unchecked" , "rawtypes" })
137+ @ Test
138+ public void testInvocationWithMessageAndListOfSingleRoutingExpression () {
139+ FunctionCatalog functionCatalog = this .configureCatalog ();
140+ Function function = functionCatalog .lookup (RoutingFunction .FUNCTION_NAME );
141+ assertThat (function ).isNotNull ();
142+ Message <String > message = MessageBuilder .withPayload ("hello" )
143+ .setHeader (FunctionProperties .PREFIX + ".routing-expression" ,
144+ List .of ("'reverse'" ))
145+ .build ();
146+ assertThat (function .apply (message )).isEqualTo ("olleh" );
147+ }
148+
149+ @ SuppressWarnings ({ "unchecked" , "rawtypes" })
150+ @ Test
151+ public void testInvocationWithMessageAndListOfMultipleRoutingExpressions () {
152+ FunctionCatalog functionCatalog = this .configureCatalog ();
153+ Function function = functionCatalog .lookup (RoutingFunction .FUNCTION_NAME );
154+ assertThat (function ).isNotNull ();
155+ Message <String > message = MessageBuilder .withPayload ("hello" )
156+ .setHeader (FunctionProperties .PREFIX + ".routing-expression" ,
157+ List .of ("'uppercase'" , "'reverse'" ))
158+ .build ();
159+ assertThat (function .apply (message )).isEqualTo ("HELLO" );
160+ }
161+
110162 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
111163 @ Test
112164 public void testRoutingSimpleInputWithReactiveFunctionWithMessageHeader () {
0 commit comments