use of org.spongepowered.api.plugin.PluginManager in project SpongeCommon by SpongePowered.
the class ShouldFireTest method init.
@Before
public void init() throws Exception {
PluginManager manager = Mockito.mock(PluginManager.class);
this.eventManager = new SpongeEventManager(this.logger, manager);
this.plugin = new Object();
this.container = Mockito.mock(PluginContainer.class);
Mockito.when(manager.fromInstance(this.plugin)).thenReturn(Optional.of(this.container));
this.resetStatics();
}
use of org.spongepowered.api.plugin.PluginManager in project SpongeCommon by SpongePowered.
the class SnapshotGenerationTest method init.
@Before
public void init() {
PluginManager manager = Mockito.mock(PluginManager.class);
this.eventManager = new SpongeEventManager(this.logger, manager);
try {
Field field = Timings.class.getDeclaredField("factory");
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, Mockito.mock(TimingsFactory.class));
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
this.plugin = new Object();
PluginContainer container = Mockito.mock(PluginContainer.class);
Mockito.when(manager.fromInstance(this.plugin)).thenReturn(Optional.of(container));
Cause cause = Cause.of(EventContext.empty(), this);
this.entity = Mockito.mock(Entity.class, withSettings().defaultAnswer(Mockito.RETURNS_MOCKS));
this.event = SpongeEventFactory.createSpawnEntityEvent(cause, Lists.newArrayList(this.entity));
Game game = mock(Game.class);
CauseStackManager csm = mock(CauseStackManager.class);
Mockito.when(game.getCauseStackManager()).thenReturn(csm);
}
use of org.spongepowered.api.plugin.PluginManager in project SpongeCommon by SpongePowered.
the class TestImplementationModule method configure.
@Override
protected void configure() {
super.configure();
this.bind(Server.class).to(TestServer.class);
this.bind(SpongeGame.class).to(TestGame.class);
Platform platform = mock(Platform.class);
PluginContainer mock = mock(PluginContainer.class);
when(platform.getContainer(any())).thenReturn(mock);
this.bind(Platform.class).toInstance(platform);
PluginManager manager = mock(PluginManager.class);
when(mock.getId()).thenReturn("sponge");
when(manager.getPlugin(anyString())).thenReturn(Optional.of(mock));
when(manager.fromInstance(any())).thenReturn(Optional.of(mock));
this.bind(PluginManager.class).toInstance(manager);
this.bind(EventManager.class).toInstance(mock(EventManager.class));
this.bind(ChannelRegistrar.class).toInstance(mock(ChannelRegistrar.class));
}
use of org.spongepowered.api.plugin.PluginManager in project SpongeForge by SpongePowered.
the class SpongeModEventManagerTest method init.
@Before
public void init() throws Exception {
PluginManager manager = Mockito.mock(PluginManager.class);
this.eventManager = new SpongeEventManager(manager);
this.plugin = new Object();
this.container = Mockito.mock(PluginContainer.class);
Mockito.when(manager.fromInstance(plugin)).thenReturn(Optional.of(this.container));
this.resetStatics();
}
Aggregations