Search in sources :

Example 1 with EzyPluginSetup

use of com.tvd12.ezyfoxserver.command.EzyPluginSetup in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntryTest method notAllowRequestTest.

@Test
public void notAllowRequestTest() {
    // given
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyPluginSetup pluginSetup = mock(EzyPluginSetup.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzyPluginSetting pluginSetting = mock(EzyPluginSetting.class);
    when(plugin.getSetting()).thenReturn(pluginSetting);
    NotAllowRequestEntry sut = new NotAllowRequestEntry();
    // when
    when(pluginContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    when(zoneContext.getParent()).thenReturn(serverContext);
    when(pluginContext.get(EzyPluginSetup.class)).thenReturn(pluginSetup);
    sut.config(pluginContext);
    // then
    verify(pluginContext, times(0)).get(EzyPluginSetup.class);
}
Also used : EzyPluginSetup(com.tvd12.ezyfoxserver.command.EzyPluginSetup) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) Test(org.testng.annotations.Test)

Example 2 with EzyPluginSetup

use of com.tvd12.ezyfoxserver.command.EzyPluginSetup in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntry method setPluginRequestController.

private void setPluginRequestController(EzyPluginContext pluginContext, EzyBeanContext beanContext) {
    if (!allowRequest() || getClass().isAnnotationPresent(EzyDisallowRequest.class)) {
        return;
    }
    EzyPluginSetup setup = pluginContext.get(EzyPluginSetup.class);
    EzyPluginRequestController controller = newUserRequestController(beanContext);
    setup.setRequestController(controller);
    Set<String> commands = ((EzyCommandsAware) controller).getCommands();
    pluginContext.setProperty(COMMANDS, commands);
}
Also used : EzyPluginSetup(com.tvd12.ezyfoxserver.command.EzyPluginSetup) EzyCommandsAware(com.tvd12.ezyfoxserver.support.controller.EzyCommandsAware) EzyPluginRequestController(com.tvd12.ezyfoxserver.plugin.EzyPluginRequestController) EzyDisallowRequest(com.tvd12.ezyfoxserver.support.annotation.EzyDisallowRequest)

Example 3 with EzyPluginSetup

use of com.tvd12.ezyfoxserver.command.EzyPluginSetup in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntryTest method scanPackages.

@Test
public void scanPackages() {
    // given
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyPluginSetup pluginSetup = mock(EzyPluginSetup.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzyPluginSetting pluginSetting = mock(EzyPluginSetting.class);
    when(plugin.getSetting()).thenReturn(pluginSetting);
    InternalPluginEntry sut = new InternalPluginEntry();
    // when
    when(pluginContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    when(zoneContext.getParent()).thenReturn(serverContext);
    when(pluginContext.get(EzyPluginSetup.class)).thenReturn(pluginSetup);
    sut.config(pluginContext);
    // then
    EzyBeanContext beanContext = sut.beanContext;
    MongoConfig mongoConfig = (MongoConfig) beanContext.getBean(MongoConfig.class);
    Set<String> expectedPackages = Sets.newHashSet(EzySupportConstants.DEFAULT_PACKAGE_TO_SCAN, "com.tvd12.ezyfoxserver.support.v120.test.entry");
    Asserts.assertEquals(expectedPackages, mongoConfig.packagesToScan);
    Singleton singleton = (Singleton) beanContext.getBean(Singleton.class);
    Asserts.assertNotNull(singleton);
}
Also used : EzyPluginSetup(com.tvd12.ezyfoxserver.command.EzyPluginSetup) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzySingleton(com.tvd12.ezyfox.bean.annotation.EzySingleton) Test(org.testng.annotations.Test)

Example 4 with EzyPluginSetup

use of com.tvd12.ezyfoxserver.command.EzyPluginSetup in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntryTest method disallowRequestTest.

@Test
public void disallowRequestTest() {
    // given
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyPluginSetup pluginSetup = mock(EzyPluginSetup.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzyPluginSetting pluginSetting = mock(EzyPluginSetting.class);
    when(plugin.getSetting()).thenReturn(pluginSetting);
    DisAllowRequestEntry sut = new DisAllowRequestEntry();
    // when
    when(pluginContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    when(zoneContext.getParent()).thenReturn(serverContext);
    when(pluginContext.get(EzyPluginSetup.class)).thenReturn(pluginSetup);
    sut.config(pluginContext);
    // then
    verify(pluginContext, times(0)).get(EzyPluginSetup.class);
}
Also used : EzyPluginSetup(com.tvd12.ezyfoxserver.command.EzyPluginSetup) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) Test(org.testng.annotations.Test)

Aggregations

EzyPluginSetup (com.tvd12.ezyfoxserver.command.EzyPluginSetup)4 EzyPlugin (com.tvd12.ezyfoxserver.EzyPlugin)3 EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)3 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)3 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)3 EzyPluginSetting (com.tvd12.ezyfoxserver.setting.EzyPluginSetting)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 Test (org.testng.annotations.Test)3 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)1 EzySingleton (com.tvd12.ezyfox.bean.annotation.EzySingleton)1 EzyPluginRequestController (com.tvd12.ezyfoxserver.plugin.EzyPluginRequestController)1 EzyDisallowRequest (com.tvd12.ezyfoxserver.support.annotation.EzyDisallowRequest)1 EzyCommandsAware (com.tvd12.ezyfoxserver.support.controller.EzyCommandsAware)1