use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyPluginInfoControllerTest method test.
@Test
public void test() {
EzyPluginInfoController controller = new EzyPluginInfoController();
EzyServerContext serverContext = mock(EzyServerContext.class);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
EzySimplePluginInfoRequest request = new EzySimplePluginInfoRequest();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
user.setZoneId(1);
request.setSession(session);
request.setUser(user);
EzyArray data = EzyEntityFactory.newArrayBuilder().append("test").build();
request.deserializeParams(data);
controller.handle(serverContext, request);
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
EzySimplePlugin plugin = new EzySimplePlugin();
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
plugin.setSetting(pluginSetting);
when(pluginContext.getPlugin()).thenReturn(plugin);
when(zoneContext.getPluginContext("test")).thenReturn(pluginContext);
controller.handle(serverContext, request);
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyRequestAppControllerTest method testHasNotAccessed.
@Test
public void testHasNotAccessed() {
EzyArray data = EzyEntityArrays.newArray(1, EzyEntityArrays.newArray());
EzyRequestAppController controller = new EzyRequestAppController();
MyTestUser user = new MyTestUser();
user.setName("dungtv1");
user.addSession(session);
EzySimpleRequestAppRequest request = new EzySimpleRequestAppRequest();
request.deserializeParams(data);
request.setUser(user);
request.setSession(session);
EzyServerContext ctx = newServerContext();
controller.handle(ctx, request);
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyRequestAppControllerTest method test.
@Test
public void test() {
EzyArray data = EzyEntityArrays.newArray(1, EzyEntityArrays.newArray());
EzyRequestAppController controller = new EzyRequestAppController();
EzySimpleRequestAppRequest request = new EzySimpleRequestAppRequest();
request.deserializeParams(data);
request.setUser(user);
request.setSession(session);
EzyServerContext ctx = newServerContext();
controller.handle(ctx, request);
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyAbstractHandlerGroupTest method handleReceivedDataNotSuccess.
@Test
public void handleReceivedDataNotSuccess() throws Exception {
// given
ExHandlerGroup sut = newHandlerGroup();
EzySession session = FieldUtil.getFieldValue(sut, "session");
when(session.addReceivedRequests(1)).thenReturn(false);
when(session.isActivated()).thenReturn(true);
EzySessionTicketsRequestQueues sessionTicketsRequestQueues = FieldUtil.getFieldValue(sut, "sessionTicketsRequestQueues");
EzyArray data = EzyEntityFactory.newArrayBuilder().append(EzyCommand.APP_ACCESS.getId()).append(EzyEntityFactory.newArray()).build();
// when
MethodInvoker.create().object(sut).method("handleReceivedData").param(Object.class, data).param(int.class, 100).call();
// then
verify(sessionTicketsRequestQueues, times(1)).addRequest(any());
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandlerTest method test.
@Test
public void test() {
ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
EzySocketDataHandlerGroup handlerGroup = mock(EzySocketDataHandlerGroup.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(handlerGroup);
EzySession session = spy(EzyAbstractSession.class);
session.setActivated(true);
EzyRequestQueue requestQueue = new EzyNonBlockingRequestQueue();
when(session.getExtensionRequestQueue()).thenReturn(requestQueue);
EzyArray array = EzyEntityFactory.newArrayBuilder().append(10).build();
EzySocketRequest request = new EzySimpleSocketRequest(session, array);
EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
handler.setSessionTicketsQueue(sessionTicketsRequestQueues.getExtensionQueue());
sessionTicketsRequestQueues.addRequest(request);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
handler.handleEvent();
handler.destroy();
}
Aggregations