use of io.github.nucleuspowered.nucleus.NucleusPlugin in project Nucleus by NucleusPowered.
the class TestModule method configure.
@Override
protected void configure() {
Path test;
Path test2;
try {
test = Files.createTempDirectory("quick");
test2 = Files.createTempFile(test, "quick", "conf");
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
this.bind(Path.class).annotatedWith(DefaultConfig.class).toInstance(test2);
this.bind(Path.class).annotatedWith(ConfigDir.class).toInstance(test);
this.bind(Game.class).toInstance(Mockito.mock(Game.class));
this.bind(Logger.class).toInstance(Mockito.mock(Logger.class));
CoreConfigAdapter mock = Mockito.mock(CoreConfigAdapter.class);
PowerMockito.replace(PowerMockito.method(CoreConfigAdapter.class, "getNode")).with((obj, method, arguments) -> new CoreConfig());
this.bind(CoreConfigAdapter.class).toInstance(mock);
try {
NucleusPlugin plugin = getMockPlugin();
this.bind(NucleusPlugin.class).toInstance(plugin);
this.bind(UserDataManager.class).toInstance(plugin.getUserDataManager());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of io.github.nucleuspowered.nucleus.NucleusPlugin in project Nucleus by NucleusPowered.
the class TestModule method getMockPlugin.
private NucleusPlugin getMockPlugin() {
NucleusPlugin plugin = Mockito.mock(NucleusPlugin.class);
PermissionRegistry pr = new PermissionRegistry();
Mockito.when(plugin.getMessageProvider()).thenReturn(new ResourceMessageProvider(ResourceMessageProvider.messagesBundle));
Mockito.when(plugin.getPermissionRegistry()).thenReturn(pr);
Mockito.when(plugin.getUserDataManager()).thenReturn(Mockito.mock(UserDataManager.class));
/*
Field f = Nucleus.class.getDeclaredField("nucleus");
f.setAccessible(true);
f.set(null, plugin);
*/
try {
Path file = Files.createTempFile("quickstartcmdtest", "conf");
CommandsConfig cc = new CommandsConfig(file);
Mockito.when(plugin.getCommandsConfig()).thenReturn(cc);
return plugin;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of io.github.nucleuspowered.nucleus.NucleusPlugin in project Nucleus by NucleusPowered.
the class ChatUtilTests method setup.
@BeforeClass
public static void setup() throws Exception {
TestBase.testSetup();
NucleusPlugin plugin = Guice.createInjector(new TestModule()).getInstance(NucleusPlugin.class);
Field parserToTest = TextParsingUtils.class.getDeclaredField("urlParser");
parserToTest.setAccessible(true);
patternToTest = (Pattern) parserToTest.get(new TextParsingUtils(plugin));
}
Aggregations