Skip to content

Commit fbfd620

Browse files
sobychackoWillam2004
authored andcommitted
Checkstyle fixes
Enabling checkstyle by default in the build Signed-off-by: Soby Chacko <[email protected]> Signed-off-by: 家娃 <[email protected]>
1 parent d279679 commit fbfd620

File tree

190 files changed

+1611
-1446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+1611
-1446
lines changed

advisors/spring-ai-advisors-vector-store/src/test/java/org/springframework/ai/chat/client/advisor/vectorstore/VectorStoreChatMemoryAdvisorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
import org.junit.jupiter.api.Test;
2020
import org.mockito.Mockito;
21+
import reactor.core.scheduler.Scheduler;
2122

2223
import org.springframework.ai.chat.prompt.PromptTemplate;
2324
import org.springframework.ai.vectorstore.VectorStore;
24-
import reactor.core.scheduler.Scheduler;
2525

2626
import static org.assertj.core.api.Assertions.assertThat;
2727
import static org.assertj.core.api.Assertions.assertThatThrownBy;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-common/src/test/java/org/springframework/ai/mcp/client/common/autoconfigure/McpClientAutoConfigurationIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import io.modelcontextprotocol.client.McpSyncClient;
2626
import io.modelcontextprotocol.spec.McpClientTransport;
2727
import io.modelcontextprotocol.spec.McpSchema;
28-
import org.junit.jupiter.api.Disabled;
2928
import org.junit.jupiter.api.Test;
3029
import org.mockito.Mockito;
3130
import reactor.core.publisher.Mono;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-common/src/test/java/org/springframework/ai/mcp/client/common/autoconfigure/McpClientAutoConfigurationRuntimeHintsTests.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
import java.util.HashSet;
2121
import java.util.Set;
2222

23-
import org.junit.jupiter.api.Test;
2423
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
2525

2626
import org.springframework.ai.mcp.client.common.autoconfigure.aot.McpClientAutoConfigurationRuntimeHints;
2727
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpStdioClientProperties;
28+
import org.springframework.aot.hint.MemberCategory;
2829
import org.springframework.aot.hint.RuntimeHints;
2930
import org.springframework.aot.hint.TypeReference;
30-
import org.springframework.aot.hint.MemberCategory;
3131
import org.springframework.core.io.Resource;
3232
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
3333

@@ -49,16 +49,16 @@ public class McpClientAutoConfigurationRuntimeHintsTests {
4949

5050
@BeforeEach
5151
void setUp() {
52-
runtimeHints = new RuntimeHints();
53-
mcpRuntimeHints = new McpClientAutoConfigurationRuntimeHints();
52+
this.runtimeHints = new RuntimeHints();
53+
this.mcpRuntimeHints = new McpClientAutoConfigurationRuntimeHints();
5454
}
5555

5656
@Test
5757
void registerHints() throws IOException {
5858

59-
mcpRuntimeHints.registerHints(runtimeHints, null);
59+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
6060

61-
boolean hasJsonPattern = runtimeHints.resources()
61+
boolean hasJsonPattern = this.runtimeHints.resources()
6262
.resourcePatternHints()
6363
.anyMatch(resourceHints -> resourceHints.getIncludes()
6464
.stream()
@@ -96,7 +96,7 @@ else if (path.endsWith("/nested/nested-config.json")) {
9696
Set<TypeReference> jsonAnnotatedClasses = findJsonAnnotatedClassesInPackage(MCP_CLIENT_PACKAGE);
9797

9898
Set<TypeReference> registeredTypes = new HashSet<>();
99-
runtimeHints.reflection().typeHints().forEach(typeHint -> registeredTypes.add(typeHint.getType()));
99+
this.runtimeHints.reflection().typeHints().forEach(typeHint -> registeredTypes.add(typeHint.getType()));
100100

101101
for (TypeReference jsonAnnotatedClass : jsonAnnotatedClasses) {
102102
assertThat(registeredTypes.contains(jsonAnnotatedClass))
@@ -112,9 +112,9 @@ else if (path.endsWith("/nested/nested-config.json")) {
112112
@Test
113113
void registerHintsWithNullClassLoader() {
114114
// Test that registering hints with null ClassLoader works correctly
115-
mcpRuntimeHints.registerHints(runtimeHints, null);
115+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
116116

117-
boolean hasJsonPattern = runtimeHints.resources()
117+
boolean hasJsonPattern = this.runtimeHints.resources()
118118
.resourcePatternHints()
119119
.anyMatch(resourceHints -> resourceHints.getIncludes()
120120
.stream()
@@ -126,12 +126,12 @@ void registerHintsWithNullClassLoader() {
126126

127127
@Test
128128
void allMemberCategoriesAreRegistered() {
129-
mcpRuntimeHints.registerHints(runtimeHints, null);
129+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
130130

131131
Set<TypeReference> jsonAnnotatedClasses = findJsonAnnotatedClassesInPackage(MCP_CLIENT_PACKAGE);
132132

133133
// Verify that all MemberCategory values are registered for each type
134-
runtimeHints.reflection().typeHints().forEach(typeHint -> {
134+
this.runtimeHints.reflection().typeHints().forEach(typeHint -> {
135135
if (jsonAnnotatedClasses.contains(typeHint.getType())) {
136136
Set<MemberCategory> expectedCategories = Set.of(MemberCategory.values());
137137
Set<MemberCategory> actualCategories = typeHint.getMemberCategories();
@@ -142,10 +142,10 @@ void allMemberCategoriesAreRegistered() {
142142

143143
@Test
144144
void verifySpecificMcpClientClasses() {
145-
mcpRuntimeHints.registerHints(runtimeHints, null);
145+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
146146

147147
Set<TypeReference> registeredTypes = new HashSet<>();
148-
runtimeHints.reflection().typeHints().forEach(typeHint -> registeredTypes.add(typeHint.getType()));
148+
this.runtimeHints.reflection().typeHints().forEach(typeHint -> registeredTypes.add(typeHint.getType()));
149149

150150
// Verify specific MCP client classes are registered
151151
assertThat(registeredTypes.contains(TypeReference.of(McpStdioClientProperties.Parameters.class)))
@@ -156,16 +156,16 @@ void verifySpecificMcpClientClasses() {
156156
@Test
157157
void multipleRegistrationCallsAreIdempotent() {
158158
// Register hints multiple times and verify no duplicates
159-
mcpRuntimeHints.registerHints(runtimeHints, null);
160-
int firstRegistrationCount = (int) runtimeHints.reflection().typeHints().count();
159+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
160+
int firstRegistrationCount = (int) this.runtimeHints.reflection().typeHints().count();
161161

162-
mcpRuntimeHints.registerHints(runtimeHints, null);
163-
int secondRegistrationCount = (int) runtimeHints.reflection().typeHints().count();
162+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
163+
int secondRegistrationCount = (int) this.runtimeHints.reflection().typeHints().count();
164164

165165
assertThat(firstRegistrationCount).isEqualTo(secondRegistrationCount);
166166

167167
// Verify resource pattern registration is also idempotent
168-
boolean hasJsonPattern = runtimeHints.resources()
168+
boolean hasJsonPattern = this.runtimeHints.resources()
169169
.resourcePatternHints()
170170
.anyMatch(resourceHints -> resourceHints.getIncludes()
171171
.stream()
@@ -176,10 +176,10 @@ void multipleRegistrationCallsAreIdempotent() {
176176

177177
@Test
178178
void verifyJsonResourcePatternIsRegistered() {
179-
mcpRuntimeHints.registerHints(runtimeHints, null);
179+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
180180

181181
// Verify the specific JSON resource pattern is registered
182-
boolean hasJsonPattern = runtimeHints.resources()
182+
boolean hasJsonPattern = this.runtimeHints.resources()
183183
.resourcePatternHints()
184184
.anyMatch(resourceHints -> resourceHints.getIncludes()
185185
.stream()
@@ -190,10 +190,10 @@ void verifyJsonResourcePatternIsRegistered() {
190190

191191
@Test
192192
void verifyNestedClassesAreRegistered() {
193-
mcpRuntimeHints.registerHints(runtimeHints, null);
193+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
194194

195195
Set<TypeReference> registeredTypes = new HashSet<>();
196-
runtimeHints.reflection().typeHints().forEach(typeHint -> registeredTypes.add(typeHint.getType()));
196+
this.runtimeHints.reflection().typeHints().forEach(typeHint -> registeredTypes.add(typeHint.getType()));
197197

198198
// Verify nested classes are properly registered
199199
assertThat(registeredTypes.contains(TypeReference.of(McpStdioClientProperties.Parameters.class)))
@@ -203,10 +203,10 @@ void verifyNestedClassesAreRegistered() {
203203

204204
@Test
205205
void verifyResourcePatternHintsArePresentAfterRegistration() {
206-
mcpRuntimeHints.registerHints(runtimeHints, null);
206+
this.mcpRuntimeHints.registerHints(this.runtimeHints, null);
207207

208208
// Verify that resource pattern hints are present
209-
long patternCount = runtimeHints.resources().resourcePatternHints().count();
209+
long patternCount = this.runtimeHints.resources().resourcePatternHints().count();
210210
assertThat(patternCount).isGreaterThan(0);
211211
}
212212

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-httpclient/src/main/java/org/springframework/ai/mcp/client/httpclient/autoconfigure/StreamableHttpHttpClientTransportAutoConfiguration.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24+
import com.fasterxml.jackson.databind.ObjectMapper;
25+
import io.modelcontextprotocol.client.McpSyncClient;
26+
import io.modelcontextprotocol.client.transport.AsyncHttpRequestCustomizer;
27+
import io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport;
28+
import io.modelcontextprotocol.client.transport.SyncHttpRequestCustomizer;
29+
import io.modelcontextprotocol.spec.McpSchema;
30+
2431
import org.springframework.ai.mcp.client.common.autoconfigure.NamedClientMcpTransport;
2532
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpClientCommonProperties;
2633
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpStreamableHttpClientProperties;
@@ -33,14 +40,6 @@
3340
import org.springframework.context.annotation.Bean;
3441
import org.springframework.core.log.LogAccessor;
3542

36-
import com.fasterxml.jackson.databind.ObjectMapper;
37-
38-
import io.modelcontextprotocol.client.McpSyncClient;
39-
import io.modelcontextprotocol.client.transport.AsyncHttpRequestCustomizer;
40-
import io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport;
41-
import io.modelcontextprotocol.client.transport.SyncHttpRequestCustomizer;
42-
import io.modelcontextprotocol.spec.McpSchema;
43-
4443
/**
4544
* Auto-configuration for Streamable HTTP client transport in the Model Context Protocol
4645
* (MCP).

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-httpclient/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfigurationIT.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
/*
2-
* Copyright 2024-2025 the original author or authors.
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
315
*/
416

517
package org.springframework.ai.mcp.client.autoconfigure;
618

7-
import static org.assertj.core.api.Assertions.assertThat;
8-
import static org.mockito.ArgumentMatchers.any;
9-
import static org.mockito.Mockito.atLeastOnce;
10-
import static org.mockito.Mockito.mock;
11-
import static org.mockito.Mockito.verify;
12-
import static org.mockito.Mockito.verifyNoInteractions;
13-
import static org.mockito.Mockito.when;
14-
1519
import java.util.List;
1620

21+
import io.modelcontextprotocol.client.McpSyncClient;
22+
import io.modelcontextprotocol.client.transport.AsyncHttpRequestCustomizer;
23+
import io.modelcontextprotocol.client.transport.SyncHttpRequestCustomizer;
24+
import io.modelcontextprotocol.spec.McpSchema.ListToolsResult;
1725
import org.junit.jupiter.api.AfterAll;
1826
import org.junit.jupiter.api.BeforeAll;
1927
import org.junit.jupiter.api.Test;
2028
import org.junit.jupiter.api.Timeout;
2129
import org.slf4j.Logger;
2230
import org.slf4j.LoggerFactory;
31+
import org.testcontainers.containers.GenericContainer;
32+
import org.testcontainers.containers.wait.strategy.Wait;
33+
import reactor.core.publisher.Mono;
34+
2335
import org.springframework.ai.mcp.client.common.autoconfigure.McpClientAutoConfiguration;
2436
import org.springframework.ai.mcp.client.httpclient.autoconfigure.SseHttpClientTransportAutoConfiguration;
2537
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -28,14 +40,13 @@
2840
import org.springframework.context.annotation.Bean;
2941
import org.springframework.context.annotation.Configuration;
3042

31-
import org.testcontainers.containers.GenericContainer;
32-
import org.testcontainers.containers.wait.strategy.Wait;
33-
34-
import io.modelcontextprotocol.client.McpSyncClient;
35-
import io.modelcontextprotocol.client.transport.AsyncHttpRequestCustomizer;
36-
import io.modelcontextprotocol.client.transport.SyncHttpRequestCustomizer;
37-
import io.modelcontextprotocol.spec.McpSchema.ListToolsResult;
38-
import reactor.core.publisher.Mono;
43+
import static org.assertj.core.api.Assertions.assertThat;
44+
import static org.mockito.ArgumentMatchers.any;
45+
import static org.mockito.Mockito.atLeastOnce;
46+
import static org.mockito.Mockito.mock;
47+
import static org.mockito.Mockito.verify;
48+
import static org.mockito.Mockito.verifyNoInteractions;
49+
import static org.mockito.Mockito.when;
3950

4051
@Timeout(15)
4152
public class SseHttpClientTransportAutoConfigurationIT {

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-httpclient/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfigurationTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616

1717
package org.springframework.ai.mcp.client.autoconfigure;
1818

19-
import static org.assertj.core.api.Assertions.assertThat;
20-
2119
import java.lang.reflect.Field;
2220
import java.util.List;
2321

22+
import com.fasterxml.jackson.databind.ObjectMapper;
23+
import io.modelcontextprotocol.client.transport.HttpClientSseClientTransport;
2424
import org.junit.jupiter.api.Test;
25+
2526
import org.springframework.ai.mcp.client.common.autoconfigure.NamedClientMcpTransport;
2627
import org.springframework.ai.mcp.client.httpclient.autoconfigure.SseHttpClientTransportAutoConfiguration;
2728
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -30,9 +31,7 @@
3031
import org.springframework.context.annotation.Configuration;
3132
import org.springframework.util.ReflectionUtils;
3233

33-
import com.fasterxml.jackson.databind.ObjectMapper;
34-
35-
import io.modelcontextprotocol.client.transport.HttpClientSseClientTransport;
34+
import static org.assertj.core.api.Assertions.assertThat;
3635

3736
/**
3837
* Tests for {@link SseHttpClientTransportAutoConfiguration}.

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-httpclient/src/test/java/org/springframework/ai/mcp/client/autoconfigure/StreamableHttpHttpClientTransportAutoConfigurationIT.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
/*
2-
* Copyright 2024-2025 the original author or authors.
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
315
*/
416

517
package org.springframework.ai.mcp.client.autoconfigure;
618

7-
import static org.assertj.core.api.Assertions.assertThat;
8-
import static org.mockito.ArgumentMatchers.any;
9-
import static org.mockito.Mockito.atLeastOnce;
10-
import static org.mockito.Mockito.mock;
11-
import static org.mockito.Mockito.verify;
12-
import static org.mockito.Mockito.verifyNoInteractions;
13-
import static org.mockito.Mockito.when;
14-
1519
import java.util.List;
1620

21+
import io.modelcontextprotocol.client.McpSyncClient;
22+
import io.modelcontextprotocol.client.transport.AsyncHttpRequestCustomizer;
23+
import io.modelcontextprotocol.client.transport.SyncHttpRequestCustomizer;
24+
import io.modelcontextprotocol.spec.McpSchema.ListToolsResult;
1725
import org.junit.jupiter.api.AfterAll;
1826
import org.junit.jupiter.api.BeforeAll;
1927
import org.junit.jupiter.api.Test;
2028
import org.junit.jupiter.api.Timeout;
2129
import org.slf4j.Logger;
2230
import org.slf4j.LoggerFactory;
31+
import org.testcontainers.containers.GenericContainer;
32+
import org.testcontainers.containers.wait.strategy.Wait;
33+
import reactor.core.publisher.Mono;
34+
2335
import org.springframework.ai.mcp.client.common.autoconfigure.McpClientAutoConfiguration;
2436
import org.springframework.ai.mcp.client.httpclient.autoconfigure.StreamableHttpHttpClientTransportAutoConfiguration;
2537
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -28,14 +40,13 @@
2840
import org.springframework.context.annotation.Bean;
2941
import org.springframework.context.annotation.Configuration;
3042

31-
import org.testcontainers.containers.GenericContainer;
32-
import org.testcontainers.containers.wait.strategy.Wait;
33-
34-
import io.modelcontextprotocol.client.McpSyncClient;
35-
import io.modelcontextprotocol.client.transport.AsyncHttpRequestCustomizer;
36-
import io.modelcontextprotocol.client.transport.SyncHttpRequestCustomizer;
37-
import io.modelcontextprotocol.spec.McpSchema.ListToolsResult;
38-
import reactor.core.publisher.Mono;
43+
import static org.assertj.core.api.Assertions.assertThat;
44+
import static org.mockito.ArgumentMatchers.any;
45+
import static org.mockito.Mockito.atLeastOnce;
46+
import static org.mockito.Mockito.mock;
47+
import static org.mockito.Mockito.verify;
48+
import static org.mockito.Mockito.verifyNoInteractions;
49+
import static org.mockito.Mockito.when;
3950

4051
@Timeout(15)
4152
public class StreamableHttpHttpClientTransportAutoConfigurationIT {

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-webflux/src/main/java/org/springframework/ai/mcp/client/webflux/autoconfigure/StreamableHttpWebFluxTransportAutoConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23+
import com.fasterxml.jackson.databind.ObjectMapper;
24+
import io.modelcontextprotocol.client.transport.WebClientStreamableHttpTransport;
25+
2326
import org.springframework.ai.mcp.client.common.autoconfigure.NamedClientMcpTransport;
2427
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpClientCommonProperties;
2528
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpStreamableHttpClientProperties;
@@ -32,10 +35,6 @@
3235
import org.springframework.context.annotation.Bean;
3336
import org.springframework.web.reactive.function.client.WebClient;
3437

35-
import com.fasterxml.jackson.databind.ObjectMapper;
36-
37-
import io.modelcontextprotocol.client.transport.WebClientStreamableHttpTransport;
38-
3938
/**
4039
* Auto-configuration for WebFlux-based Streamable HTTP client transport in the Model
4140
* Context Protocol (MCP).

0 commit comments

Comments
 (0)