Commits

DerFrZocker authored and md_5 committed 69c7ce23f29
#990: Use Mockito instead of InvocationHandler for test mocking
No tags

src/test/java/org/bukkit/event/PlayerChatTabCompleteEventTest.java

Modified
1 1 package org.bukkit.event;
2 2
3 3 import static org.hamcrest.CoreMatchers.*;
4 4 import static org.junit.Assert.*;
5 +import static org.mockito.Mockito.*;
5 6 import com.google.common.collect.ImmutableList;
6 7 import org.bukkit.event.player.PlayerChatTabCompleteEvent;
7 -import org.bukkit.plugin.messaging.TestPlayer;
8 8 import org.junit.Test;
9 9
10 10 public class PlayerChatTabCompleteEventTest {
11 11
12 12 @Test
13 13 public void testGetLastToken() {
14 14 assertThat(getToken("Hello everyone!"), is("everyone!"));
15 15 assertThat(getToken(" welcome to the show..."), is("show..."));
16 16 assertThat(getToken("The whitespace is here "), is(""));
17 17 assertThat(getToken("Too much whitespace is here "), is(""));
18 18 assertThat(getToken("The_whitespace_is_missing"), is("The_whitespace_is_missing"));
19 19 assertThat(getToken(""), is(""));
20 20 assertThat(getToken(" "), is(""));
21 21 }
22 22
23 23 private String getToken(String message) {
24 - return new PlayerChatTabCompleteEvent(TestPlayer.getInstance(), message, ImmutableList.<String>of()).getLastToken();
24 + return new PlayerChatTabCompleteEvent(mock(), message, ImmutableList.<String>of()).getLastToken();
25 25 }
26 26 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut