@@ -106,6 +106,8 @@ public class InteractionsIndexTests extends OpenSearchTestCase {
106
106
107
107
InteractionsIndex interactionsIndex ;
108
108
109
+ Interaction interaction ;
110
+
109
111
@ Before
110
112
public void setup () {
111
113
this .client = mock (Client .class );
@@ -123,6 +125,16 @@ public void setup() {
123
125
doReturn (indicesAdminClient ).when (adminClient ).indices ();
124
126
doReturn (threadPool ).when (client ).threadPool ();
125
127
doReturn (new ThreadContext (Settings .EMPTY )).when (threadPool ).getThreadContext ();
128
+ interaction = new Interaction (
129
+ "iid" ,
130
+ Instant .ofEpochMilli (1234 ),
131
+ "cid" ,
132
+ "inp" ,
133
+ "pt" ,
134
+ "rsp" ,
135
+ "ogn" ,
136
+ Collections .singletonMap ("metadata" , "some meta" )
137
+ );
126
138
this .interactionsIndex = spy (new InteractionsIndex (client , clusterService , conversationMetaIndex ));
127
139
}
128
140
@@ -573,7 +585,7 @@ public void testDelete_BulkHasFailures_ReturnFalse() {
573
585
}).when (client ).bulk (any (), any ());
574
586
doAnswer (invocation -> {
575
587
ActionListener <List <Interaction >> al = invocation .getArgument (2 );
576
- al .onResponse (List .of ());
588
+ al .onResponse (List .of (interaction ));
577
589
return null ;
578
590
}).when (interactionsIndex ).getAllInteractions (anyString (), anyInt (), any ());
579
591
@ SuppressWarnings ("unchecked" )
@@ -594,7 +606,7 @@ public void testDelete_BulkFails_ThenFail() {
594
606
}).when (client ).bulk (any (), any ());
595
607
doAnswer (invocation -> {
596
608
ActionListener <List <Interaction >> al = invocation .getArgument (2 );
597
- al .onResponse (List .of ());
609
+ al .onResponse (List .of (interaction ));
598
610
return null ;
599
611
}).when (interactionsIndex ).getAllInteractions (anyString (), anyInt (), any ());
600
612
@ SuppressWarnings ("unchecked" )
@@ -621,6 +633,22 @@ public void testDelete_SearchFails_ThenFail() {
621
633
assert (argCaptor .getValue ().getMessage ().equals ("Failure during GetAllInteractions" ));
622
634
}
623
635
636
+ public void testDelete_SearchReturnEmpty_ThenPass () {
637
+ doReturn (true ).when (metadata ).hasIndex (anyString ());
638
+ setupGrantAccess ();
639
+ doAnswer (invocation -> {
640
+ ActionListener <List <Interaction >> al = invocation .getArgument (2 );
641
+ al .onResponse (List .of ());
642
+ return null ;
643
+ }).when (interactionsIndex ).getAllInteractions (anyString (), anyInt (), any ());
644
+ @ SuppressWarnings ("unchecked" )
645
+ ActionListener <Boolean > deleteConversationListener = mock (ActionListener .class );
646
+ interactionsIndex .deleteConversation ("cid" , deleteConversationListener );
647
+ ArgumentCaptor <Boolean > argCaptor = ArgumentCaptor .forClass (Boolean .class );
648
+ verify (deleteConversationListener , times (1 )).onResponse (argCaptor .capture ());
649
+ assert (argCaptor .getValue ());
650
+ }
651
+
624
652
public void testDelete_NoAccessNoUser_ThenFail () {
625
653
doReturn (true ).when (metadata ).hasIndex (anyString ());
626
654
setupDenyAccess (null );
0 commit comments