Updates for checkstyle
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.AbstractMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -295,8 +296,9 @@ class FileWalker extends SimpleFileVisitor<Path> {
|
||||
Path foundFile;
|
||||
|
||||
FileWalker(StubConfiguration stubConfiguration) {
|
||||
this.latestSnapshotVersion = LATEST.stream().anyMatch(s -> s.equals(stubConfiguration.version.toLowerCase()));
|
||||
this.latestReleaseVersion = RELEASE.equals(stubConfiguration.version.toLowerCase());
|
||||
this.latestSnapshotVersion = LATEST.stream()
|
||||
.anyMatch(s -> s.equals(stubConfiguration.version.toLowerCase(Locale.ROOT)));
|
||||
this.latestReleaseVersion = RELEASE.equals(stubConfiguration.version.toLowerCase(Locale.ROOT));
|
||||
this.matcherWithDot = FileSystems.getDefault().getPathMatcher("glob:" + matcherGlob(stubConfiguration, "."));
|
||||
this.matcherWithoutDot = FileSystems.getDefault().getPathMatcher("glob:" + matcherGlob(stubConfiguration, "/"));
|
||||
}
|
||||
@@ -368,12 +370,12 @@ class FileWalker extends SimpleFileVisitor<Path> {
|
||||
private File folderWithPredefinedName(File[] files) {
|
||||
if (this.latestSnapshotVersion) {
|
||||
return Arrays.stream(files)
|
||||
.filter(file -> LATEST.stream().anyMatch(s -> s.equals(file.getName().toLowerCase())))
|
||||
.filter(file -> LATEST.stream().anyMatch(s -> s.equals(file.getName().toLowerCase(Locale.ROOT))))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
return Arrays.stream(files)
|
||||
.filter(file -> RELEASE.equals(file.getName().toLowerCase()))
|
||||
.filter(file -> RELEASE.equals(file.getName().toLowerCase(Locale.ROOT)))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -128,7 +130,7 @@ public class StubConfiguration {
|
||||
* @return {@code true} for a snapshot or a LATEST (+) version.
|
||||
*/
|
||||
public boolean isVersionChanging() {
|
||||
return DEFAULT_VERSION.equals(this.version) || this.version.toLowerCase().contains("snapshot");
|
||||
return DEFAULT_VERSION.equals(this.version) || this.version.toLowerCase(Locale.ROOT).contains("snapshot");
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
@@ -213,7 +214,7 @@ public class StubRunnerOptions {
|
||||
Set<String> propertyNames = properties.stringPropertyNames();
|
||||
propertyNames.stream()
|
||||
// stubrunner.properties.foo.bar=baz
|
||||
.filter(s -> s.toLowerCase().startsWith("stubrunner.properties"))
|
||||
.filter(s -> s.toLowerCase(Locale.ROOT).startsWith("stubrunner.properties"))
|
||||
// foo.bar=baz
|
||||
.forEach(s -> map.put(s.substring("stubrunner.properties".length() + 1), System.getProperty(s)));
|
||||
return map;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.contract.stubrunner;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -81,7 +82,7 @@ public final class StubRunnerPropertyUtils {
|
||||
}
|
||||
|
||||
private static String appendPrefixIfNecessary(String prop) {
|
||||
if (prop.toLowerCase().startsWith("stubrunner")) {
|
||||
if (prop.toLowerCase(Locale.ROOT).startsWith("stubrunner")) {
|
||||
return prop;
|
||||
}
|
||||
return STUBRUNNER_PROPERTIES + "." + prop;
|
||||
@@ -95,7 +96,7 @@ public final class StubRunnerPropertyUtils {
|
||||
}
|
||||
return systemProp;
|
||||
}
|
||||
String convertedEnvProp = stubRunnerProp.replaceAll("\\.", "_").replaceAll("-", "_").toUpperCase();
|
||||
String convertedEnvProp = stubRunnerProp.replaceAll("\\.", "_").replaceAll("-", "_").toUpperCase(Locale.ROOT);
|
||||
String envVar = FETCHER.envVar(convertedEnvProp);
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Environment variable [" + convertedEnvProp + "] has value [" + envVar + "]");
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -269,7 +270,7 @@ public class ContractVerifierExtension implements Serializable {
|
||||
}
|
||||
|
||||
public void setTestFramework(String testFramework) {
|
||||
this.testFramework.set(TestFramework.valueOf(testFramework.toUpperCase()));
|
||||
this.testFramework.set(TestFramework.valueOf(testFramework.toUpperCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
public Property<TestMode> getTestMode() {
|
||||
@@ -281,7 +282,7 @@ public class ContractVerifierExtension implements Serializable {
|
||||
}
|
||||
|
||||
public void setTestMode(String testMode) {
|
||||
this.testMode.set(TestMode.valueOf(testMode.toUpperCase()));
|
||||
this.testMode.set(TestMode.valueOf(testMode.toUpperCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
public Property<String> getBasePackageForTests() {
|
||||
@@ -469,7 +470,7 @@ public class ContractVerifierExtension implements Serializable {
|
||||
}
|
||||
|
||||
public void setContractsMode(String contractsMode) {
|
||||
this.contractsMode.set(StubRunnerProperties.StubsMode.valueOf(contractsMode.toUpperCase()));
|
||||
this.contractsMode.set(StubRunnerProperties.StubsMode.valueOf(contractsMode.toUpperCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
public Property<String> getPackageWithBaseClasses() {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -71,7 +72,7 @@ class BodyReader {
|
||||
private String byteBodyToAFileForTestMethod(SingleContractMetadata metadata, FromFileProperty property,
|
||||
CommunicationType side) {
|
||||
GeneratedClassDataForMethod classDataForMethod = classDataForMethod(metadata);
|
||||
String newFileName = classDataForMethod.getMethodName() + "_" + side.name().toLowerCase() + "_"
|
||||
String newFileName = classDataForMethod.getMethodName() + "_" + side.name().toLowerCase(Locale.ROOT) + "_"
|
||||
+ property.fileName();
|
||||
writeFileForBothIdeAndBuildTool(metadata, property.asBytes(), newFileName);
|
||||
return newFileName;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.builder;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.cloud.contract.spec.internal.ExecutionProperty;
|
||||
import org.springframework.cloud.contract.spec.internal.Request;
|
||||
import org.springframework.cloud.contract.spec.internal.Url;
|
||||
@@ -51,7 +53,7 @@ class CustomModeMethodWithUrlGiven implements Given {
|
||||
|
||||
private void addUrl(Url buildUrl, Request request) {
|
||||
Object testSideUrl = MapConverter.getTestSideValues(buildUrl);
|
||||
String method = request.getMethod().getServerValue().toString().toLowerCase();
|
||||
String method = request.getMethod().getServerValue().toString().toLowerCase(Locale.ROOT);
|
||||
String url = testSideUrl.toString();
|
||||
if (!(testSideUrl instanceof ExecutionProperty)) {
|
||||
url = this.bodyParser.quotedShortText(testSideUrl.toString());
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.builder;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.cloud.contract.spec.internal.ExecutionProperty;
|
||||
import org.springframework.cloud.contract.spec.internal.FromFileProperty;
|
||||
import org.springframework.cloud.contract.spec.internal.Request;
|
||||
@@ -43,7 +45,7 @@ class JaxRsRequestMethodWhen implements When, JaxRsBodyParser {
|
||||
void appendMethodAndBody(SingleContractMetadata metadata) {
|
||||
Request request = metadata.getContract().getRequest();
|
||||
ContentType type = metadata.getInputTestContentType();
|
||||
String method = request.getMethod().getServerValue().toString().toLowerCase();
|
||||
String method = request.getMethod().getServerValue().toString().toLowerCase(Locale.ROOT);
|
||||
if (request.getBody() != null) {
|
||||
String contentType = StringUtils.hasText(metadata.getDefinedInputTestContentType())
|
||||
? metadata.getDefinedInputTestContentType() : type.getMimeType();
|
||||
@@ -61,11 +63,11 @@ class JaxRsRequestMethodWhen implements When, JaxRsBodyParser {
|
||||
else {
|
||||
value = "\"" + requestBodyAsString(metadata) + "\"";
|
||||
}
|
||||
this.blockBuilder.addIndented(
|
||||
".build(\"" + method.toUpperCase() + "\", entity(" + value + ", \"" + contentType + "\"))");
|
||||
this.blockBuilder.addIndented(".build(\"" + method.toUpperCase(Locale.ROOT) + "\", entity(" + value + ", \""
|
||||
+ contentType + "\"))");
|
||||
}
|
||||
else {
|
||||
this.blockBuilder.addIndented(".build(\"" + method.toUpperCase() + "\")");
|
||||
this.blockBuilder.addIndented(".build(\"" + method.toUpperCase(Locale.ROOT) + "\")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.builder;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.cloud.contract.spec.internal.ExecutionProperty;
|
||||
import org.springframework.cloud.contract.spec.internal.Request;
|
||||
import org.springframework.cloud.contract.spec.internal.Url;
|
||||
@@ -53,7 +55,7 @@ class MockMvcUrlWhen implements When, MockMvcAcceptor, QueryParamsResolver {
|
||||
|
||||
private void addUrl(Url buildUrl, Request request) {
|
||||
Object testSideUrl = MapConverter.getTestSideValues(buildUrl);
|
||||
String method = request.getMethod().getServerValue().toString().toLowerCase();
|
||||
String method = request.getMethod().getServerValue().toString().toLowerCase(Locale.ROOT);
|
||||
String url = testSideUrl.toString();
|
||||
if (!(testSideUrl instanceof ExecutionProperty)) {
|
||||
url = this.bodyParser.quotedShortText(testSideUrl.toString());
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -273,7 +274,7 @@ public class YamlContract {
|
||||
return Arrays.stream(values())
|
||||
.filter(matchingType -> matchingType.name()
|
||||
.replace("_", "")
|
||||
.equalsIgnoreCase(string.toLowerCase().replace("_", "")))
|
||||
.equalsIgnoreCase(string.toLowerCase(Locale.ROOT).replace("_", "")))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -78,7 +79,7 @@ public class OkHttpHttpVerifier implements HttpVerifier {
|
||||
}
|
||||
|
||||
private String url(Request request) {
|
||||
String url = request.scheme().name().toLowerCase() + ":" + this.hostAndPort
|
||||
String url = request.scheme().name().toLowerCase(Locale.ROOT) + ":" + this.hostAndPort
|
||||
+ (request.path().startsWith("/") ? request.path() : "/" + request.path());
|
||||
if (!request.queryParams().isEmpty()) {
|
||||
return url + "?"
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.AbstractMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.contract.spec.internal.HttpMethods;
|
||||
@@ -69,7 +70,7 @@ public class Request {
|
||||
public String contentType() {
|
||||
Object value = this.headers.entrySet()
|
||||
.stream()
|
||||
.filter(e -> e.getKey().toLowerCase().equals("content-type"))
|
||||
.filter(e -> e.getKey().toLowerCase(Locale.ROOT).equals("content-type"))
|
||||
.findFirst()
|
||||
.orElse(new AbstractMap.SimpleEntry<>("", null))
|
||||
.getValue();
|
||||
@@ -169,7 +170,7 @@ public class Request {
|
||||
* @return builder
|
||||
*/
|
||||
public Request.Builder method(String method, String path) {
|
||||
return new Request.Builder(HttpMethods.HttpMethod.valueOf(method.toUpperCase()), path);
|
||||
return new Request.Builder(HttpMethods.HttpMethod.valueOf(method.toUpperCase(Locale.ROOT)), path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.contract.verifier.messaging.stream;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -60,9 +61,9 @@ class DestinationResolver {
|
||||
log.debug("Found following channels [" + channels + "] for destination [" + destination + "]. "
|
||||
+ "Will pick the one that matches the default channel name or the first one if none is matching");
|
||||
}
|
||||
String defaultChannelName = channels.get(defaultChannel.name().toLowerCase());
|
||||
String defaultChannelName = channels.get(defaultChannel.name().toLowerCase(Locale.ROOT));
|
||||
String matchingChannelName = StringUtils.hasText(defaultChannelName)
|
||||
? defaultChannel.name().toLowerCase() : channels.keySet().iterator().next();
|
||||
? defaultChannel.name().toLowerCase(Locale.ROOT) : channels.keySet().iterator().next();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Picked channel name is [" + matchingChannelName + "]");
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A utility class that helps to convert names.
|
||||
@@ -104,7 +105,7 @@ public final class NamesUtil {
|
||||
if (isEmpty(className)) {
|
||||
return className;
|
||||
}
|
||||
String firstChar = className.substring(0, 1).toLowerCase();
|
||||
String firstChar = className.substring(0, 1).toLowerCase(Locale.ROOT);
|
||||
return firstChar + className.substring(1);
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ public final class NamesUtil {
|
||||
if (isEmpty(className)) {
|
||||
return className;
|
||||
}
|
||||
String firstChar = className.substring(0, 1).toUpperCase();
|
||||
String firstChar = className.substring(0, 1).toUpperCase(Locale.ROOT);
|
||||
return firstChar + className.substring(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -169,7 +170,7 @@ public class WireMockSnippet implements Snippet {
|
||||
org.springframework.http.HttpHeaders headers = operation.getRequest().getHeaders();
|
||||
// TODO: whitelist headers
|
||||
for (String name : headers.keySet()) {
|
||||
if (!this.headerBlackList.contains(name.toLowerCase())) {
|
||||
if (!this.headerBlackList.contains(name.toLowerCase(Locale.ROOT))) {
|
||||
if ("content-type".equalsIgnoreCase(name) && this.contentType != null) {
|
||||
continue;
|
||||
}
|
||||
@@ -239,7 +240,7 @@ public class WireMockSnippet implements Snippet {
|
||||
org.springframework.http.HttpHeaders headers = operation.getResponse().getHeaders();
|
||||
HttpHeaders result = new HttpHeaders();
|
||||
for (String name : headers.keySet()) {
|
||||
if (!this.headerBlackList.contains(name.toLowerCase())) {
|
||||
if (!this.headerBlackList.contains(name.toLowerCase(Locale.ROOT))) {
|
||||
result = result.plus(new HttpHeader(name, headers.get(name)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user