29
29
30
30
import static org .opensearch .flowframework .common .WorkflowResources .MODEL_ID ;
31
31
import static org .mockito .ArgumentMatchers .any ;
32
+ import static org .mockito .ArgumentMatchers .nullable ;
32
33
import static org .mockito .Mockito .doAnswer ;
33
34
import static org .mockito .Mockito .verify ;
34
35
@@ -54,12 +55,12 @@ public void testDeleteModel() throws IOException, ExecutionException, Interrupte
54
55
55
56
doAnswer (invocation -> {
56
57
String modelIdArg = invocation .getArgument (0 );
57
- ActionListener <DeleteResponse > actionListener = invocation .getArgument (1 );
58
+ ActionListener <DeleteResponse > actionListener = invocation .getArgument (2 );
58
59
ShardId shardId = new ShardId (new Index ("indexName" , "uuid" ), 1 );
59
60
DeleteResponse output = new DeleteResponse (shardId , modelIdArg , 1 , 1 , 1 , true );
60
61
actionListener .onResponse (output );
61
62
return null ;
62
- }).when (machineLearningNodeClient ).deleteModel (any (String .class ), any ());
63
+ }).when (machineLearningNodeClient ).deleteModel (any (String .class ), nullable ( String . class ), any ());
63
64
64
65
PlainActionFuture <WorkflowData > future = deleteModelStep .execute (
65
66
inputData .getNodeId (),
@@ -69,7 +70,7 @@ public void testDeleteModel() throws IOException, ExecutionException, Interrupte
69
70
Collections .emptyMap (),
70
71
null
71
72
);
72
- verify (machineLearningNodeClient ).deleteModel (any (String .class ), any ());
73
+ verify (machineLearningNodeClient ).deleteModel (any (String .class ), nullable ( String . class ), any ());
73
74
74
75
assertTrue (future .isDone ());
75
76
assertEquals (modelId , future .get ().getContent ().get (MODEL_ID ));
@@ -81,10 +82,10 @@ public void testDeleteModelNotFound() throws IOException, ExecutionException, In
81
82
DeleteModelStep deleteModelStep = new DeleteModelStep (machineLearningNodeClient );
82
83
83
84
doAnswer (invocation -> {
84
- ActionListener <DeleteResponse > actionListener = invocation .getArgument (1 );
85
+ ActionListener <DeleteResponse > actionListener = invocation .getArgument (2 );
85
86
actionListener .onFailure (new OpenSearchStatusException ("No model found with that id" , RestStatus .NOT_FOUND ));
86
87
return null ;
87
- }).when (machineLearningNodeClient ).deleteModel (any (String .class ), any ());
88
+ }).when (machineLearningNodeClient ).deleteModel (any (String .class ), nullable ( String . class ), any ());
88
89
89
90
PlainActionFuture <WorkflowData > future = deleteModelStep .execute (
90
91
inputData .getNodeId (),
@@ -94,7 +95,7 @@ public void testDeleteModelNotFound() throws IOException, ExecutionException, In
94
95
Collections .emptyMap (),
95
96
null
96
97
);
97
- verify (machineLearningNodeClient ).deleteModel (any (String .class ), any ());
98
+ verify (machineLearningNodeClient ).deleteModel (any (String .class ), nullable ( String . class ), any ());
98
99
99
100
assertTrue (future .isDone ());
100
101
assertEquals (modelId , future .get ().getContent ().get (MODEL_ID ));
@@ -122,10 +123,10 @@ public void testDeleteModelFailure() throws IOException {
122
123
DeleteModelStep deleteModelStep = new DeleteModelStep (machineLearningNodeClient );
123
124
124
125
doAnswer (invocation -> {
125
- ActionListener <DeleteResponse > actionListener = invocation .getArgument (1 );
126
+ ActionListener <DeleteResponse > actionListener = invocation .getArgument (2 );
126
127
actionListener .onFailure (new FlowFrameworkException ("Failed to delete model" , RestStatus .INTERNAL_SERVER_ERROR ));
127
128
return null ;
128
- }).when (machineLearningNodeClient ).deleteModel (any (String .class ), any ());
129
+ }).when (machineLearningNodeClient ).deleteModel (any (String .class ), nullable ( String . class ), any ());
129
130
130
131
PlainActionFuture <WorkflowData > future = deleteModelStep .execute (
131
132
inputData .getNodeId (),
@@ -136,7 +137,7 @@ public void testDeleteModelFailure() throws IOException {
136
137
null
137
138
);
138
139
139
- verify (machineLearningNodeClient ).deleteModel (any (String .class ), any ());
140
+ verify (machineLearningNodeClient ).deleteModel (any (String .class ), nullable ( String . class ), any ());
140
141
141
142
assertTrue (future .isDone ());
142
143
ExecutionException ex = assertThrows (ExecutionException .class , () -> future .get ().getContent ());
0 commit comments