Skip to content

Commit

Permalink
Unnecessary use of fully qualified name 'Mockito.when' #3049
Browse files Browse the repository at this point in the history
  • Loading branch information
yurake committed Feb 15, 2023
1 parent 924956b commit e449b6a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ActiveMqSocketTest {
void testOnOpen() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
assertThat(socket.getSessions().containsKey(id), is(true));
} finally {
Expand All @@ -39,7 +39,7 @@ void testOnOpen() {
void testOnClose() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onClose(session);
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -52,7 +52,7 @@ void testOnClose() {
void testOnError() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onError(session, new Throwable("testOnError"));
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -66,8 +66,8 @@ void testOnMessage() {
Session session = mock(Session.class);
try {
RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class);
Mockito.when(session.getId()).thenReturn(id);
Mockito.when(session.getAsyncRemote()).thenReturn(async);
when(session.getId()).thenReturn(id);
when(session.getAsyncRemote()).thenReturn(async);
socket.onOpen(session);
socket.onMessage(message);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void testCallUp() throws IOException, TimeoutException {
ReadinessHealthCheckHazelcast hc = new ReadinessHealthCheckHazelcast() {
protected HazelcastServiceStatus createHazelcastStatus() {
HazelcastServiceStatus mock = mock(HazelcastServiceStatus.class);
Mockito.when(mock.isActive()).thenReturn(true);
when(mock.isActive()).thenReturn(true);
return mock;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class HazelcastSocketTest {
void testOnOpen() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
assertThat(socket.getSessions().containsKey(id), is(true));
} finally {
Expand All @@ -39,7 +39,7 @@ void testOnOpen() {
void testOnClose() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onClose(session);
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -52,7 +52,7 @@ void testOnClose() {
void testOnError() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onError(session, new Throwable("testOnError"));
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -66,8 +66,8 @@ void testOnMessage() {
Session session = mock(Session.class);
try {
RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class);
Mockito.when(session.getId()).thenReturn(id);
Mockito.when(session.getAsyncRemote()).thenReturn(async);
when(session.getId()).thenReturn(id);
when(session.getAsyncRemote()).thenReturn(async);
socket.onOpen(session);
socket.onMessage(message);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MemcachedServiceTest {
@Test
void testSetMemcached() {
MemCachedClient mcc = mock(MemCachedClient.class);
Mockito.when(mcc.set(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(true);
when(mcc.set(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(true);
try {
MsgBean msgbean = svcMock.setMsg(mcc);
assertThat(msgbean.getFullmsg(), containsString(respbody));
Expand All @@ -53,8 +53,8 @@ void testGetMemcached() {
Object obj = "11111111";
String msg = "Hello k8s-3tier-webapp with quarkus";
MemCachedClient mcc = mock(MemCachedClient.class);
Mockito.when(mcc.get("id")).thenReturn(obj.toString());
Mockito.when(mcc.get("msg")).thenReturn(msg);
when(mcc.get("id")).thenReturn(obj.toString());
when(mcc.get("msg")).thenReturn(msg);

MsgBean bean = svcMock.getMsg(mcc);
assertThat(bean.getId(), is(Integer.valueOf(obj.toString())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.bson.Document;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;

import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RabbitmqSocketTest {
void testOnOpen() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
assertThat(socket.getSessions().containsKey(id), is(true));
} finally {
Expand All @@ -39,7 +39,7 @@ void testOnOpen() {
void testOnClose() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onClose(session);
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -52,7 +52,7 @@ void testOnClose() {
void testOnError() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onError(session, new Throwable("testOnError"));
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -66,8 +66,8 @@ void testOnMessage() {
Session session = mock(Session.class);
try {
RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class);
Mockito.when(session.getId()).thenReturn(id);
Mockito.when(session.getAsyncRemote()).thenReturn(async);
when(session.getId()).thenReturn(id);
when(session.getAsyncRemote()).thenReturn(async);
socket.onOpen(session);
socket.onMessage(message);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ServiceSocketTest {
void testOnOpen() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
assertThat(socket.getSessions().containsKey(id), is(true));
} finally {
Expand All @@ -39,7 +39,7 @@ void testOnOpen() {
void testOnClose() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onClose(session);
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -52,7 +52,7 @@ void testOnClose() {
void testOnError() {
Session session = mock(Session.class);
try {
Mockito.when(session.getId()).thenReturn(id);
when(session.getId()).thenReturn(id);
socket.onOpen(session);
socket.onError(session, new Throwable("testOnError"));
assertThat(socket.getSessions().containsKey(id), is(false));
Expand All @@ -66,8 +66,8 @@ void testOnMessage() {
Session session = mock(Session.class);
try {
RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class);
Mockito.when(session.getId()).thenReturn(id);
Mockito.when(session.getAsyncRemote()).thenReturn(async);
when(session.getId()).thenReturn(id);
when(session.getAsyncRemote()).thenReturn(async);
socket.onOpen(session);
socket.onMessage(message);
} catch (Exception e) {
Expand Down

0 comments on commit e449b6a

Please sign in to comment.