use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.
the class EzyUserRequestAppSingletonControllerTest method test.
@Test
public void test() throws Exception {
EzyRequestHandlerImplementer.setDebug(true);
EzyExceptionHandlerImplementer.setDebug(true);
EzySimpleSettings settings = new EzySimpleSettings();
EzySimpleServer server = new EzySimpleServer();
server.setSettings(settings);
EzySimpleServerContext serverContext = new EzySimpleServerContext();
serverContext.setServer(server);
serverContext.init();
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
EzySimpleZoneContext zoneContext = new EzySimpleZoneContext();
zoneContext.setZone(zone);
zoneContext.init();
zoneContext.setParent(serverContext);
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("test");
EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().build();
EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
EzySimpleApplication application = new EzySimpleApplication();
application.setSetting(appSetting);
application.setUserManager(appUserManager);
application.setEventControllers(eventControllers);
ScheduledExecutorService appScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setApp(application);
appContext.setParent(zoneContext);
appContext.setExecutorService(appScheduledExecutorService);
appContext.init();
EzySimpleAppEntry entry = new EzyAppEntryEx();
entry.config(appContext);
entry.start();
handleClientRequest(appContext);
EzyBeanContext beanContext = appContext.get(EzyBeanContext.class);
EzyRequestCommandManager requestCommandManager = beanContext.getSingleton(EzyRequestCommandManager.class);
EzyFeatureCommandManager featureCommandManager = beanContext.getSingleton(EzyFeatureCommandManager.class);
Asserts.assertTrue(requestCommandManager.containsCommand("v1.2.2/hello"));
Asserts.assertTrue(requestCommandManager.containsCommand("v122/listener/hello"));
Asserts.assertTrue(requestCommandManager.isManagementCommand("v1.2.2/hello"));
Asserts.assertTrue(requestCommandManager.isPaymentCommand("v1.2.2/hello"));
Asserts.assertEquals(featureCommandManager.getFeatureByCommand("v1.2.2/hello"), "hello.world");
entry.destroy();
}
use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlersImplementerTest method testImplementDuplicateCommandButAllowOverride.
@Test
public void testImplementDuplicateCommandButAllowOverride() {
EzyRequestHandlerImplementer.setDebug(true);
EzyRequestHandlersImplementer implementer = new EzyRequestHandlersImplementer();
EzyFeatureCommandManager featureCommandManager = new EzyFeatureCommandManager();
EzyRequestCommandManager requestCommandManager = new EzyRequestCommandManager();
implementer.setFeatureCommandManager(featureCommandManager);
implementer.setRequestCommandManager(requestCommandManager);
implementer.setAllowOverrideCommand(true);
implementer.implement(Arrays.asList(new HelloController(), new HelloController()));
}
use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlersImplementerTest method testImplementFailedCase3.
@Test(expectedExceptions = EzyDuplicateRequestHandlerException.class)
public void testImplementFailedCase3() {
EzyRequestHandlerImplementer.setDebug(true);
EzyRequestHandlersImplementer implementer = new EzyRequestHandlersImplementer();
EzyFeatureCommandManager featureCommandManager = new EzyFeatureCommandManager();
EzyRequestCommandManager requestCommandManager = new EzyRequestCommandManager();
implementer.setFeatureCommandManager(featureCommandManager);
implementer.setRequestCommandManager(requestCommandManager);
implementer.implement(Arrays.asList(new HelloController(), new HelloController()));
}
use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.
the class EzyRequestCommandManagerTest method test.
@Test
public void test() {
// given
EzyRequestCommandManager sut = new EzyRequestCommandManager();
sut.addCommand("a");
sut.addPaymentCommand("d");
sut.addManagementCommand("e");
// when
// then
Asserts.assertTrue(sut.containsCommand("a"));
Asserts.assertEquals(sut.getCommands(), Collections.singletonList("a"), false);
Assert.assertTrue(sut.isPaymentCommand("d"));
Asserts.assertEquals(sut.getPaymentCommands(), Collections.singletonList("d"), false);
Assert.assertTrue(sut.isManagementCommand("e"));
Asserts.assertEquals(sut.getManagementCommands(), Collections.singletonList("e"), false);
sut.destroy();
}
Aggregations