Skip to content

Commit ca41ec4

Browse files
committed
apply spotless
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent 8fea510 commit ca41ec4

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

plugin/src/test/java/org/opensearch/ml/action/models/DeleteModelTransportActionTests.java

+14-21
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@
1818
import static org.opensearch.ml.action.models.DeleteModelTransportAction.OS_STATUS_EXCEPTION_MESSAGE;
1919
import static org.opensearch.ml.action.models.DeleteModelTransportAction.SEARCH_FAILURE_MSG;
2020
import static org.opensearch.ml.action.models.DeleteModelTransportAction.TIMEOUT_MSG;
21-
import static org.opensearch.ml.common.CommonValue.ML_AGENT_INDEX;
2221
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX;
2322

24-
import java.io.ByteArrayOutputStream;
2523
import java.io.IOException;
26-
import java.io.ObjectOutputStream;
27-
import java.nio.ByteBuffer;
2824
import java.nio.charset.StandardCharsets;
2925
import java.util.ArrayList;
3026
import java.util.Arrays;
@@ -52,17 +48,13 @@
5248
import org.opensearch.action.search.SearchResponse;
5349
import org.opensearch.action.support.ActionFilters;
5450
import org.opensearch.client.Client;
55-
import org.opensearch.client.Response;
5651
import org.opensearch.cluster.service.ClusterService;
5752
import org.opensearch.common.settings.Settings;
5853
import org.opensearch.common.util.concurrent.ThreadContext;
5954
import org.opensearch.common.xcontent.XContentFactory;
60-
import org.opensearch.common.xcontent.XContentType;
6155
import org.opensearch.core.action.ActionListener;
62-
import org.opensearch.core.action.ActionResponse;
6356
import org.opensearch.core.common.bytes.BytesArray;
6457
import org.opensearch.core.common.bytes.BytesReference;
65-
import org.opensearch.core.xcontent.MediaType;
6658
import org.opensearch.core.xcontent.MediaTypeRegistry;
6759
import org.opensearch.core.xcontent.NamedXContentRegistry;
6860
import org.opensearch.core.xcontent.ToXContent;
@@ -80,7 +72,6 @@
8072
import org.opensearch.ml.model.MLModelManager;
8173
import org.opensearch.search.SearchHit;
8274
import org.opensearch.search.SearchHits;
83-
import org.opensearch.search.pipeline.PipelineConfiguration;
8475
import org.opensearch.test.OpenSearchTestCase;
8576
import org.opensearch.threadpool.ThreadPool;
8677
import org.opensearch.transport.TransportService;
@@ -139,7 +130,6 @@ public class DeleteModelTransportActionTests extends OpenSearchTestCase {
139130
@Mock
140131
private org.opensearch.search.pipeline.PipelineConfiguration searchPipelineConfiguration;
141132

142-
143133
@Mock
144134
GetPipelineResponse getIngestionPipelineResponse;
145135

@@ -217,7 +207,9 @@ public void testDeleteModel_BlockedBySearchPipeline() throws IOException {
217207

218208
public void testDeleteModel_BlockedByIngestPipeline() throws IOException {
219209
org.opensearch.ingest.PipelineConfiguration ingestPipelineConfiguration = new org.opensearch.ingest.PipelineConfiguration(
220-
"1", new BytesArray("{\"model_id\": \"test_id\"}".getBytes(StandardCharsets.UTF_8)), MediaTypeRegistry.JSON
210+
"1",
211+
new BytesArray("{\"model_id\": \"test_id\"}".getBytes(StandardCharsets.UTF_8)),
212+
MediaTypeRegistry.JSON
221213
);
222214
when(getIngestionPipelineResponse.pipelines()).thenReturn(List.of(ingestPipelineConfiguration));
223215
doAnswer(invocation -> {
@@ -229,7 +221,10 @@ public void testDeleteModel_BlockedByIngestPipeline() throws IOException {
229221
deleteModelTransportAction.doExecute(null, mlModelDeleteRequest, actionListener);
230222
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
231223
verify(actionListener).onFailure(argumentCaptor.capture());
232-
assertEquals("1 ingest pipelines are still using this model, please delete or update the pipelines first: [1]", argumentCaptor.getValue().getMessage());
224+
assertEquals(
225+
"1 ingest pipelines are still using this model, please delete or update the pipelines first: [1]",
226+
argumentCaptor.getValue().getMessage()
227+
);
233228
}
234229

235230
public void testDeleteModel_BlockedByAgent() throws IOException {
@@ -245,7 +240,10 @@ public void testDeleteModel_BlockedByAgent() throws IOException {
245240
deleteModelTransportAction.doExecute(null, mlModelDeleteRequest, actionListener);
246241
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
247242
verify(actionListener).onFailure(argumentCaptor.capture());
248-
assertEquals("1 agents are still using this model, please delete or update the agents first: [1]", argumentCaptor.getValue().getMessage());
243+
assertEquals(
244+
"1 agents are still using this model, please delete or update the agents first: [1]",
245+
argumentCaptor.getValue().getMessage()
246+
);
249247
}
250248

251249
public void testDeleteRemoteModel_Success() throws IOException {
@@ -277,7 +275,6 @@ public void testDeleteRemoteModel_deleteModelController_failed() throws IOExcept
277275
return null;
278276
}).when(client).delete(any(), any());
279277

280-
281278
GetResponse getResponse = prepareModelWithFunction(MLModelState.REGISTERED, null, false, FunctionName.REMOTE);
282279
doAnswer(invocation -> {
283280
ActionListener<GetResponse> actionListener = invocation.getArgument(1);
@@ -460,7 +457,6 @@ public void testDeleteModel_deleteModelController_ResourceNotFoundException() th
460457
return null;
461458
}).when(client).delete(any(), any());
462459

463-
464460
GetResponse getResponse = prepareMLModel(MLModelState.REGISTERED, null, false);
465461
doAnswer(invocation -> {
466462
ActionListener<GetResponse> actionListener = invocation.getArgument(1);
@@ -504,7 +500,6 @@ public void testDeleteRemoteModel_modelNotFound_ResourceNotFoundException() thro
504500
return null;
505501
}).when(client).delete(any(), any());
506502

507-
508503
GetResponse getResponse = prepareModelWithFunction(MLModelState.REGISTERED, null, false, FunctionName.REMOTE);
509504
doAnswer(invocation -> {
510505
ActionListener<GetResponse> actionListener = invocation.getArgument(1);
@@ -529,7 +524,6 @@ public void testDeleteRemoteModel_modelNotFound_RuntimeException() throws IOExce
529524
return null;
530525
}).when(client).delete(any(), any());
531526

532-
533527
GetResponse getResponse = prepareModelWithFunction(MLModelState.REGISTERED, null, false, FunctionName.REMOTE);
534528
doAnswer(invocation -> {
535529
ActionListener<GetResponse> actionListener = invocation.getArgument(1);
@@ -683,7 +677,7 @@ private GetResponse buildResponse(MLModel mlModel) throws IOException {
683677

684678
private void prepare() {
685679
emptyBulkByScrollResponse = new BulkByScrollResponse(new ArrayList<>(), null);
686-
SearchHits hits = new SearchHits(new SearchHit[] { }, new TotalHits(0, TotalHits.Relation.EQUAL_TO), 0.0f);
680+
SearchHits hits = new SearchHits(new SearchHit[] {}, new TotalHits(0, TotalHits.Relation.EQUAL_TO), 0.0f);
687681
when(searchResponse.getHits()).thenReturn(hits);
688682
when(getIngestionPipelineResponse.pipelines()).thenReturn(List.of());
689683

@@ -693,7 +687,6 @@ private void prepare() {
693687
return null;
694688
}).when(client).search(any(), any());
695689

696-
697690
doAnswer(invocation -> {
698691
ActionListener<BulkByScrollResponse> listener = invocation.getArgument(2);
699692
listener.onResponse(emptyBulkByScrollResponse);
@@ -712,8 +705,8 @@ private void prepare() {
712705
listener.onResponse(getSearchPipelineResponse);
713706
return null;
714707
}).when(client).execute(eq(GetSearchPipelineAction.INSTANCE), any(), any());
715-
configDataMap = Map.of("model_id", "test_id", "list_model_id", List.of("test_list_id"),
716-
"test_map_id", Map.of("test_key", "test_map_id"));
708+
configDataMap = Map
709+
.of("model_id", "test_id", "list_model_id", List.of("test_list_id"), "test_map_id", Map.of("test_key", "test_map_id"));
717710
doAnswer(invocation -> new SearchRequest()).when(relatedModelIdHelper).constructQueryRequest(any());
718711
}
719712
}

0 commit comments

Comments
 (0)