@@ -177,6 +177,89 @@ public class Application {
177177"
178178`;
179179
180+ exports [` template integration tests using the generator should generate a consumer and return a payload when using x-scs-function-name and dynamic topic binding 1` ] = `
181+ "
182+ import java.util.function.Consumer;
183+
184+ import org.slf4j.Logger;
185+ import org.slf4j.LoggerFactory;
186+ import org.springframework.beans.factory.annotation.Autowired;
187+ import org.springframework.boot.SpringApplication;
188+ import org.springframework.boot.autoconfigure.SpringBootApplication;
189+ import org.springframework.cloud.stream.function.StreamBridge;
190+ import org.springframework.context.annotation.Bean;
191+ import org.springframework.messaging.Message;
192+ import org.springframework.messaging.support.MessageBuilder;
193+
194+ @SpringBootApplication
195+ public class Application {
196+
197+ private static final Logger logger = LoggerFactory .getLogger (Application .class );
198+
199+ @Autowired
200+ private StreamBridge streamBridge ;
201+
202+ public static void main (String [] args ) {
203+ SpringApplication.run(Application .class );
204+ }
205+
206+ // This is a consumer that calls a send method, instead of a function, because it has a dynamic channel and we need streamBridge.
207+ @Bean
208+ public Consumer <MySchema > sameFunctionName() {
209+ return data - > {
210+ // Add business logic here.
211+ logger.info(data .toString ());
212+ String messageId = \\"string\\";
213+ String operation = \\"string\\";
214+ MyOtherSchema payload = new MyOtherSchema();
215+ sendSameFunctionName(payload , messageId , operation );
216+ };
217+ }
218+
219+ public void sendSameFunctionName(
220+ MyOtherSchema payload, String messageId, String operation
221+ ) {
222+ String topic = String .format (\\" testLevel1/%s/%s\\ " ,
223+ messageId , operation );
224+ streamBridge .send (topic , payload );
225+ }
226+ }
227+ "
228+ `;
229+
230+ exports[`template integration tests using the generator should generate a function and return a payload when using x-scs-function-name and a static topic 1`] = `
231+ "
232+ import java.util.function.Function;
233+
234+ import org.slf4j.Logger;
235+ import org.slf4j.LoggerFactory;
236+ import org.springframework.boot.SpringApplication;
237+ import org.springframework.boot.autoconfigure.SpringBootApplication;
238+ import org.springframework.context.annotation.Bean;
239+ import org.springframework.messaging.Message;
240+
241+ @SpringBootApplication
242+ public class Application {
243+
244+ private static final Logger logger = LoggerFactory .getLogger (Application .class );
245+
246+ public static void main (String [] args ) {
247+ SpringApplication.run(Application .class );
248+ }
249+
250+ @Bean
251+ public Function < Message < ? > , Message < ? >> sameFunctionName () {
252+ return data -> {
253+ // Add business logic here.
254+ logger.info(data .toString ());
255+ return new Message<?>();
256+ };
257+ }
258+
259+ }
260+ "
261+ `;
262+
180263exports [` template integration tests using the generator should generate a model subclass when it sees an allOf 1` ] = `
181264"package com.acme;
182265
@@ -1501,53 +1584,3 @@ public class Debtor {
15011584}
15021585"
15031586`;
1504-
1505- exports[`template integration tests using the generator should return payload when using x-scs-function-name instead of logging the message 1`] = `
1506- "
1507- import java.util.function.Supplier;
1508-
1509- import org.slf4j.Logger;
1510- import org.slf4j.LoggerFactory;
1511- import org.springframework.beans.factory.annotation.Autowired;
1512- import org.springframework.boot.SpringApplication;
1513- import org.springframework.boot.autoconfigure.SpringBootApplication;
1514- import org.springframework.cloud.stream.function.StreamBridge;
1515- import org.springframework.context.annotation.Bean;
1516- import org.springframework.messaging.Message;
1517- import org.springframework.messaging.support.MessageBuilder;
1518-
1519- @SpringBootApplication
1520- public class Application {
1521-
1522- private static final Logger logger = LoggerFactory .getLogger (Application .class );
1523-
1524- @Autowired
1525- private StreamBridge streamBridge ;
1526-
1527- public static void main (String [] args ) {
1528- SpringApplication.run(Application .class );
1529- }
1530-
1531- // This is a consumer that calls a send method, instead of a function, because it has a dynamic channel and we need streamBridge.
1532- @Bean
1533- public Consumer <MySchema > sameFunctionName() {
1534- return data - > {
1535- // Add business logic here.
1536- logger.info(data .toString ());
1537- String messageId = \\"string\\";
1538- String operation = \\"string\\";
1539- MyOtherSchema payload = new MyOtherSchema();
1540- sendSameFunctionName(payload , messageId , operation );
1541- };
1542- }
1543-
1544- public void sendSameFunctionName(
1545- MyOtherSchema payload, String messageId, String operation
1546- ) {
1547- String topic = String .format (\\" testLevel1/%s/%s\\ " ,
1548- messageId , operation );
1549- streamBridge .send (topic , payload );
1550- }
1551- }
1552- "
1553- `;
0 commit comments