Skip to content

Commit

Permalink
apply spotless
Browse files Browse the repository at this point in the history
Signed-off-by: xinyual <[email protected]>
  • Loading branch information
xinyual committed Dec 19, 2024
1 parent d9e0925 commit c83bfac
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<GetSearchPipelineResponse> 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<GetPipelineResponse> listener = invocation.getArgument(2);
listener.onResponse(getIngestionPipelineResponse);
Expand All @@ -236,7 +231,13 @@ public void testDeleteModel_BlockedBySearchPipelineAndIngestionPipeline() throws
String totalErrorMessage = argumentCaptor.getValue().getMessage();
String[] separateErrorMessages = totalErrorMessage.split("\\. ");
Set<String> generateErrorMessages = new HashSet<>(List.of(separateErrorMessages));
Set<String> 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<String> 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)) {
Expand Down Expand Up @@ -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);
Expand All @@ -334,12 +335,10 @@ public void testDeleteModel_UseSettingToSkipBlockedByIngestPipeline() throws IOE
return null;
}).when(modelAccessControlHelper).validateModelGroupAccess(any(), any(), any(), any());



Map<String, Object> ingestPipelineConfig1 = Map.of("model_id", "test_id");
Map<String, Object> 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 -> {
Expand Down

0 comments on commit c83bfac

Please sign in to comment.