Create delayed injection test runner
- Test runner supporting new "DelayedInjection" annotation: such fields are only initialized with instantiation right before the first time they're used in tests, allowing to set up mock behavior beforehand
This commit is contained in:
@@ -3,9 +3,8 @@ package tools.checktestmocks;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Sets;
|
||||
import fr.xephi.authme.initialization.ConstructorInjection;
|
||||
import fr.xephi.authme.initialization.FieldInjection;
|
||||
import fr.xephi.authme.initialization.Injection;
|
||||
import fr.xephi.authme.initialization.InjectionHelper;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.mockito.Mock;
|
||||
import tools.utils.AutoToolTask;
|
||||
@@ -139,11 +138,7 @@ public class CheckTestMocks implements AutoToolTask {
|
||||
}
|
||||
|
||||
private static Set<Class<?>> getRealClassDependencies(Class<?> realClass) {
|
||||
Injection<?> injection = ConstructorInjection.provide(realClass).get();
|
||||
if (injection != null) {
|
||||
return Sets.newHashSet(injection.getDependencies());
|
||||
}
|
||||
injection = FieldInjection.provide(realClass).get();
|
||||
Injection<?> injection = InjectionHelper.getInjection(realClass);
|
||||
return injection == null
|
||||
? Collections.<Class<?>>emptySet()
|
||||
: Sets.newHashSet(injection.getDependencies());
|
||||
|
||||
@@ -5,9 +5,8 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Multimap;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.converter.Converter;
|
||||
import fr.xephi.authme.initialization.ConstructorInjection;
|
||||
import fr.xephi.authme.initialization.FieldInjection;
|
||||
import fr.xephi.authme.initialization.Injection;
|
||||
import fr.xephi.authme.initialization.InjectionHelper;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||
@@ -144,11 +143,7 @@ public class DrawDependency implements ToolTask {
|
||||
}
|
||||
|
||||
private List<String> getDependencies(Class<?> clazz) {
|
||||
Injection<?> injection = ConstructorInjection.provide(clazz).get();
|
||||
if (injection != null) {
|
||||
return formatInjectionDependencies(injection);
|
||||
}
|
||||
injection = FieldInjection.provide(clazz).get();
|
||||
Injection<?> injection = InjectionHelper.getInjection(clazz);
|
||||
return injection == null ? null : formatInjectionDependencies(injection);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user