/* Ċ Ġ* ĠCopyright Ġ 2 0 1 8 - 2 0 2 0 Ġthe Ġoriginal Ġauthor Ġor Ġauthors . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttps :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġorg . springframework . integration . dsl . rout ers Ċ Ċ import Ġassert k . assertThat Ċ import Ġassert k . assertions . isEqualTo Ċ import Ġassert k . assertions . isInstanceOf Ċ import Ġassert k . assertions . isNotNull Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . beans . factory . annotation . Qualifier Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġorg . springframework . integration . channel . Queue Channel Ċ import Ġorg . springframework . integration . config . Enable Integration Ċ import Ġorg . springframework . integration . dsl . Message Channels Ċ import Ġorg . springframework . integration . dsl . integration Flow Ċ import Ġorg . springframework . integration . support . Message Builder Ċ import Ġorg . springframework . messaging . Message Channel Ċ import Ġorg . springframework . messaging . Poll able Channel Ċ import Ġorg . springframework . messaging . support . Generic Message Ċ import Ġorg . springframework . test . annotation . Dir ties Context Ċ import Ġorg . springframework . test . context . junit . jupiter . Spring JUnit Config ĊĊ Ċ /** Ċ Ġ* Ġ@ author ĠArt em ĠB il an Ċ Ġ* Ċ Ġ* Ġ@ since Ġ 5 . 0 . 5 Ċ Ġ*/ Ċ @ Spring JUnit Config Ċ @ Dir ties Context Ċ class ĠRouter Dsl Tests Ġ{ ĊĊ ĉ @ Autowired Ċ ĉ @ Qualifier (" router Two Sub Flows . input ") Ċ ĉ private Ġlateinit Ġvar Ġrouter Two Sub Flows Input : ĠMessage Channel ĊĊ ĉ @ Autowired Ċ ĉ @ Qualifier (" router Two Sub Flows Output ") Ċ ĉ private Ġlateinit Ġvar Ġrouter Two Sub Flows Output : ĠPoll able Channel ĊĊ ĉ @ Test Ċ ĉ fun Ġ` route Ġto Ġtwo Ġsub flows Ġusing Ġlambda `() Ġ{ ĊĊĉ ĉ this . router Two Sub Flows Input . send ( Generic Message < Any >( listOf ( 1 , Ġ 2 , Ġ 3 , Ġ 4 , Ġ 5 , Ġ 6 ))) Ċĉ ĉ val Ġreceive Ġ= Ġthis . router Two Sub Flows Output . receive ( 1 0 0 0 0 ) ĊĊĉ ĉ val Ġpayload Ġ= Ġreceive ?. payload ĊĊĉ ĉ assertThat ( payload ) Ċĉĉĉ ĉ . isNotNull () Ċĉĉĉ ĉ . isInstanceOf ( List :: class . java ) Ċĉĉĉ ĉ . isEqualTo ( listOf ( 3 , Ġ 4 , Ġ 9 , Ġ 8 , Ġ 1 5 , Ġ 1 2 )) Ċ ĉ } ĊĊĊ ĉ @ Autowired Ċ ĉ @ Qualifier (" split Route Aggregate . input ") Ċ ĉ private Ġlateinit Ġvar Ġsplit Route Aggregate Input : ĠMessage Channel ĊĊ ĉ @ Test Ċ ĉ fun Ġ` route Ġto Ġtwo Ġsub flows Ġusing Ġthem Ġas Ġbean Ġreferences `() Ġ{ ĊĊĉ ĉ val Ġreply Channel Ġ= ĠQueue Channel () Ċĉ ĉ val Ġmessage Ġ= ĠMessage Builder . with Payload ( array Of ( 1 , Ġ 2 , Ġ 3 )) Ċĉĉĉ ĉ . set Reply Channel ( reply Channel ) Ċĉĉĉ ĉ . build () ĊĊĉ ĉ this . split Route Aggregate Input . send ( message ) ĊĊĉ ĉ val Ġreceive Ġ= Ġreply Channel . receive ( 1 0 0 0 0 ) ĊĊĉ ĉ val Ġpayload Ġ= Ġreceive ?. payload ĊĊĉ ĉ assertThat ( payload ) Ċĉĉĉ ĉ . isNotNull () Ċĉĉĉ ĉ . isInstanceOf ( List :: class . java ) Ċĉĉĉ ĉ . isEqualTo ( listOf (" even ", Ġ" odd ", Ġ" even ")) Ċ ĉ } ĊĊ ĉ @ Configuration Ċ ĉ @ Enable Integration Ċ ĉ class ĠConfig Ġ{ ĊĊĉ ĉ @ Bean Ċĉ ĉ fun Ġrouter Two Sub Flows () Ġ= Ċĉĉĉ ĉ integration Flow Ġ{ Ċĉĉĉĉ ĉ split () Ċĉĉĉĉ ĉ route < Int , ĠBoolean >({ Ġit Ġ% Ġ 2 Ġ== Ġ 0 Ġ}) Ġ{ Ċĉĉĉĉĉ ĉ sub Flow Mapping ( true ) Ġ{ Ġhandle < Int > Ġ{ Ġp , Ġ_ Ġ-> Ġp Ġ* Ġ 2 Ġ} Ġ} Ċĉĉĉĉĉ ĉ sub Flow Mapping ( false ) Ġ{ Ġhandle < Int > Ġ{ Ġp , Ġ_ Ġ-> Ġp Ġ* Ġ 3 Ġ} Ġ} Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ aggregate () Ċĉĉĉĉ ĉ channel Ġ{ Ġqueue (" router Two Sub Flows Output ") Ġ} Ċĉĉĉ ĉ } ĊĊĉ ĉ @ Bean Ċĉ ĉ fun Ġsplit Route Aggregate () Ġ= Ċĉĉĉ ĉ integration Flow Ġ{ Ċĉĉĉĉ ĉ split () Ċĉĉĉĉ ĉ route < Int , ĠBoolean >({ Ġit Ġ% Ġ 2 Ġ== Ġ 0 Ġ}) Ġ{ Ċĉĉĉĉĉ ĉ sub Flow Mapping ( true ) Ġ{ Ġgateway ( odd Flow (). input Channel ) Ġ} Ċĉĉĉĉĉ ĉ sub Flow Mapping ( false ) Ġ{ Ġgateway ( even Flow (). input Channel ) Ġ} Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ aggregate () Ċĉĉĉ ĉ } ĊĊĉ ĉ @ Bean Ċĉ ĉ fun Ġodd Flow () Ġ= Ċĉĉĉ ĉ integration Flow Ġ{ Ċĉĉĉĉ ĉ handle < Any > Ġ{ Ġ_, Ġ_ Ġ-> Ġ" odd " Ġ} Ċĉĉĉ ĉ } ĊĊĉ ĉ @ Bean Ċĉ ĉ fun Ġeven Flow () Ġ= Ċĉĉĉ ĉ integration Flow Ġ{ Ċĉĉĉĉ ĉ handle < Any > Ġ{ Ġ_, Ġ_ Ġ-> Ġ" even " Ġ} Ċĉĉĉ ĉ } ĊĊĉ ĉ @ Bean Ċĉ ĉ fun Ġpublish Subscribe () Ġ= Ċĉĉĉ ĉ Message Channels . publish Subscribe () Ċĉĉĉĉĉ ĉ . ignore Failures ( true ) Ċĉĉĉĉĉ ĉ . apply Sequence ( false ) Ċ ĉ } Ċ Ċ } Ċ