Fixed errors and tests for CompleteChallengeCommandTest

This commit is contained in:
tastybento 2021-09-23 17:22:16 -07:00
parent 018455f8f6
commit c21cae91e1

View File

@ -83,7 +83,7 @@ public class CompleteChallengeCommandTest {
private IslandWorldManager iwm; private IslandWorldManager iwm;
@Mock @Mock
private GameModeAddon gameModeAddon; private GameModeAddon gameModeAddon;
@Mock
private Settings settings; private Settings settings;
@Mock @Mock
private Challenge challenge; private Challenge challenge;
@ -159,8 +159,9 @@ public class CompleteChallengeCommandTest {
when(ChatColor.translateAlternateColorCodes(any(char.class), anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class)); when(ChatColor.translateAlternateColorCodes(any(char.class), anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
// Settings // Settings
settings = new Settings();
when(addon.getChallengesSettings()).thenReturn(settings); when(addon.getChallengesSettings()).thenReturn(settings);
when(settings.getVisibilityMode()).thenReturn(VisibilityMode.VISIBLE); settings.setVisibilityMode(VisibilityMode.VISIBLE);
// Island // Island
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
@ -217,7 +218,7 @@ public class CompleteChallengeCommandTest {
@Test @Test
public void testExecuteUserStringListOfStringNoArgs() { public void testExecuteUserStringListOfStringNoArgs() {
assertFalse(cc.execute(user, "complete", Collections.emptyList())); assertFalse(cc.execute(user, "complete", Collections.emptyList()));
verify(user).sendMessage(eq("challenges.errors.no-name")); verify(user).getTranslation(eq("challenges.errors.no-name"));
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock")); verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
} }
@ -228,7 +229,7 @@ public class CompleteChallengeCommandTest {
public void testExecuteUserStringListOfStringUnknownChallenge() { public void testExecuteUserStringListOfStringUnknownChallenge() {
when(chm.getChallenge(anyString())).thenReturn(null); when(chm.getChallenge(anyString())).thenReturn(null);
assertFalse(cc.execute(user, "complete", Collections.singletonList("mychal"))); assertFalse(cc.execute(user, "complete", Collections.singletonList("mychal")));
verify(user).sendMessage(eq("challenges.errors.unknown-challenge")); verify(user).getTranslation(eq("challenges.errors.unknown-challenge"));
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock")); verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
} }
@ -257,7 +258,7 @@ public class CompleteChallengeCommandTest {
@Test @Test
public void testExecuteUserStringListOfStringKnownChallengeSuccessMultipleTimesNoPerm() { public void testExecuteUserStringListOfStringKnownChallengeSuccessMultipleTimesNoPerm() {
assertTrue(cc.execute(user, "complete", Arrays.asList("mychal", "5"))); assertTrue(cc.execute(user, "complete", Arrays.asList("mychal", "5")));
verify(user).sendMessage(eq("challenges.error.no-multiple-permission")); verify(user).getTranslation(eq("challenges.error.no-multiple-permission"));
} }
/** /**