Migrate to Mockito.mock(T...) where feasible

This commit is contained in:
Sam Brannen
2023-01-19 14:32:29 +01:00
parent c3d123fef7
commit c4c786596f
369 changed files with 2267 additions and 2707 deletions

View File

@@ -156,7 +156,7 @@ public class CaffeineCacheManagerTests {
Cache cache1 = cm.getCache("c1");
@SuppressWarnings("unchecked")
CacheLoader<Object, Object> loader = mock(CacheLoader.class);
CacheLoader<Object, Object> loader = mock();
cm.setCacheLoader(loader);
Cache cache1x = cm.getCache("c1");

View File

@@ -86,11 +86,10 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
private final List<String> cacheNames;
private final CacheManager cacheManager;
private final CacheManager cacheManager = mock();
private CacheManagerMock() {
this.cacheNames = new ArrayList<>();
this.cacheManager = mock(CacheManager.class);
given(cacheManager.getCacheNames()).willReturn(cacheNames);
}
@@ -101,7 +100,7 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addCache(String name) {
cacheNames.add(name);
Cache cache = mock(Cache.class);
Cache cache = mock();
given(cache.getName()).willReturn(name);
given(cacheManager.getCache(name)).willReturn(cache);
}

View File

@@ -114,7 +114,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
@Test
public void defaultCacheNameWithDefaults() {
Method method = ReflectionUtils.findMethod(Object.class, "toString");
CacheDefaults mock = mock(CacheDefaults.class);
CacheDefaults mock = mock();
given(mock.cacheName()).willReturn("");
assertThat(source.determineCacheName(method, mock, "")).isEqualTo("java.lang.Object.toString()");
}

View File

@@ -61,13 +61,13 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
@SuppressWarnings({ "rawtypes", "unchecked" })
protected CacheResolver getCacheResolver(CacheInvocationContext<? extends Annotation> context, String cacheName) {
CacheResolver cacheResolver = mock(CacheResolver.class);
CacheResolver cacheResolver = mock();
javax.cache.Cache cache;
if (cacheName == null) {
cache = null;
}
else {
cache = mock(javax.cache.Cache.class);
cache = mock();
given(cache.getName()).willReturn(cacheName);
}
given(cacheResolver.resolveCache(context)).willReturn(cache);

View File

@@ -154,7 +154,7 @@ public class JCacheErrorHandlerTests {
@Bean
@Override
public CacheErrorHandler errorHandler() {
return mock(CacheErrorHandler.class);
return mock();
}
@Bean
@@ -164,14 +164,14 @@ public class JCacheErrorHandlerTests {
@Bean
public Cache mockCache() {
Cache cache = mock(Cache.class);
Cache cache = mock();
given(cache.getName()).willReturn("test");
return cache;
}
@Bean
public Cache mockErrorCache() {
Cache cache = mock(Cache.class);
Cache cache = mock();
given(cache.getName()).willReturn("error");
return cache;
}

View File

@@ -68,7 +68,7 @@ class QuartzSupportTests {
TestBean tb = new TestBean("tb", 99);
StaticApplicationContext ac = new StaticApplicationContext();
final Scheduler scheduler = mock(Scheduler.class);
final Scheduler scheduler = mock();
SchedulerContext schedulerContext = new SchedulerContext();
given(scheduler.getContext()).willReturn(schedulerContext);

View File

@@ -34,7 +34,7 @@ public class TestableCacheResolver implements CacheResolver {
public <K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annotation> cacheInvocationContext) {
String cacheName = cacheInvocationContext.getCacheName();
@SuppressWarnings("unchecked")
Cache<K, V> mock = mock(Cache.class);
Cache<K, V> mock = mock();
given(mock.getName()).willReturn(cacheName);
return mock;
}