Polish MockitoApi

pull/2430/merge
Phillip Webb 8 years ago
parent 7f99153daf
commit 1169f69390

@ -34,7 +34,6 @@ import org.mockito.stubbing.Answer;
import org.mockito.verification.VerificationMode; import org.mockito.verification.VerificationMode;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
@ -171,36 +170,17 @@ abstract class MockitoApi {
Mockito1Api() { Mockito1Api() {
this.mockUtil = BeanUtils.instantiateClass(MockUtil.class); this.mockUtil = BeanUtils.instantiateClass(MockUtil.class);
this.getMockSettingsMethod = findMockSettingsMethod(); this.getMockSettingsMethod = ReflectionUtils.findMethod(MockUtil.class,
"getMockSettings", Object.class);
this.mockingProgress = (MockingProgress) BeanUtils this.mockingProgress = (MockingProgress) BeanUtils
.instantiateClass(ClassUtils.resolveClassName( .instantiateClass(ClassUtils.resolveClassName(
"org.mockito.internal.progress.ThreadSafeMockingProgress", "org.mockito.internal.progress.ThreadSafeMockingProgress",
MockitoApi.class.getClassLoader())); MockitoApi.class.getClassLoader()));
this.reportMatcherMethod = findReportMatcherMethod(); this.reportMatcherMethod = ReflectionUtils.findMethod(
this.mockAwareVerificationModeConstructor = findMockAwareVerificationModeConstructor(); ArgumentMatcherStorage.class, "reportMatcher", Matcher.class);
} this.mockAwareVerificationModeConstructor = ClassUtils
private Method findMockSettingsMethod() {
Method method = ReflectionUtils.findMethod(MockUtil.class, "getMockSettings",
Object.class);
Assert.state(method != null, "Unable to find getMockSettings method");
return method;
}
private Method findReportMatcherMethod() {
Method method = ReflectionUtils.findMethod(ArgumentMatcherStorage.class,
"reportMatcher", Matcher.class);
Assert.state(method != null, "Unable to find reportMatcher method");
return method;
}
private Constructor<MockAwareVerificationMode> findMockAwareVerificationModeConstructor() {
Constructor<MockAwareVerificationMode> constructor = ClassUtils
.getConstructorIfAvailable(MockAwareVerificationMode.class, .getConstructorIfAvailable(MockAwareVerificationMode.class,
Object.class, VerificationMode.class); Object.class, VerificationMode.class);
Assert.state(constructor != null,
"Unable to find MockAwareVerificationMode constructor");
return constructor;
} }
@Override @Override

Loading…
Cancel
Save