Skip to content

Commit 962ef9f

Browse files
committed
Updates for checkstyle
1 parent 6f49655 commit 962ef9f

File tree

15 files changed

+48
-28
lines changed

15 files changed

+48
-28
lines changed

spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/ScmStubDownloaderBuilder.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Arrays;
3232
import java.util.Collections;
3333
import java.util.List;
34+
import java.util.Locale;
3435
import java.util.Map;
3536
import java.util.Objects;
3637
import java.util.concurrent.ConcurrentHashMap;
@@ -295,8 +296,9 @@ class FileWalker extends SimpleFileVisitor<Path> {
295296
Path foundFile;
296297

297298
FileWalker(StubConfiguration stubConfiguration) {
298-
this.latestSnapshotVersion = LATEST.stream().anyMatch(s -> s.equals(stubConfiguration.version.toLowerCase()));
299-
this.latestReleaseVersion = RELEASE.equals(stubConfiguration.version.toLowerCase());
299+
this.latestSnapshotVersion = LATEST.stream()
300+
.anyMatch(s -> s.equals(stubConfiguration.version.toLowerCase(Locale.ROOT)));
301+
this.latestReleaseVersion = RELEASE.equals(stubConfiguration.version.toLowerCase(Locale.ROOT));
300302
this.matcherWithDot = FileSystems.getDefault().getPathMatcher("glob:" + matcherGlob(stubConfiguration, "."));
301303
this.matcherWithoutDot = FileSystems.getDefault().getPathMatcher("glob:" + matcherGlob(stubConfiguration, "/"));
302304
}
@@ -368,12 +370,12 @@ private DefaultArtifactVersionWrapper replaceWithSnapshotIfSameVersions(
368370
private File folderWithPredefinedName(File[] files) {
369371
if (this.latestSnapshotVersion) {
370372
return Arrays.stream(files)
371-
.filter(file -> LATEST.stream().anyMatch(s -> s.equals(file.getName().toLowerCase())))
373+
.filter(file -> LATEST.stream().anyMatch(s -> s.equals(file.getName().toLowerCase(Locale.ROOT))))
372374
.findFirst()
373375
.orElse(null);
374376
}
375377
return Arrays.stream(files)
376-
.filter(file -> RELEASE.equals(file.getName().toLowerCase()))
378+
.filter(file -> RELEASE.equals(file.getName().toLowerCase(Locale.ROOT)))
377379
.findFirst()
378380
.orElse(null);
379381
}

spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.contract.stubrunner;
1818

19+
import java.util.Locale;
20+
1921
import org.springframework.util.StringUtils;
2022

2123
/**
@@ -128,7 +130,7 @@ public boolean groupIdAndArtifactMatches(String ivyNotationAsString) {
128130
* @return {@code true} for a snapshot or a LATEST (+) version.
129131
*/
130132
public boolean isVersionChanging() {
131-
return DEFAULT_VERSION.equals(this.version) || this.version.toLowerCase().contains("snapshot");
133+
return DEFAULT_VERSION.equals(this.version) || this.version.toLowerCase(Locale.ROOT).contains("snapshot");
132134
}
133135

134136
public String getGroupId() {

spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubRunnerOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.util.Collection;
2222
import java.util.HashMap;
23+
import java.util.Locale;
2324
import java.util.Map;
2425
import java.util.Properties;
2526
import java.util.Set;
@@ -213,7 +214,7 @@ private static Map<String, String> stubRunnerProps() {
213214
Set<String> propertyNames = properties.stringPropertyNames();
214215
propertyNames.stream()
215216
// stubrunner.properties.foo.bar=baz
216-
.filter(s -> s.toLowerCase().startsWith("stubrunner.properties"))
217+
.filter(s -> s.toLowerCase(Locale.ROOT).startsWith("stubrunner.properties"))
217218
// foo.bar=baz
218219
.forEach(s -> map.put(s.substring("stubrunner.properties".length() + 1), System.getProperty(s)));
219220
return map;

spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubRunnerPropertyUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.cloud.contract.stubrunner;
1818

1919
import java.util.HashMap;
20+
import java.util.Locale;
2021
import java.util.Map;
2122

2223
import org.apache.commons.logging.Log;
@@ -81,7 +82,7 @@ public static String getProperty(Map<String, String> options, String propName) {
8182
}
8283

8384
private static String appendPrefixIfNecessary(String prop) {
84-
if (prop.toLowerCase().startsWith("stubrunner")) {
85+
if (prop.toLowerCase(Locale.ROOT).startsWith("stubrunner")) {
8586
return prop;
8687
}
8788
return STUBRUNNER_PROPERTIES + "." + prop;
@@ -95,7 +96,7 @@ private static String doGetProp(String stubRunnerProp) {
9596
}
9697
return systemProp;
9798
}
98-
String convertedEnvProp = stubRunnerProp.replaceAll("\\.", "_").replaceAll("-", "_").toUpperCase();
99+
String convertedEnvProp = stubRunnerProp.replaceAll("\\.", "_").replaceAll("-", "_").toUpperCase(Locale.ROOT);
99100
String envVar = FETCHER.envVar(convertedEnvProp);
100101
if (log.isTraceEnabled()) {
101102
log.trace("Environment variable [" + convertedEnvProp + "] has value [" + envVar + "]");

spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/ContractVerifierExtension.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Arrays;
2323
import java.util.HashMap;
2424
import java.util.List;
25+
import java.util.Locale;
2526
import java.util.Map;
2627

2728
import javax.inject.Inject;
@@ -269,7 +270,7 @@ public void setTestFramework(TestFramework testFramework) {
269270
}
270271

271272
public void setTestFramework(String testFramework) {
272-
this.testFramework.set(TestFramework.valueOf(testFramework.toUpperCase()));
273+
this.testFramework.set(TestFramework.valueOf(testFramework.toUpperCase(Locale.ROOT)));
273274
}
274275

275276
public Property<TestMode> getTestMode() {
@@ -281,7 +282,7 @@ public void setTestMode(TestMode testMode) {
281282
}
282283

283284
public void setTestMode(String testMode) {
284-
this.testMode.set(TestMode.valueOf(testMode.toUpperCase()));
285+
this.testMode.set(TestMode.valueOf(testMode.toUpperCase(Locale.ROOT)));
285286
}
286287

287288
public Property<String> getBasePackageForTests() {
@@ -469,7 +470,7 @@ public void setContractsMode(StubRunnerProperties.StubsMode contractsMode) {
469470
}
470471

471472
public void setContractsMode(String contractsMode) {
472-
this.contractsMode.set(StubRunnerProperties.StubsMode.valueOf(contractsMode.toUpperCase()));
473+
this.contractsMode.set(StubRunnerProperties.StubsMode.valueOf(contractsMode.toUpperCase(Locale.ROOT)));
473474
}
474475

475476
public Property<String> getPackageWithBaseClasses() {

spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/BodyReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.file.Path;
2424
import java.util.Collections;
2525
import java.util.List;
26+
import java.util.Locale;
2627
import java.util.Map;
2728

2829
import org.apache.commons.logging.Log;
@@ -71,7 +72,7 @@ void storeContractAsYaml(SingleContractMetadata metadata) {
7172
private String byteBodyToAFileForTestMethod(SingleContractMetadata metadata, FromFileProperty property,
7273
CommunicationType side) {
7374
GeneratedClassDataForMethod classDataForMethod = classDataForMethod(metadata);
74-
String newFileName = classDataForMethod.getMethodName() + "_" + side.name().toLowerCase() + "_"
75+
String newFileName = classDataForMethod.getMethodName() + "_" + side.name().toLowerCase(Locale.ROOT) + "_"
7576
+ property.fileName();
7677
writeFileForBothIdeAndBuildTool(metadata, property.asBytes(), newFileName);
7778
return newFileName;

spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeMethodWithUrlGiven.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.contract.verifier.builder;
1818

19+
import java.util.Locale;
20+
1921
import org.springframework.cloud.contract.spec.internal.ExecutionProperty;
2022
import org.springframework.cloud.contract.spec.internal.Request;
2123
import org.springframework.cloud.contract.spec.internal.Url;
@@ -51,7 +53,7 @@ private Url getUrl(Request request) {
5153

5254
private void addUrl(Url buildUrl, Request request) {
5355
Object testSideUrl = MapConverter.getTestSideValues(buildUrl);
54-
String method = request.getMethod().getServerValue().toString().toLowerCase();
56+
String method = request.getMethod().getServerValue().toString().toLowerCase(Locale.ROOT);
5557
String url = testSideUrl.toString();
5658
if (!(testSideUrl instanceof ExecutionProperty)) {
5759
url = this.bodyParser.quotedShortText(testSideUrl.toString());

spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/JaxRsRequestMethodWhen.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.contract.verifier.builder;
1818

19+
import java.util.Locale;
20+
1921
import org.springframework.cloud.contract.spec.internal.ExecutionProperty;
2022
import org.springframework.cloud.contract.spec.internal.FromFileProperty;
2123
import org.springframework.cloud.contract.spec.internal.Request;
@@ -43,7 +45,7 @@ public MethodVisitor<When> apply(SingleContractMetadata metadata) {
4345
void appendMethodAndBody(SingleContractMetadata metadata) {
4446
Request request = metadata.getContract().getRequest();
4547
ContentType type = metadata.getInputTestContentType();
46-
String method = request.getMethod().getServerValue().toString().toLowerCase();
48+
String method = request.getMethod().getServerValue().toString().toLowerCase(Locale.ROOT);
4749
if (request.getBody() != null) {
4850
String contentType = StringUtils.hasText(metadata.getDefinedInputTestContentType())
4951
? metadata.getDefinedInputTestContentType() : type.getMimeType();
@@ -61,11 +63,11 @@ else if (body instanceof FromFileProperty) {
6163
else {
6264
value = "\"" + requestBodyAsString(metadata) + "\"";
6365
}
64-
this.blockBuilder.addIndented(
65-
".build(\"" + method.toUpperCase() + "\", entity(" + value + ", \"" + contentType + "\"))");
66+
this.blockBuilder.addIndented(".build(\"" + method.toUpperCase(Locale.ROOT) + "\", entity(" + value + ", \""
67+
+ contentType + "\"))");
6668
}
6769
else {
68-
this.blockBuilder.addIndented(".build(\"" + method.toUpperCase() + "\")");
70+
this.blockBuilder.addIndented(".build(\"" + method.toUpperCase(Locale.ROOT) + "\")");
6971
}
7072
}
7173

spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MockMvcUrlWhen.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.contract.verifier.builder;
1818

19+
import java.util.Locale;
20+
1921
import org.springframework.cloud.contract.spec.internal.ExecutionProperty;
2022
import org.springframework.cloud.contract.spec.internal.Request;
2123
import org.springframework.cloud.contract.spec.internal.Url;
@@ -53,7 +55,7 @@ private Url getUrl(Request request) {
5355

5456
private void addUrl(Url buildUrl, Request request) {
5557
Object testSideUrl = MapConverter.getTestSideValues(buildUrl);
56-
String method = request.getMethod().getServerValue().toString().toLowerCase();
58+
String method = request.getMethod().getServerValue().toString().toLowerCase(Locale.ROOT);
5759
String url = testSideUrl.toString();
5860
if (!(testSideUrl instanceof ExecutionProperty)) {
5961
url = this.bodyParser.quotedShortText(testSideUrl.toString());

spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/converter/YamlContract.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.HashMap;
2222
import java.util.LinkedHashMap;
2323
import java.util.List;
24+
import java.util.Locale;
2425
import java.util.Map;
2526
import java.util.Objects;
2627

@@ -273,7 +274,7 @@ static MatchingType from(String string) {
273274
return Arrays.stream(values())
274275
.filter(matchingType -> matchingType.name()
275276
.replace("_", "")
276-
.equalsIgnoreCase(string.toLowerCase().replace("_", "")))
277+
.equalsIgnoreCase(string.toLowerCase(Locale.ROOT).replace("_", "")))
277278
.findFirst()
278279
.orElse(null);
279280
}

0 commit comments

Comments
 (0)