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

@@ -776,7 +776,7 @@ public class CachingClientConnectionFactoryTests {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
invocation.callRealMethod();
String log = (String) invocation.getArguments()[0];
String log = invocation.getArgumentAt(0, String.class);
if (log.startsWith("Response")) {
Executors.newSingleThreadScheduledExecutor().execute(new Runnable() {

View File

@@ -303,7 +303,7 @@ public class TcpNioConnectionTests {
Socket socket = mock(Socket.class);
Mockito.when(channel.socket()).thenReturn(socket);
doAnswer(invocation -> {
ByteBuffer buffer = (ByteBuffer) invocation.getArguments()[0];
ByteBuffer buffer = invocation.getArgumentAt(0, ByteBuffer.class);
buffer.position(1);
return 1;
}).when(channel).read(Mockito.any(ByteBuffer.class));
@@ -343,7 +343,7 @@ public class TcpNioConnectionTests {
Socket socket = mock(Socket.class);
Mockito.when(channel.socket()).thenReturn(socket);
doAnswer(invocation -> {
ByteBuffer buffer = (ByteBuffer) invocation.getArguments()[0];
ByteBuffer buffer = invocation.getArgumentAt(0, ByteBuffer.class);
buffer.position(1025);
buffer.put((byte) '\r');
buffer.put((byte) '\n');
@@ -501,7 +501,7 @@ public class TcpNioConnectionTests {
@Override
public Integer answer(InvocationOnMock invocation) throws Throwable {
ByteBuffer buff = (ByteBuffer) invocation.getArguments()[0];
ByteBuffer buff = invocation.getArgumentAt(0, ByteBuffer.class);
byte[] bytes = written.toByteArray();
buff.put(bytes);
return bytes.length;
@@ -516,7 +516,7 @@ public class TcpNioConnectionTests {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
ByteBuffer buff = (ByteBuffer) invocation.getArguments()[0];
ByteBuffer buff = invocation.getArgumentAt(0, ByteBuffer.class);
byte[] bytes = new byte[buff.limit()];
buff.get(bytes);
written.write(bytes);