Skip to content

Commit f3aab2f

Browse files
ThomasVitaleilayaperumalg
authored andcommitted
fix: Fix wrong checkstyle automated changes
* Revert the checkstyle automatic changes to AiObservationMetricAttributes and DocumentMetadata enums. * Added tests for alphabetical sorting in SpringAiKind, AiOperationType, AiProvider. Fixed existing wrongly sorted values. Signed-off-by: Thomas Vitale <[email protected]>
1 parent 5e9e678 commit f3aab2f

File tree

9 files changed

+204
-34
lines changed

9 files changed

+204
-34
lines changed

spring-ai-commons/src/main/java/org/springframework/ai/document/DocumentMetadata.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,13 +32,14 @@ public enum DocumentMetadata {
3232
* The lower the distance, the more they are similar.
3333
* It's the opposite of the similarity score.
3434
*/
35-
DISTANCE();
35+
DISTANCE("distance");
3636

3737
private final String value;
3838

39-
DocumentMetadata() {
40-
this.value = "distance";
39+
DocumentMetadata(String value) {
40+
this.value = value;
4141
}
42+
4243
public String value() {
4344
return this.value;
4445
}

spring-ai-commons/src/main/java/org/springframework/ai/observation/conventions/AiObservationMetricAttributes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,12 +33,12 @@ public enum AiObservationMetricAttributes {
3333
/**
3434
* The type of token being counted (input, output, total).
3535
*/
36-
TOKEN_TYPE();
36+
TOKEN_TYPE("gen_ai.token.type");
3737

3838
private final String value;
3939

40-
AiObservationMetricAttributes() {
41-
this.value = "gen_ai.token.type";
40+
AiObservationMetricAttributes(String value) {
41+
this.value = value;
4242
}
4343

4444
/**

spring-ai-commons/src/main/java/org/springframework/ai/observation/conventions/AiOperationType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public enum AiOperationType {
3030

3131
// @formatter:off
3232

33-
// Please, keep the alphabetical sorting.
3433
/**
3534
* AI operation type for chat.
3635
*/

spring-ai-commons/src/main/java/org/springframework/ai/observation/conventions/AiProvider.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@ public enum AiProvider {
3030

3131
// @formatter:off
3232

33-
// Please, keep the alphabetical sorting.
3433
/**
3534
* AI system provided by Anthropic.
3635
*/
@@ -47,41 +46,44 @@ public enum AiProvider {
4746
BEDROCK_CONVERSE("bedrock_converse"),
4847

4948
/**
50-
* AI system provided by Mistral.
49+
* AI system provided by DeepSeek.
5150
*/
52-
MISTRAL_AI("mistral_ai"),
51+
DEEPSEEK("deepseek"),
5352

5453
/**
55-
* AI system provided by Oracle OCI.
54+
* AI system provided by Vertex AI.
5655
*/
57-
OCI_GENAI("oci_genai"),
56+
GOOGLE_GENAI_AI("google_genai"),
5857

5958
/**
60-
* AI system provided by Ollama.
59+
* AI system provided by Minimax.
6160
*/
62-
OLLAMA("ollama"),
61+
MINIMAX("minimax"),
6362

6463
/**
65-
* AI system provided by OpenAI.
64+
* AI system provided by Mistral.
6665
*/
67-
OPENAI("openai"),
66+
MISTRAL_AI("mistral_ai"),
6867

6968
/**
70-
* AI system provided by Minimax.
69+
* AI system provided by Oracle OCI.
7170
*/
72-
MINIMAX("minimax"),
73-
71+
OCI_GENAI("oci_genai"),
7472

73+
/**
74+
* AI system provided by Ollama.
75+
*/
76+
OLLAMA("ollama"),
7577

7678
/**
77-
* AI system provided by Zhipuai.
79+
* AI system provided by ONNX.
7880
*/
79-
ZHIPUAI("zhipuai"),
81+
ONNX("onnx"),
8082

8183
/**
82-
* AI system provided by DeepSeek.
84+
* AI system provided by OpenAI.
8385
*/
84-
DEEPSEEK("deepseek"),
86+
OPENAI("openai"),
8587

8688
/**
8789
* AI system provided by Spring AI.
@@ -94,14 +96,9 @@ public enum AiProvider {
9496
VERTEX_AI("vertex_ai"),
9597

9698
/**
97-
* AI system provided by Vertex AI.
98-
*/
99-
GOOGLE_GENAI_AI("google_genai"),
100-
101-
/**
102-
* AI system provided by ONNX.
99+
* AI system provided by Zhipuai.
103100
*/
104-
ONNX("onnx");
101+
ZHIPUAI("zhipuai");
105102

106103
private final String value;
107104

spring-ai-commons/src/main/java/org/springframework/ai/observation/conventions/SpringAiKind.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public enum SpringAiKind {
2626

2727
// @formatter:off
2828

29-
// Please, keep the alphabetical sorting.
3029
/**
3130
* Spring AI kind for advisor.
3231
*/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2023-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.
15+
*/
16+
17+
package org.springframework.ai.observation.conventions;
18+
19+
import java.util.Arrays;
20+
import java.util.List;
21+
import java.util.stream.Collectors;
22+
23+
import org.junit.jupiter.api.Test;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Unit tests for {@link AiOperationType}.
29+
*
30+
* @author Thomas Vitale
31+
*/
32+
class AiOperationTypeTests {
33+
34+
@Test
35+
void enumValuesShouldBeSortedAlphabetically() {
36+
List<String> actualNames = Arrays.stream(AiOperationType.values()).map(Enum::name).collect(Collectors.toList());
37+
38+
List<String> sortedNames = actualNames.stream().sorted().collect(Collectors.toList());
39+
40+
assertThat(actualNames).as("Enum values should be sorted alphabetically").isEqualTo(sortedNames);
41+
}
42+
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2023-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.
15+
*/
16+
17+
package org.springframework.ai.observation.conventions;
18+
19+
import java.util.Arrays;
20+
import java.util.List;
21+
import java.util.stream.Collectors;
22+
23+
import org.junit.jupiter.api.Test;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Unit tests for {@link AiProvider}.
29+
*
30+
* @author Thomas Vitale
31+
*/
32+
class AiProviderTests {
33+
34+
@Test
35+
void enumValuesShouldBeSortedAlphabetically() {
36+
List<String> actualNames = Arrays.stream(AiProvider.values()).map(Enum::name).collect(Collectors.toList());
37+
38+
List<String> sortedNames = actualNames.stream().sorted().collect(Collectors.toList());
39+
40+
assertThat(actualNames).as("Enum values should be sorted alphabetically").isEqualTo(sortedNames);
41+
}
42+
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2023-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.
15+
*/
16+
17+
package org.springframework.ai.observation.conventions;
18+
19+
import java.util.Arrays;
20+
import java.util.List;
21+
import java.util.stream.Collectors;
22+
23+
import org.junit.jupiter.api.Test;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Unit tests for {@link SpringAiKind}.
29+
*
30+
* @author Thomas Vitale
31+
*/
32+
class SpringAiKindTests {
33+
34+
@Test
35+
void enumValuesShouldBeSortedAlphabetically() {
36+
List<String> actualNames = Arrays.stream(SpringAiKind.values()).map(Enum::name).collect(Collectors.toList());
37+
38+
List<String> sortedNames = actualNames.stream().sorted().collect(Collectors.toList());
39+
40+
assertThat(actualNames).as("Enum values should be sorted alphabetically").isEqualTo(sortedNames);
41+
}
42+
43+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2023-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.
15+
*/
16+
17+
package org.springframework.ai.observation.conventions;
18+
19+
import java.util.Arrays;
20+
import java.util.List;
21+
import java.util.stream.Collectors;
22+
23+
import org.junit.jupiter.api.Test;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Unit tests for {@link VectorStoreProvider}.
29+
*
30+
* @author Thomas Vitale
31+
*/
32+
class VectorStoreProviderTests {
33+
34+
@Test
35+
void enumValuesShouldBeSortedAlphabetically() {
36+
List<String> actualNames = Arrays.stream(VectorStoreProvider.values())
37+
.map(Enum::name)
38+
.collect(Collectors.toList());
39+
40+
List<String> sortedNames = actualNames.stream().sorted().collect(Collectors.toList());
41+
42+
assertThat(actualNames).as("Enum values should be sorted alphabetically").isEqualTo(sortedNames);
43+
}
44+
45+
}

0 commit comments

Comments
 (0)