Fix checkstyle ternary issues
Fix checkstyle issues with ternary expressions following the spring-javaformat upgrade. See gh-13932
This commit is contained in:
@@ -168,10 +168,10 @@ class ImportsContextCustomizer implements ContextCustomizer {
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
BeanDefinition definition = this.beanFactory
|
||||
.getBeanDefinition(ImportsConfiguration.BEAN_NAME);
|
||||
Object testClass = (definition != null
|
||||
? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null);
|
||||
return (testClass != null ? new String[] { ((Class<?>) testClass).getName() }
|
||||
: NO_IMPORTS);
|
||||
Object testClass = (definition != null)
|
||||
? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null;
|
||||
return (testClass != null) ? new String[] { ((Class<?>) testClass).getName() }
|
||||
: NO_IMPORTS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -245,7 +245,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
|
||||
collectClassAnnotations(testClass, annotations, seen);
|
||||
Set<Object> determinedImports = determineImports(annotations, testClass);
|
||||
this.key = Collections.unmodifiableSet(
|
||||
determinedImports != null ? determinedImports : annotations);
|
||||
(determinedImports != null) ? determinedImports : annotations);
|
||||
}
|
||||
|
||||
private void collectClassAnnotations(Class<?> classType,
|
||||
|
||||
@@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder {
|
||||
|
||||
private String getParentPackage(String sourcePackage) {
|
||||
int lastDot = sourcePackage.lastIndexOf('.');
|
||||
return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : "");
|
||||
return (lastDot != -1) ? sourcePackage.substring(0, lastDot) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -110,9 +110,9 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
if (!ObjectUtils.isEmpty(config.getActiveProfiles())) {
|
||||
setActiveProfiles(environment, config.getActiveProfiles());
|
||||
}
|
||||
ResourceLoader resourceLoader = (application.getResourceLoader() != null
|
||||
ResourceLoader resourceLoader = (application.getResourceLoader() != null)
|
||||
? application.getResourceLoader()
|
||||
: new DefaultResourceLoader(getClass().getClassLoader()));
|
||||
: new DefaultResourceLoader(getClass().getClassLoader());
|
||||
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment,
|
||||
resourceLoader, config.getPropertySourceLocations());
|
||||
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment,
|
||||
|
||||
@@ -166,8 +166,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
WebAppConfiguration webAppConfiguration = AnnotatedElementUtils
|
||||
.findMergedAnnotation(mergedConfig.getTestClass(),
|
||||
WebAppConfiguration.class);
|
||||
String resourceBasePath = (webAppConfiguration != null
|
||||
? webAppConfiguration.value() : "src/main/webapp");
|
||||
String resourceBasePath = (webAppConfiguration != null)
|
||||
? webAppConfiguration.value() : "src/main/webapp";
|
||||
mergedConfig = new WebMergedContextConfiguration(mergedConfig,
|
||||
resourceBasePath);
|
||||
}
|
||||
@@ -316,17 +316,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
*/
|
||||
protected WebEnvironment getWebEnvironment(Class<?> testClass) {
|
||||
SpringBootTest annotation = getAnnotation(testClass);
|
||||
return (annotation != null ? annotation.webEnvironment() : null);
|
||||
return (annotation != null) ? annotation.webEnvironment() : null;
|
||||
}
|
||||
|
||||
protected Class<?>[] getClasses(Class<?> testClass) {
|
||||
SpringBootTest annotation = getAnnotation(testClass);
|
||||
return (annotation != null ? annotation.classes() : null);
|
||||
return (annotation != null) ? annotation.classes() : null;
|
||||
}
|
||||
|
||||
protected String[] getProperties(Class<?> testClass) {
|
||||
SpringBootTest annotation = getAnnotation(testClass);
|
||||
return (annotation != null ? annotation.properties() : null);
|
||||
return (annotation != null) ? annotation.properties() : null;
|
||||
}
|
||||
|
||||
protected SpringBootTest getAnnotation(Class<?> testClass) {
|
||||
|
||||
@@ -278,8 +278,8 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
"%nExpecting:%n <%s>%nsingle bean of type:%n <%s>%nbut found:%n <%s>",
|
||||
getApplicationContext(), type, names));
|
||||
}
|
||||
T bean = (names.length != 0 ? getApplicationContext().getBean(names[0], type)
|
||||
: null);
|
||||
T bean = (names.length != 0) ? getApplicationContext().getBean(names[0], type)
|
||||
: null;
|
||||
return Assertions.assertThat(bean).as("Bean of type <%s> from <%s>", type,
|
||||
getApplicationContext());
|
||||
}
|
||||
|
||||
@@ -93,11 +93,11 @@ public final class WebApplicationContextRunner extends
|
||||
*/
|
||||
public static Supplier<ConfigurableWebApplicationContext> withMockServletContext(
|
||||
Supplier<ConfigurableWebApplicationContext> contextFactory) {
|
||||
return (contextFactory != null ? () -> {
|
||||
return (contextFactory != null) ? () -> {
|
||||
ConfigurableWebApplicationContext context = contextFactory.get();
|
||||
context.setServletContext(new MockServletContext());
|
||||
return context;
|
||||
} : null);
|
||||
} : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -74,8 +74,8 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JsonContent " + this.json
|
||||
+ (this.type != null ? " created from " + this.type : "");
|
||||
String createdFrom = (this.type != null) ? " created from " + this.type : "";
|
||||
return "JsonContent " + this.json + createdFrom;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
|
||||
}
|
||||
try {
|
||||
return JSONCompare.compareJSON(
|
||||
(expectedJson != null ? expectedJson.toString() : null),
|
||||
((expectedJson != null) ? expectedJson.toString() : null),
|
||||
this.actual.toString(), compareMode);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
|
||||
}
|
||||
try {
|
||||
return JSONCompare.compareJSON(
|
||||
(expectedJson != null ? expectedJson.toString() : null),
|
||||
((expectedJson != null) ? expectedJson.toString() : null),
|
||||
this.actual.toString(), comparator);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
|
||||
|
||||
JsonPathValue(CharSequence expression, Object... args) {
|
||||
org.springframework.util.Assert.hasText(
|
||||
(expression != null ? expression.toString() : null),
|
||||
((expression != null) ? expression.toString() : null),
|
||||
"expression must not be null or empty");
|
||||
this.expression = String.format(expression.toString(), args);
|
||||
this.jsonPath = JsonPath.compile(this.expression);
|
||||
@@ -1107,7 +1107,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
|
||||
public Object getValue(boolean required) {
|
||||
try {
|
||||
CharSequence json = JsonContentAssert.this.actual;
|
||||
return this.jsonPath.read(json != null ? json.toString() : null);
|
||||
return this.jsonPath.read((json != null) ? json.toString() : null);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (!required) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -43,7 +43,7 @@ class JsonLoader {
|
||||
|
||||
JsonLoader(Class<?> resourceLoadClass, Charset charset) {
|
||||
this.resourceLoadClass = resourceLoadClass;
|
||||
this.charset = (charset != null ? charset : StandardCharsets.UTF_8);
|
||||
this.charset = (charset != null) ? charset : StandardCharsets.UTF_8;
|
||||
}
|
||||
|
||||
Class<?> getResourceLoadClass() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -62,8 +62,8 @@ public final class ObjectContent<T> implements AssertProvider<ObjectContentAsser
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ObjectContent " + this.object
|
||||
+ (this.type != null ? " created from " + this.type : "");
|
||||
String createdFrom = (this.type != null) ? " created from " + this.type : "";
|
||||
return "ObjectContent " + this.object + createdFrom;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -39,7 +39,7 @@ abstract class Definition {
|
||||
Definition(String name, MockReset reset, boolean proxyTargetAware,
|
||||
QualifierDefinition qualifier) {
|
||||
this.name = name;
|
||||
this.reset = (reset != null ? reset : MockReset.AFTER);
|
||||
this.reset = (reset != null) ? reset : MockReset.AFTER;
|
||||
this.proxyTargetAware = proxyTargetAware;
|
||||
this.qualifier = qualifier;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class MockDefinition extends Definition {
|
||||
Assert.notNull(typeToMock, "TypeToMock must not be null");
|
||||
this.typeToMock = typeToMock;
|
||||
this.extraInterfaces = asClassSet(extraInterfaces);
|
||||
this.answer = (answer != null ? answer : Answers.RETURNS_DEFAULTS);
|
||||
this.answer = (answer != null) ? answer : Answers.RETURNS_DEFAULTS;
|
||||
this.serializable = serializable;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ public abstract class EnvironmentTestUtils {
|
||||
Map<String, Object> map = getOrAdd(sources, name);
|
||||
for (String pair : pairs) {
|
||||
int index = getSeparatorIndex(pair);
|
||||
String key = (index > 0 ? pair.substring(0, index) : pair);
|
||||
String value = (index > 0 ? pair.substring(index + 1) : "");
|
||||
String key = (index > 0) ? pair.substring(0, index) : pair;
|
||||
String value = (index > 0) ? pair.substring(index + 1) : "";
|
||||
map.put(key.trim(), value.trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public final class TestPropertyValues {
|
||||
}
|
||||
|
||||
protected String applySuffix(String name) {
|
||||
return (this.suffix != null ? name + "-" + this.suffix : name);
|
||||
return (this.suffix != null) ? name + "-" + this.suffix : name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -261,8 +261,8 @@ public final class TestPropertyValues {
|
||||
|
||||
public static Pair parse(String pair) {
|
||||
int index = getSeparatorIndex(pair);
|
||||
String name = (index > 0 ? pair.substring(0, index) : pair);
|
||||
String value = (index > 0 ? pair.substring(index + 1) : "");
|
||||
String name = (index > 0) ? pair.substring(0, index) : pair;
|
||||
String value = (index > 0) ? pair.substring(index + 1) : "";
|
||||
return of(name.trim(), value.trim());
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class TestRestTemplate {
|
||||
*/
|
||||
public TestRestTemplate(RestTemplateBuilder restTemplateBuilder, String username,
|
||||
String password, HttpClientOption... httpClientOptions) {
|
||||
this(restTemplateBuilder != null ? restTemplateBuilder.build() : null, username,
|
||||
this((restTemplateBuilder != null) ? restTemplateBuilder.build() : null, username,
|
||||
password, httpClientOptions);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user