Fix error when Mockito isn't present in prod
This commit is contained in:
parent
ab4dd75684
commit
01dd8a477e
3 changed files with 16 additions and 6 deletions
|
@ -2,6 +2,7 @@ package buttondevteam.core;
|
|||
|
||||
import buttondevteam.core.component.channel.Channel;
|
||||
import buttondevteam.core.component.channel.ChannelComponent;
|
||||
import buttondevteam.lib.ChromaUtils;
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
@ -19,12 +20,9 @@ import java.util.Collections;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
public class TestPrepare {
|
||||
private static boolean test = false;
|
||||
|
||||
public static boolean isTest() { return test; }
|
||||
|
||||
public static void PrepareServer() {
|
||||
test = true;
|
||||
ChromaUtils.setTest(); //Needs to be in a separate class because of the potential lack of Mockito
|
||||
Bukkit.setServer(Mockito.mock(Server.class, new Answer<Object>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package buttondevteam.core.component.channel;
|
||||
|
||||
import buttondevteam.core.TestPrepare;
|
||||
import buttondevteam.lib.ChromaUtils;
|
||||
import buttondevteam.lib.TBMCSystemChatEvent;
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.chat.*;
|
||||
|
@ -36,7 +36,7 @@ public class ChannelComponent extends Component {
|
|||
}
|
||||
|
||||
void registerChannelCommand(Channel channel) {
|
||||
if (!TestPrepare.isTest())
|
||||
if (!ChromaUtils.isTest())
|
||||
registerCommand(new ChannelCommand(channel));
|
||||
}
|
||||
|
||||
|
|
|
@ -86,4 +86,16 @@ public final class ChromaUtils {
|
|||
return what.get();
|
||||
return def;
|
||||
}
|
||||
|
||||
private static boolean test = false;
|
||||
|
||||
/**
|
||||
* Returns true while unit testing.
|
||||
*/
|
||||
public static boolean isTest() { return test; }
|
||||
|
||||
/**
|
||||
* Call when unit testing.
|
||||
*/
|
||||
public static void setTest() { test = true; }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue