mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-26 18:11:43 +01:00
Added explicit test for addon locale override
This commit is contained in:
parent
0636532bb4
commit
016c502b66
@ -40,6 +40,8 @@ import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.addons.AddonDescription;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
@ -54,6 +56,7 @@ public class UserTest {
|
||||
private BentoBox plugin;
|
||||
private LocalesManager lm;
|
||||
private User user;
|
||||
private IslandWorldManager iwm;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@ -82,7 +85,7 @@ public class UserTest {
|
||||
when(Bukkit.getPlayer(Mockito.any(UUID.class))).thenReturn(player);
|
||||
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
// Addon
|
||||
when(iwm .getAddon(Mockito.any())).thenReturn(Optional.empty());
|
||||
@ -253,6 +256,20 @@ public class UserTest {
|
||||
Mockito.verify(player).sendMessage(Mockito.eq(TEST_TRANSLATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendMessageOverrideWithAddon() {
|
||||
GameModeAddon addon = mock(GameModeAddon.class);
|
||||
AddonDescription desc = new AddonDescription.Builder("mock", "name").build();
|
||||
when(addon.getDescription()).thenReturn(desc);
|
||||
Optional<GameModeAddon> optionalAddon = Optional.of(addon);
|
||||
when(iwm .getAddon(any())).thenReturn(optionalAddon);
|
||||
when(lm.get(any(), Mockito.eq("name.a.reference"))).thenReturn("mockmockmock");
|
||||
//user = User.getInstance(player);
|
||||
user.sendMessage("a.reference");
|
||||
Mockito.verify(player, Mockito.never()).sendMessage(Mockito.eq(TEST_TRANSLATION));
|
||||
Mockito.verify(player).sendMessage(Mockito.eq("mockmockmock"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendMessageBlankTranslation() {
|
||||
// Nothing - blank translation
|
||||
|
Loading…
Reference in New Issue
Block a user