2424import  static  io .serverlessworkflow .fluent .agentic .AgentsUtils .newStyleEditor ;
2525import  static  io .serverlessworkflow .fluent .agentic .AgentsUtils .newStyleScorer ;
2626import  static  io .serverlessworkflow .fluent .agentic .AgentsUtils .newSummaryStory ;
27- import  static  io .serverlessworkflow .fluent .agentic .dsl .AgenticDSL .fn ;
2827import  static  io .serverlessworkflow .fluent .agentic .langchain4j .Agents .*;
2928import  static  io .serverlessworkflow .fluent .agentic .langchain4j .Agents .AudienceEditor ;
3029import  static  io .serverlessworkflow .fluent .agentic .langchain4j .Agents .CreativeWriter ;
3130import  static  io .serverlessworkflow .fluent .agentic .langchain4j .Agents .StyleEditor ;
3231import  static  io .serverlessworkflow .fluent .agentic .langchain4j .Models .BASE_MODEL ;
3332import  static  org .junit .jupiter .api .Assertions .assertEquals ;
3433import  static  org .junit .jupiter .api .Assertions .assertNotNull ;
35- import  static  org .junit .jupiter .api .Assertions .assertTrue ;
3634import  static  org .mockito .ArgumentMatchers .any ;
3735import  static  org .mockito .ArgumentMatchers .eq ;
3836import  static  org .mockito .Mockito .spy ;
4846import  java .util .function .Function ;
4947import  java .util .function .Predicate ;
5048import  java .util .stream .IntStream ;
51- 
5249import  org .junit .jupiter .api .Test ;
5350
5451public  class  WorkflowAgentsIT  {
@@ -106,9 +103,9 @@ public void sequenceHelperTest() {
106103    var  styleEditor  = newStyleEditor ();
107104
108105    AgentsUtils .NovelCreator  novelCreator  =
109-              io .serverlessworkflow .fluent .agentic .AgenticServices .of (AgentsUtils .NovelCreator .class )
110-                      .flow (workflow ("seqFlow" ).sequence (creativeWriter , audienceEditor , styleEditor ))
111-                      .build ();
106+         io .serverlessworkflow .fluent .agentic .AgenticServices .of (AgentsUtils .NovelCreator .class )
107+             .flow (workflow ("seqFlow" ).sequence (creativeWriter , audienceEditor , styleEditor ))
108+             .build ();
112109
113110    String  story  = novelCreator .createNovel ("dragons and wizards" , "young adults" , "fantasy" );
114111    assertNotNull (story );
@@ -121,9 +118,9 @@ public void agentAndSequenceHelperTest() {
121118    var  styleEditor  = newStyleEditor ();
122119
123120    AgentsUtils .NovelCreator  novelCreator  =
124-              io .serverlessworkflow .fluent .agentic .AgenticServices .of (AgentsUtils .NovelCreator .class )
125-                      .flow (workflow ("seqFlow" ).agent (creativeWriter ).sequence (audienceEditor , styleEditor ))
126-                      .build ();
121+         io .serverlessworkflow .fluent .agentic .AgenticServices .of (AgentsUtils .NovelCreator .class )
122+             .flow (workflow ("seqFlow" ).agent (creativeWriter ).sequence (audienceEditor , styleEditor ))
123+             .build ();
127124
128125    String  story  = novelCreator .createNovel ("dragons and wizards" , "young adults" , "fantasy" );
129126    assertNotNull (story );
@@ -137,13 +134,13 @@ public void agentAndSequenceAndAgentHelperTest() {
137134    var  summaryStory  = newSummaryStory ();
138135
139136    AgentsUtils .NovelCreator  novelCreator  =
140-              io .serverlessworkflow .fluent .agentic .AgenticServices .of (AgentsUtils .NovelCreator .class )
141-                      .flow (
142-                              workflow ("seqFlow" )
143-                                      .agent (creativeWriter )
144-                                      .sequence (audienceEditor , styleEditor )
145-                                      .agent (summaryStory ))
146-                      .build ();
137+         io .serverlessworkflow .fluent .agentic .AgenticServices .of (AgentsUtils .NovelCreator .class )
138+             .flow (
139+                 workflow ("seqFlow" )
140+                     .agent (creativeWriter )
141+                     .sequence (audienceEditor , styleEditor )
142+                     .agent (summaryStory ))
143+             .build ();
147144
148145    String  story  = novelCreator .createNovel ("dragons and wizards" , "young adults" , "fantasy" );
149146    assertNotNull (story );
@@ -155,20 +152,20 @@ public void parallelWorkflow() {
155152    var  movieExpert  = newMovieExpert ();
156153
157154    Function <Map <String , List <String >>, List <EveningPlan >> planEvening  =
158-              input  -> {
159-                List <String > movies  = input .get ("findMovie" );
160-                List <String > meals  = input .get ("findMeal" );
155+         input  -> {
156+           List <String > movies  = input .get ("findMovie" );
157+           List <String > meals  = input .get ("findMeal" );
161158
162-                int  max  = Math .min (movies .size (), meals .size ());
163-                return  IntStream .range (0 , max )
164-                        .mapToObj (i  -> new  EveningPlan (movies .get (i ), meals .get (i )))
165-                        .toList ();
166-              };
159+           int  max  = Math .min (movies .size (), meals .size ());
160+           return  IntStream .range (0 , max )
161+               .mapToObj (i  -> new  EveningPlan (movies .get (i ), meals .get (i )))
162+               .toList ();
163+         };
167164
168165    EveningPlannerAgent  eveningPlannerAgent  =
169-              AgenticServices .of (EveningPlannerAgent .class )
170-                      .flow (workflow ("parallelFlow" ).parallel (foodExpert , movieExpert ).outputAs (planEvening ))
171-                      .build ();
166+         AgenticServices .of (EveningPlannerAgent .class )
167+             .flow (workflow ("parallelFlow" ).parallel (foodExpert , movieExpert ).outputAs (planEvening ))
168+             .build ();
172169    List <EveningPlan > result  = eveningPlannerAgent .plan ("romantic" );
173170    assertEquals (3 , result .size ());
174171  }
@@ -182,9 +179,9 @@ public void loopTest() {
182179    Predicate <AgenticScope > until  = s  -> s .readState ("score" , 0.0 ) >= 0.8 ;
183180
184181    StyledWriter  styledWriter  =
185-              AgenticServices .of (StyledWriter .class )
186-                      .flow (workflow ("loopFlow" ).agent (creativeWriter ).loop (until , scorer , editor ))
187-                      .build ();
182+         AgenticServices .of (StyledWriter .class )
183+             .flow (workflow ("loopFlow" ).agent (creativeWriter ).loop (until , scorer , editor ))
184+             .build ();
188185
189186    String  story  = styledWriter .writeStoryWithStyle ("dragons and wizards" , "fantasy" );
190187    assertNotNull (story );
@@ -195,25 +192,25 @@ public void humanInTheLoop() {
195192    var  astrologyAgent  = newAstrologyAgent ();
196193
197194    var  askSign  =
198-              new  Function <Map <String , Object >, Map <String , Object >>() {
199-                @ Override 
200-                public  Map <String , Object > apply (Map <String , Object > holder ) {
201-                  System .out .println ("What's your star sign?" );
202-                  // var sign = System.console().readLine(); 
203-                  holder .put ("sign" , "piscis" );
204-                  return  holder ;
205-                }
206-              };
195+         new  Function <Map <String , Object >, Map <String , Object >>() {
196+           @ Override 
197+           public  Map <String , Object > apply (Map <String , Object > holder ) {
198+             System .out .println ("What's your star sign?" );
199+             // var sign = System.console().readLine(); 
200+             holder .put ("sign" , "piscis" );
201+             return  holder ;
202+           }
203+         };
207204
208205    String  result  =
209-              AgenticServices .of (Agents .HoroscopeAgent .class )
210-                      .flow (
211-                              workflow ("humanInTheLoop" )
212-                                      .inputFrom (askSign )
213-                                      // .tasks(tasks -> tasks.callFn(fn(askSign))) // TODO should work too 
214-                                      .agent (astrologyAgent ))
215-                      .build ()
216-                      .invoke ("My name is Mario. What is my horoscope?" );
206+         AgenticServices .of (Agents .HoroscopeAgent .class )
207+             .flow (
208+                 workflow ("humanInTheLoop" )
209+                     .inputFrom (askSign )
210+                     // .tasks(tasks -> tasks.callFn(fn(askSign))) // TODO should work too 
211+                     .agent (astrologyAgent ))
212+             .build ()
213+             .invoke ("My name is Mario. What is my horoscope?" );
217214
218215    assertNotNull (result );
219216  }
0 commit comments