Search in sources :

Example 1 with PermissionRegistry

use of io.github.nucleuspowered.nucleus.internal.PermissionRegistry 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);
    }
}
Also used : Path(java.nio.file.Path) UserDataManager(io.github.nucleuspowered.nucleus.dataservices.loaders.UserDataManager) CommandsConfig(io.github.nucleuspowered.nucleus.config.CommandsConfig) PermissionRegistry(io.github.nucleuspowered.nucleus.internal.PermissionRegistry) NucleusPlugin(io.github.nucleuspowered.nucleus.NucleusPlugin) IOException(java.io.IOException) ResourceMessageProvider(io.github.nucleuspowered.nucleus.internal.messages.ResourceMessageProvider)

Aggregations

NucleusPlugin (io.github.nucleuspowered.nucleus.NucleusPlugin)1 CommandsConfig (io.github.nucleuspowered.nucleus.config.CommandsConfig)1 UserDataManager (io.github.nucleuspowered.nucleus.dataservices.loaders.UserDataManager)1 PermissionRegistry (io.github.nucleuspowered.nucleus.internal.PermissionRegistry)1 ResourceMessageProvider (io.github.nucleuspowered.nucleus.internal.messages.ResourceMessageProvider)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1