Remove Mockito 1 leftover

Closes gh-15422
This commit is contained in:
dreis2211 2018-12-08 14:42:19 +01:00 committed by Stephane Nicoll
parent 554e7061ce
commit 0f92b139f3

View File

@ -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.
@ -16,12 +16,10 @@
package org.springframework.boot.test.mock.mockito;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable;
@ -34,10 +32,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@ -60,32 +58,8 @@ public class SpyBeanWithAopProxyTests {
Long d2 = this.dateService.getDate(false);
assertThat(d1).isEqualTo(d2);
verify(this.dateService, times(1)).getDate(false);
verify(this.dateService, times(1)).getDate(matchesFalse());
verify(this.dateService, times(1)).getDate(matchesAnyBoolean());
}
private boolean matchesFalse() {
if (isTestingMockito1()) {
Method method = ReflectionUtils.findMethod(
ClassUtils.resolveClassName("org.mockito.Matchers", null), "eq",
Boolean.TYPE);
return (boolean) ReflectionUtils.invokeMethod(method, null, false);
}
return ArgumentMatchers.eq(false);
}
private boolean matchesAnyBoolean() {
if (isTestingMockito1()) {
Method method = ReflectionUtils.findMethod(
ClassUtils.resolveClassName("org.mockito.Matchers", null),
"anyBoolean");
return (boolean) ReflectionUtils.invokeMethod(method, null);
}
return ArgumentMatchers.anyBoolean();
}
private boolean isTestingMockito1() {
return ClassUtils.isPresent("org.mockito.ReturnValues", null);
verify(this.dateService, times(1)).getDate(eq(false));
verify(this.dateService, times(1)).getDate(anyBoolean());
}
@Configuration