use of com.tvd12.ezyfoxserver.app.EzyAppRequestController in project ezyfox-server by youngmonkeys.
the class EzySimpleApplicationTest method test.
@Test
public void test() {
EzySimpleApplication app = new EzySimpleApplication();
EzySimpleAppSetting setting = new EzySimpleAppSetting();
app.setSetting(setting);
// noinspection EqualsWithItself
assert app.equals(app);
assert !app.equals(new EzySimpleApplication());
EzyAppRequestController controller = mock(EzyAppRequestController.class);
app.setRequestController(controller);
assert app.getRequestController() == controller;
app.destroy();
app.destroy();
}
use of com.tvd12.ezyfoxserver.app.EzyAppRequestController in project ezyfox-server by youngmonkeys.
the class EzyUserRequestAppSingletonControllerTest method handleClientRequest.
private void handleClientRequest(EzyAppContext context) {
EzySimpleApplication app = (EzySimpleApplication) context.getApp();
EzyAppRequestController requestController = app.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
EzyUserRequestAppEvent event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("responseFactoryTest").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("hello2").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("hello6").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("c_hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNotSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("requestException").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
try {
data = EzyEntityFactory.newArrayBuilder().append("requestException2").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
} catch (Exception e) {
assert e.getCause().getClass() == Exception.class;
}
data = EzyEntityFactory.newArrayBuilder().append("requestException3").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
try {
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
}
use of com.tvd12.ezyfoxserver.app.EzyAppRequestController in project ezyfox-server by youngmonkeys.
the class EzySimpleAppEntryTest method handleClientRequest.
private void handleClientRequest(EzyAppContext context) {
EzySimpleApplication app = (EzySimpleApplication) context.getApp();
EzyAppRequestController requestController = app.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("chat").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
EzyUserRequestAppEvent event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("chat").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noUser").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noSession").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noDataBinding").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNoSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
try {
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
data = EzyEntityFactory.newArrayBuilder().append("app").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
}
use of com.tvd12.ezyfoxserver.app.EzyAppRequestController in project ezyfox-server by youngmonkeys.
the class EzySimpleAppEntry method setAppRequestController.
private void setAppRequestController(EzyAppContext appContext, EzyBeanContext beanContext) {
EzyAppSetup setup = appContext.get(EzyAppSetup.class);
EzyAppRequestController controller = newUserRequestController(beanContext);
setup.setRequestController(controller);
Set<String> commands = ((EzyCommandsAware) controller).getCommands();
appContext.setProperty(COMMANDS, commands);
}
use of com.tvd12.ezyfoxserver.app.EzyAppRequestController in project ezyfox-server by youngmonkeys.
the class EzyDefaultAppEntryTest method handleClientRequest.
private void handleClientRequest(EzyAppContext context) {
EzySimpleApplication app = (EzySimpleApplication) context.getApp();
EzyAppRequestController requestController = app.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("chat").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
EzyUserRequestAppEvent event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("chat").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noUser").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noSession").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noDataBinding").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNoSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
try {
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
data = EzyEntityFactory.newArrayBuilder().append("app").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
}
Aggregations