Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed May 11, 2018
1 parent e3f0a70 commit a9645a3
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private Map<String, Object> extract(ApplicationContext context, ObjectMapper map
String beanName = entry.getKey();
Object bean = entry.getValue();
Map<String, Object> root = new HashMap<String, Object>();
String prefix = extractPrefix(context, beanFactoryMetaData, beanName, bean);
String prefix = extractPrefix(context, beanFactoryMetaData, beanName);
root.put("prefix", prefix);
root.put("properties", sanitize(prefix, safeSerialize(mapper, bean, prefix)));
result.put(beanName, root);
Expand Down Expand Up @@ -204,12 +204,10 @@ private void applyConfigurationPropertiesFilter(ObjectMapper mapper) {
* @param context the application context
* @param beanFactoryMetaData the bean factory meta-data
* @param beanName the bean name
* @param bean the bean
* @return the prefix
*/
private String extractPrefix(ApplicationContext context,
ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName,
Object bean) {
ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName) {
ConfigurationProperties annotation = context.findAnnotationOnBean(beanName,
ConfigurationProperties.class);
if (beanFactoryMetaData != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 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.
Expand Down Expand Up @@ -80,7 +80,7 @@ public Iterable<Metric<?>> findAll(String group) {
List<String> values = this.redisOperations.opsForValue().multiGet(keys);
for (String v : values) {
String key = keysIt.next();
result.add(deserialize(group, key, v, zSetOperations.score(key)));
result.add(deserialize(key, v, zSetOperations.score(key)));
}
return result;

Expand Down Expand Up @@ -143,7 +143,7 @@ public void reset(String group) {
this.zSetOperations.remove(groupKey);
}

private Metric<?> deserialize(String group, String redisKey, String v, Double value) {
private Metric<?> deserialize(String redisKey, String v, Double value) {
Date timestamp = new Date(Long.valueOf(v));
return new Metric<Double>(nameFor(redisKey), value, timestamp);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 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.
Expand Down Expand Up @@ -51,8 +51,7 @@ protected ExitStatus run(OptionSet options) throws Exception {
SourceOptions sourceOptions = new SourceOptions(options);
TestRunnerConfiguration configuration = new TestRunnerConfigurationAdapter(
options, this);
this.runner = new TestRunner(configuration, sourceOptions.getSourcesArray(),
sourceOptions.getArgsArray());
this.runner = new TestRunner(configuration, sourceOptions.getSourcesArray());
this.runner.compileAndRunTests();
return ExitStatus.OK.hangup();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 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.
Expand Down Expand Up @@ -46,9 +46,8 @@ public class TestRunner {
* Create a new {@link TestRunner} instance.
* @param configuration the configuration
* @param sources the sources
* @param args the args
*/
TestRunner(TestRunnerConfiguration configuration, String[] sources, String[] args) {
TestRunner(TestRunnerConfiguration configuration, String[] sources) {
this.sources = sources.clone();
this.compiler = new GroovyCompiler(configuration);
}
Expand Down Expand Up @@ -97,12 +96,11 @@ private class RunThread extends Thread {
if (sources.length != 0 && sources[0] instanceof Class) {
setContextClassLoader(((Class<?>) sources[0]).getClassLoader());
}
this.spockSpecificationClass = loadSpockSpecificationClass(
getContextClassLoader());
this.spockSpecificationClass = loadSpockSpecificationClass();
this.testClasses = getTestClasses(sources);
}

private Class<?> loadSpockSpecificationClass(ClassLoader contextClassLoader) {
private Class<?> loadSpockSpecificationClass() {
try {
return getContextClassLoader().loadClass("spock.lang.Specification");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private URL[] getGroovyJars(final ClassLoader parent) {
Set<URL> urls = new HashSet<URL>();
findGroovyJarsDirectly(parent, urls);
if (urls.isEmpty()) {
findGroovyJarsFromClassPath(parent, urls);
findGroovyJarsFromClassPath(urls);
}
Assert.state(!urls.isEmpty(), "Unable to find groovy JAR");
return new ArrayList<URL>(urls).toArray(new URL[urls.size()]);
Expand All @@ -205,7 +205,7 @@ private void findGroovyJarsDirectly(ClassLoader classLoader, Set<URL> urls) {
}
}

private void findGroovyJarsFromClassPath(ClassLoader parent, Set<URL> urls) {
private void findGroovyJarsFromClassPath(Set<URL> urls) {
String classpath = System.getProperty("java.class.path");
String[] entries = classpath.split(System.getProperty("path.separator"));
for (String entry : entries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SpringApplicationBannerPrinter {
}

public Banner print(Environment environment, Class<?> sourceClass, Log logger) {
Banner banner = getBanner(environment, this.fallbackBanner);
Banner banner = getBanner(environment);
try {
logger.info(createStringFromBanner(banner, environment, sourceClass));
}
Expand All @@ -67,12 +67,12 @@ public Banner print(Environment environment, Class<?> sourceClass, Log logger) {
}

public Banner print(Environment environment, Class<?> sourceClass, PrintStream out) {
Banner banner = getBanner(environment, this.fallbackBanner);
Banner banner = getBanner(environment);
banner.printBanner(environment, sourceClass, out);
return new PrintedBanner(banner, sourceClass);
}

private Banner getBanner(Environment environment, Banner definedBanner) {
private Banner getBanner(Environment environment) {
Banners banners = new Banners();
banners.addIfNotNull(getImageBanner(environment));
banners.addIfNotNull(getTextBanner(environment));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 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.
Expand Down Expand Up @@ -50,10 +50,10 @@ class TomcatErrorPage {
this.location = errorPage.getPath();
this.exceptionType = errorPage.getExceptionName();
this.errorCode = errorPage.getStatusCode();
this.nativePage = createNativePage(errorPage);
this.nativePage = createNativePage();
}

private Object createNativePage(ErrorPage errorPage) {
private Object createNativePage() {
try {
if (ClassUtils.isPresent(ERROR_PAGE_CLASS, null)) {
return BeanUtils.instantiate(ClassUtils.forName(ERROR_PAGE_CLASS, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void conversionServiceShouldAlwaysUseLocaleEnglish() {
Locale.setDefault(new Locale("tr"));
TestEnum result = this.conversionService
.convert("accept-case-insensitive-properties", TestEnum.class);
assertThat(result.equals(TestEnum.ACCEPT_CASE_INSENSITIVE_PROPERTIES));
assertThat(result).isEqualTo(TestEnum.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
}
finally {
Locale.setDefault(defaultLocale);
Expand Down

0 comments on commit a9645a3

Please sign in to comment.