Search in sources :

Example 1 with CoreConfigAdapter

use of io.github.nucleuspowered.nucleus.modules.core.config.CoreConfigAdapter 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);
    }
}
Also used : Path(java.nio.file.Path) Game(org.spongepowered.api.Game) ConfigDir(org.spongepowered.api.config.ConfigDir) CoreConfig(io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig) DefaultConfig(org.spongepowered.api.config.DefaultConfig) UserDataManager(io.github.nucleuspowered.nucleus.dataservices.loaders.UserDataManager) IOException(java.io.IOException) Logger(org.slf4j.Logger) CoreConfigAdapter(io.github.nucleuspowered.nucleus.modules.core.config.CoreConfigAdapter) NucleusPlugin(io.github.nucleuspowered.nucleus.NucleusPlugin) IOException(java.io.IOException)

Aggregations

NucleusPlugin (io.github.nucleuspowered.nucleus.NucleusPlugin)1 UserDataManager (io.github.nucleuspowered.nucleus.dataservices.loaders.UserDataManager)1 CoreConfig (io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig)1 CoreConfigAdapter (io.github.nucleuspowered.nucleus.modules.core.config.CoreConfigAdapter)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Logger (org.slf4j.Logger)1 Game (org.spongepowered.api.Game)1 ConfigDir (org.spongepowered.api.config.ConfigDir)1 DefaultConfig (org.spongepowered.api.config.DefaultConfig)1