Introduce checkstyle plugin

- Based on https://github.com/spring-io/spring-javaformat
- In this iteration, checkstyles are only enabled for spring-ai-core
This commit is contained in:
Soby Chacko
2024-10-24 10:39:48 -04:00
committed by Mark Pollack
parent 33a72417e1
commit 8e758dbd00
1412 changed files with 26997 additions and 21963 deletions

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +16,14 @@
package org.springframework.ai.bindings;
import java.net.URI;
import java.util.Map;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor;
import org.springframework.core.env.Environment;
import java.net.URI;
import java.util.Map;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s
* of type: {@value TYPE}.

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,13 +16,13 @@
package org.springframework.ai.bindings;
import java.util.Map;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor;
import org.springframework.core.env.Environment;
import java.util.Map;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s
* of type: {@value TYPE}.

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,13 +16,13 @@
package org.springframework.ai.bindings;
import java.util.Map;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor;
import org.springframework.core.env.Environment;
import java.util.Map;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s
* of type: {@value TYPE}.

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,13 +16,13 @@
package org.springframework.ai.bindings;
import java.util.Map;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor;
import org.springframework.core.env.Environment;
import java.util.Map;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s
* of type: {@value TYPE}.

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +16,14 @@
package org.springframework.ai.bindings;
import java.util.Arrays;
import java.util.Map;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor;
import org.springframework.core.env.Environment;
import java.util.Arrays;
import java.util.Map;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s
* of type: {@value TYPE}.

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +16,14 @@
package org.springframework.ai.bindings;
import java.net.URI;
import java.util.Map;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor;
import org.springframework.core.env.Environment;
import java.net.URI;
import java.util.Map;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s
* of type: {@value TYPE}.

View File

@@ -1,3 +1,19 @@
#
# Copyright 2023-2024 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Binding Properties Factories
org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor=\
org.springframework.ai.bindings.ChromaBindingsPropertiesProcessor,\

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,15 +16,16 @@
package org.springframework.ai.bindings;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.ai.bindings.BindingsValidator.CONFIG_PATH;
@@ -51,19 +52,19 @@ class ChromaBindingsPropertiesProcessorTests {
@Test
void propertiesAreContributed() {
new ChromaBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).containsEntry("spring.ai.vectorstore.chroma.client.host", "https://example.net");
assertThat(properties).containsEntry("spring.ai.vectorstore.chroma.client.port", "8000");
assertThat(properties).containsEntry("spring.ai.vectorstore.chroma.client.username", "itsme");
assertThat(properties).containsEntry("spring.ai.vectorstore.chroma.client.password", "youknowit");
new ChromaBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).containsEntry("spring.ai.vectorstore.chroma.client.host", "https://example.net");
assertThat(this.properties).containsEntry("spring.ai.vectorstore.chroma.client.port", "8000");
assertThat(this.properties).containsEntry("spring.ai.vectorstore.chroma.client.username", "itsme");
assertThat(this.properties).containsEntry("spring.ai.vectorstore.chroma.client.password", "youknowit");
}
@Test
void whenDisabledThenPropertiesAreNotContributed() {
environment.setProperty("%s.chroma.enabled".formatted(CONFIG_PATH), "false");
this.environment.setProperty("%s.chroma.enabled".formatted(CONFIG_PATH), "false");
new ChromaBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
new ChromaBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).isEmpty();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,15 +16,16 @@
package org.springframework.ai.bindings;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.ai.bindings.BindingsValidator.CONFIG_PATH;
@@ -50,17 +51,17 @@ class MistralAiBindingsPropertiesProcessorTests {
@Test
void propertiesAreContributed() {
new MistralAiBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).containsEntry("spring.ai.mistralai.api-key", "demo");
assertThat(properties).containsEntry("spring.ai.mistralai.base-url", "https://my.mistralai.example.net");
new MistralAiBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).containsEntry("spring.ai.mistralai.api-key", "demo");
assertThat(this.properties).containsEntry("spring.ai.mistralai.base-url", "https://my.mistralai.example.net");
}
@Test
void whenDisabledThenPropertiesAreNotContributed() {
environment.setProperty("%s.mistralai.enabled".formatted(CONFIG_PATH), "false");
this.environment.setProperty("%s.mistralai.enabled".formatted(CONFIG_PATH), "false");
new MistralAiBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
new MistralAiBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).isEmpty();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,15 +16,16 @@
package org.springframework.ai.bindings;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.ai.bindings.BindingsValidator.CONFIG_PATH;
@@ -49,16 +50,16 @@ class OllamaBindingsPropertiesProcessorTests {
@Test
void propertiesAreContributed() {
new OllamaBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).containsEntry("spring.ai.ollama.base-url", "https://example.net/ollama:11434");
new OllamaBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).containsEntry("spring.ai.ollama.base-url", "https://example.net/ollama:11434");
}
@Test
void whenDisabledThenPropertiesAreNotContributed() {
environment.setProperty("%s.ollama.enabled".formatted(CONFIG_PATH), "false");
this.environment.setProperty("%s.ollama.enabled".formatted(CONFIG_PATH), "false");
new OllamaBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
new OllamaBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).isEmpty();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,15 +16,16 @@
package org.springframework.ai.bindings;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.ai.bindings.BindingsValidator.CONFIG_PATH;
@@ -50,17 +51,17 @@ class OpenAiBindingsPropertiesProcessorTests {
@Test
void propertiesAreContributed() {
new OpenAiBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).containsEntry("spring.ai.openai.api-key", "demo");
assertThat(properties).containsEntry("spring.ai.openai.base-url", "https://my.openai.example.net");
new OpenAiBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).containsEntry("spring.ai.openai.api-key", "demo");
assertThat(this.properties).containsEntry("spring.ai.openai.base-url", "https://my.openai.example.net");
}
@Test
void whenDisabledThenPropertiesAreNotContributed() {
environment.setProperty("%s.openai.enabled".formatted(CONFIG_PATH), "false");
this.environment.setProperty("%s.openai.enabled".formatted(CONFIG_PATH), "false");
new OpenAiBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
new OpenAiBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).isEmpty();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,15 +16,16 @@
package org.springframework.ai.bindings;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.ai.bindings.BindingsValidator.CONFIG_PATH;
@@ -69,27 +70,29 @@ class TanzuBindingsPropertiesProcessorTests {
@Test
void propertiesAreContributed() {
new TanzuBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).containsEntry("spring.ai.openai.chat.api-key", "demo");
assertThat(properties).containsEntry("spring.ai.openai.chat.base-url", "https://my.openai.example.net");
assertThat(properties).containsEntry("spring.ai.openai.chat.options.model", "llava1.6");
assertThat(properties).containsEntry("spring.ai.openai.embedding.api-key", "demo2");
assertThat(properties).containsEntry("spring.ai.openai.embedding.base-url", "https://my.openai2.example.net");
assertThat(properties).containsEntry("spring.ai.openai.embedding.options.model", "text-embed-large");
new TanzuBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).containsEntry("spring.ai.openai.chat.api-key", "demo");
assertThat(this.properties).containsEntry("spring.ai.openai.chat.base-url", "https://my.openai.example.net");
assertThat(this.properties).containsEntry("spring.ai.openai.chat.options.model", "llava1.6");
assertThat(this.properties).containsEntry("spring.ai.openai.embedding.api-key", "demo2");
assertThat(this.properties).containsEntry("spring.ai.openai.embedding.base-url",
"https://my.openai2.example.net");
assertThat(this.properties).containsEntry("spring.ai.openai.embedding.options.model", "text-embed-large");
}
@Test
void propertiesAreMissingModelCapabilities() {
new TanzuBindingsPropertiesProcessor().process(environment, bindingsMissingModelCapabilities, properties);
assertThat(properties).isEmpty();
new TanzuBindingsPropertiesProcessor().process(this.environment, this.bindingsMissingModelCapabilities,
this.properties);
assertThat(this.properties).isEmpty();
}
@Test
void whenDisabledThenPropertiesAreNotContributed() {
environment.setProperty("%s.genai.enabled".formatted(CONFIG_PATH), "false");
this.environment.setProperty("%s.genai.enabled".formatted(CONFIG_PATH), "false");
new TanzuBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
new TanzuBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).isEmpty();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,15 +16,16 @@
package org.springframework.ai.bindings;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.ai.bindings.BindingsValidator.CONFIG_PATH;
@@ -50,18 +51,18 @@ class WeaviateBindingsPropertiesProcessorTests {
@Test
void propertiesAreContributed() {
new WeaviateBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).containsEntry("spring.ai.vectorstore.weaviate.scheme", "https");
assertThat(properties).containsEntry("spring.ai.vectorstore.weaviate.host", "example.net:8000");
assertThat(properties).containsEntry("spring.ai.vectorstore.weaviate.api-key", "demo");
new WeaviateBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).containsEntry("spring.ai.vectorstore.weaviate.scheme", "https");
assertThat(this.properties).containsEntry("spring.ai.vectorstore.weaviate.host", "example.net:8000");
assertThat(this.properties).containsEntry("spring.ai.vectorstore.weaviate.api-key", "demo");
}
@Test
void whenDisabledThenPropertiesAreNotContributed() {
environment.setProperty("%s.weaviate.enabled".formatted(CONFIG_PATH), "false");
this.environment.setProperty("%s.weaviate.enabled".formatted(CONFIG_PATH), "false");
new WeaviateBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
new WeaviateBindingsPropertiesProcessor().process(this.environment, this.bindings, this.properties);
assertThat(this.properties).isEmpty();
}
}