11package org .testar .action .priorization .llm ;
22
3+ import static org .junit .Assert .assertEquals ;
4+
35import java .util .HashSet ;
46import java .util .Set ;
57
@@ -222,6 +224,18 @@ public void test_llm_selects_android_type_action() {
222224 Assert .isTrue (innerText .equals ("testar" ));
223225 }
224226
227+ @ Test
228+ public void test_parsing_hit_escape_action () {
229+ String llmResponse = "```json{\" actionId\" :\" AID_HitEsc\" ,\" input\" :\" \" }```" ;
230+ Set <Action > derivedActions = createDefaultDerivedActions (createState ());
231+
232+ LlmParseActionResponse llmParseResponse = new LlmParseActionResponse ();
233+ LlmParseActionResult llmParseResult = llmParseResponse .parseLlmResponse (derivedActions , llmResponse );
234+
235+ assertEquals (LlmParseActionResult .ParseResult .SUCCESS , llmParseResult .getParseResult ());
236+ assertEquals ("AID_HitEsc" , llmParseResult .getActionToExecute ().get (Tags .AbstractID ));
237+ }
238+
225239 private static StateStub createState () {
226240 StateStub createdState = new StateStub ();
227241 createdState .set (WdTags .WebTitle , "Page Title | State" );
@@ -241,6 +255,7 @@ private static Set<Action> createDefaultDerivedActions(StateStub state) {
241255 derivedActions .add (createSelectAction (state , "combobox_widget_desc" , "combobox_widget_web_id" ,
242256 "CID_combobox_widget" , "AID_combobox_widget" , "CID_select" , "AID_select" , "Saab" ));
243257 derivedActions .add (createAndroidTypeAction (state ));
258+ derivedActions .add (createHitEscAction (state , "CID_HitEsc" , "AID_HitEsc" ));
244259 return derivedActions ;
245260 }
246261
@@ -321,4 +336,11 @@ private static Action createAndroidTypeAction(StateStub parentState) {
321336 return action ;
322337 }
323338
339+ private static Action createHitEscAction (StateStub parentState , String actionConcreteId , String actionAbstractId ) {
340+ Action action = ac .hitESC (parentState );
341+ action .set (Tags .ConcreteID , actionConcreteId );
342+ action .set (Tags .AbstractID , actionAbstractId );
343+ return action ;
344+ }
345+
324346}
0 commit comments