diff --git a/plugin/src/test/java/org/opensearch/ml/action/models/DeleteModelTransportActionTests.java b/plugin/src/test/java/org/opensearch/ml/action/models/DeleteModelTransportActionTests.java index 71607578ee..2426abcbcf 100644 --- a/plugin/src/test/java/org/opensearch/ml/action/models/DeleteModelTransportActionTests.java +++ b/plugin/src/test/java/org/opensearch/ml/action/models/DeleteModelTransportActionTests.java @@ -211,19 +211,14 @@ public void testDeleteModel_BlockedBySearchPipelineAndIngestionPipeline() throws return null; }).when(client).get(any(), any()); - - when(getSearchPipelineResponse.toString()).thenReturn( - StringUtils.toJson(Map.of("search_1", configDataMap)) - ); + when(getSearchPipelineResponse.toString()).thenReturn(StringUtils.toJson(Map.of("search_1", configDataMap))); doAnswer(invocation -> { ActionListener listener = invocation.getArgument(2); listener.onResponse(getSearchPipelineResponse); return null; }).when(client).execute(eq(GetSearchPipelineAction.INSTANCE), any(), any()); - when(getIngestionPipelineResponse.toString()).thenReturn( - StringUtils.toJson(Map.of("ingest_1", Map.of("model_id", "test_id"))) - ); + when(getIngestionPipelineResponse.toString()).thenReturn(StringUtils.toJson(Map.of("ingest_1", Map.of("model_id", "test_id")))); doAnswer(invocation -> { ActionListener listener = invocation.getArgument(2); listener.onResponse(getIngestionPipelineResponse); @@ -236,7 +231,13 @@ public void testDeleteModel_BlockedBySearchPipelineAndIngestionPipeline() throws String totalErrorMessage = argumentCaptor.getValue().getMessage(); String[] separateErrorMessages = totalErrorMessage.split("\\. "); Set generateErrorMessages = new HashSet<>(List.of(separateErrorMessages)); - Set expectedErrorMessages = new HashSet<>(List.of("1 ingest pipelines are still using this model, please delete or update the pipelines first: [ingest_1]", "1 search pipelines are still using this model, please delete or update the pipelines first: [search_1]")); + Set expectedErrorMessages = new HashSet<>( + List + .of( + "1 ingest pipelines are still using this model, please delete or update the pipelines first: [ingest_1]", + "1 search pipelines are still using this model, please delete or update the pipelines first: [search_1]" + ) + ); Boolean flag = false; for (String errorMessage : generateErrorMessages) { if (!expectedErrorMessages.contains(errorMessage)) { @@ -311,16 +312,16 @@ public void testDeleteModel_UseSettingToSkipBlockedByIngestPipeline() throws IOE when(clusterService.getClusterSettings()).thenReturn(clusterSettings); when(clusterService.getSettings()).thenReturn(settings); deleteModelTransportAction = spy( - new DeleteModelTransportAction( - transportService, - actionFilters, - client, - settings, - xContentRegistry, - clusterService, - modelAccessControlHelper, - agentModelsSearcher - ) + new DeleteModelTransportAction( + transportService, + actionFilters, + client, + settings, + xContentRegistry, + clusterService, + modelAccessControlHelper, + agentModelsSearcher + ) ); threadContext = new ThreadContext(settings); @@ -334,12 +335,10 @@ public void testDeleteModel_UseSettingToSkipBlockedByIngestPipeline() throws IOE return null; }).when(modelAccessControlHelper).validateModelGroupAccess(any(), any(), any(), any()); - - Map ingestPipelineConfig1 = Map.of("model_id", "test_id"); Map ingestPipelineConfig2 = Map.of("nothing", "test_id"); when(getIngestionPipelineResponse.toString()) - .thenReturn(StringUtils.toJson(Map.of("ingest_1", ingestPipelineConfig1, "ingest_2", ingestPipelineConfig2))); + .thenReturn(StringUtils.toJson(Map.of("ingest_1", ingestPipelineConfig1, "ingest_2", ingestPipelineConfig2))); // when(getIngestionPipelineResponse.pipelines()) // .thenReturn(List.of(ingestPipelineConfiguration, independentIngestPipelineConfiguration)); doAnswer(invocation -> {