Search in sources :

Example 6 with EzyPlugin

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

the class EzyRequestPluginController method handle.

@Override
public void handle(EzyServerContext ctx, EzyRequestPluginRequest request) {
    EzyRequestPluginParams params = request.getParams();
    EzyUser user = request.getUser();
    EzyZoneContext zoneCtx = ctx.getZoneContext(user.getZoneId());
    EzyPluginContext pluginCtx = getPluginContext(zoneCtx, params);
    EzyPlugin plugin = pluginCtx.getPlugin();
    EzyPluginRequestController requestController = plugin.getRequestController();
    EzyUserRequestPluginEvent event = newRequestPluginEvent(request);
    requestController.handle(pluginCtx, event);
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyPluginRequestController(com.tvd12.ezyfoxserver.plugin.EzyPluginRequestController) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyRequestPluginParams(com.tvd12.ezyfoxserver.request.EzyRequestPluginParams) EzyUserRequestPluginEvent(com.tvd12.ezyfoxserver.event.EzyUserRequestPluginEvent)

Example 7 with EzyPlugin

use of com.tvd12.ezyfoxserver.EzyPlugin 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 8 with EzyPlugin

use of com.tvd12.ezyfoxserver.EzyPlugin 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

EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)8 EzyPlugin (com.tvd12.ezyfoxserver.EzyPlugin)7 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)7 Test (org.testng.annotations.Test)6 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)5 EzyPluginSetup (com.tvd12.ezyfoxserver.command.EzyPluginSetup)3 EzyPluginSetting (com.tvd12.ezyfoxserver.setting.EzyPluginSetting)3 BaseTest (com.tvd12.test.base.BaseTest)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)2 EzyPluginRequestController (com.tvd12.ezyfoxserver.plugin.EzyPluginRequestController)2 EzySimplePluginSetting (com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting)2 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)1 EzySingleton (com.tvd12.ezyfox.bean.annotation.EzySingleton)1 EzyArray (com.tvd12.ezyfox.entity.EzyArray)1 EzyObject (com.tvd12.ezyfox.entity.EzyObject)1 EzyZone (com.tvd12.ezyfoxserver.EzyZone)1 EzyBroadcastPluginsEventImpl (com.tvd12.ezyfoxserver.command.impl.EzyBroadcastPluginsEventImpl)1 EzyPluginSendResponseImpl (com.tvd12.ezyfoxserver.command.impl.EzyPluginSendResponseImpl)1 EzyRequestPluginController (com.tvd12.ezyfoxserver.controller.EzyRequestPluginController)1