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);
}
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);
}
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);
}
Aggregations