File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
plugin/src/test/java/org/opensearch/ml/action/tasks Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 36
36
import org .opensearch .core .xcontent .NamedXContentRegistry ;
37
37
import org .opensearch .core .xcontent .ToXContent ;
38
38
import org .opensearch .core .xcontent .XContentBuilder ;
39
+ import org .opensearch .index .IndexNotFoundException ;
39
40
import org .opensearch .index .get .GetResult ;
40
41
import org .opensearch .ml .common .MLTask ;
41
42
import org .opensearch .ml .common .MLTaskState ;
@@ -146,6 +147,20 @@ public void testDeleteTask_ResourceNotFoundException() throws IOException {
146
147
assertEquals ("Failed to get data object from index .plugins-ml-task" , argumentCaptor .getValue ().getMessage ());
147
148
}
148
149
150
+ public void testDeleteTask_IndexNotFoundException () {
151
+ doAnswer (invocation -> {
152
+ ActionListener <GetResponse > actionListener = invocation .getArgument (1 );
153
+ actionListener .onFailure (new IndexNotFoundException (ML_TASK_INDEX ));
154
+ return null ;
155
+ }).when (client ).get (any (), any ());
156
+
157
+ deleteTaskTransportAction .doExecute (null , mlTaskDeleteRequest , actionListener );
158
+
159
+ ArgumentCaptor <Exception > argumentCaptor = ArgumentCaptor .forClass (Exception .class );
160
+ verify (actionListener ).onFailure (argumentCaptor .capture ());
161
+ assertEquals ("Failed to find task" , argumentCaptor .getValue ().getMessage ());
162
+ }
163
+
149
164
public void testDeleteTask_GetResponseNotExistsException () {
150
165
GetResult getResult = new GetResult (
151
166
ML_TASK_INDEX ,
You can’t perform that action at this time.
0 commit comments