use of com.tvd12.ezyfox.entity.EzyArray 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.ezyfox.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyAbstractArrayResponse method getResponseData.
@Override
protected EzyData getResponseData() {
EzyArray array = data != null ? marshaller.marshal(data) : newArrayBuilder().build();
if (additionalParams != null) {
for (Object object : additionalParams) {
Object value = marshaller.marshal(object);
array.add(value);
}
}
return array;
}
use of com.tvd12.ezyfox.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyDefaultPluginEntryTest method handleClientRequest.
private void handleClientRequest(EzyPluginContext context) {
EzySimplePlugin plugin = (EzySimplePlugin) context.getPlugin();
EzyPluginRequestController requestController = plugin.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("chat").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
EzyUserRequestPluginEvent event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("chat").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noUser").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noSession").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noDataBinding").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNoSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
try {
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
data = EzyEntityFactory.newArrayBuilder().append("plugin").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
}
use of com.tvd12.ezyfox.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzySessionTicketsRequestQueuesTest method addSystemRequest.
@Test
public void addSystemRequest() {
// given
EzySession session = mock(EzySession.class);
EzyArray data = EzyEntityArrays.newArray(EzyCommand.APP_ACCESS.getId(), EzyEmptyObject.getInstance());
EzySocketRequest socketRequest = new EzySimpleSocketRequest(session, data);
EzyRequestQueue queue = mock(EzyRequestQueue.class);
when(queue.isEmpty()).thenReturn(false);
when(queue.add(socketRequest)).thenReturn(false);
when(session.getSystemRequestQueue()).thenReturn(queue);
EzySessionTicketsRequestQueues sut = new EzySessionTicketsRequestQueues();
// when
boolean result = sut.addRequest(socketRequest);
// then
Asserts.assertFalse(result);
Asserts.assertTrue(sut.getSystemQueue().isEmpty());
}
use of com.tvd12.ezyfox.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzySessionTicketsRequestQueuesTest method addSystemRequestWithEmptyQueue.
@Test
public void addSystemRequestWithEmptyQueue() {
// given
EzySession session = mock(EzySession.class);
EzyArray data = EzyEntityArrays.newArray(EzyCommand.APP_ACCESS.getId(), EzyEmptyObject.getInstance());
EzySocketRequest socketRequest = new EzySimpleSocketRequest(session, data);
EzyRequestQueue queue = mock(EzyRequestQueue.class);
when(queue.isEmpty()).thenReturn(true);
when(session.getSystemRequestQueue()).thenReturn(queue);
EzySessionTicketsRequestQueues sut = new EzySessionTicketsRequestQueues();
// when
boolean result = sut.addRequest(socketRequest);
// then
Asserts.assertFalse(result);
Asserts.assertTrue(sut.getSystemQueue().isEmpty());
}
Aggregations