Mockito Polishing

`$ find spring-integration-* | grep '\.java$' | xargs sed -E -i '' -e 's/(\(?)\(([^<()]*)\) *invocation.getArguments\(\)\[([0-9]*)\]/\1invocation.getArgumentAt(\3, \2.class)/'`
This commit is contained in:
Gary Russell
2016-10-28 08:16:56 -04:00
committed by Artem Bilan
parent 9225c514fe
commit c5fbd93787
27 changed files with 58 additions and 58 deletions

View File

@@ -75,7 +75,7 @@ public class P2pChannelTests {
when(logger.isInfoEnabled()).thenReturn(true);
final List<String> logs = new ArrayList<String>();
doAnswer(invocation -> {
logs.add((String) invocation.getArguments()[0]);
logs.add(invocation.getArgumentAt(0, String.class));
return null;
}).when(logger).info(Mockito.anyString());
ReflectionUtils.doWithFields(AbstractMessageChannel.class, field -> {

View File

@@ -309,7 +309,7 @@ public class ChainParserTests {
final AtomicReference<String> log = new AtomicReference<String>();
when(logger.isWarnEnabled()).thenReturn(true);
doAnswer(invocation -> {
log.set((String) invocation.getArguments()[0]);
log.set(invocation.getArgumentAt(0, String.class));
return null;
}).when(logger).warn(any());

View File

@@ -276,7 +276,7 @@ public class BroadcastingDispatcherTests {
private void defaultTaskExecutorMock() {
Mockito.doAnswer(invocation -> {
((Runnable) invocation.getArguments()[0]).run();
(invocation.getArgumentAt(0, Runnable.class)).run();
return null;
}).when(taskExecutorMock).execute(Mockito.any(Runnable.class));
}
@@ -288,7 +288,7 @@ public class BroadcastingDispatcherTests {
final AtomicInteger count = new AtomicInteger();
Mockito.doAnswer(invocation -> {
if (passes[count.getAndIncrement()]) {
((Runnable) invocation.getArguments()[0]).run();
(invocation.getArgumentAt(0, Runnable.class)).run();
}
return null;
}).when(taskExecutorMock).execute(Mockito.any(Runnable.class));

View File

@@ -111,8 +111,8 @@ public class AsyncHandlerTests {
Log logger = spy(TestUtils.getPropertyValue(this.handler, "logger", Log.class));
new DirectFieldAccessor(this.handler).setPropertyValue("logger", logger);
doAnswer(invocation -> {
failedCallbackMessage = (String) invocation.getArguments()[0];
failedCallbackException = (Exception) invocation.getArguments()[1];
failedCallbackMessage = invocation.getArgumentAt(0, String.class);
failedCallbackException = invocation.getArgumentAt(1, Exception.class);
exceptionLatch.countDown();
return null;
}).when(logger).error(anyString(), any(Throwable.class));

View File

@@ -897,7 +897,7 @@ public class AdvisedMessageHandlerTests {
when(logger.isWarnEnabled()).thenReturn(Boolean.TRUE);
final AtomicReference<String> logMessage = new AtomicReference<String>();
doAnswer(invocation -> {
logMessage.set((String) invocation.getArguments()[0]);
logMessage.set(invocation.getArgumentAt(0, String.class));
return null;
}).when(logger).warn(Mockito.anyString());
DirectFieldAccessor accessor = new DirectFieldAccessor(advice);