use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzyZoneUserManagerImplTest method unmapSessionUserWithSessionCountGreaterThan1.
@Test
public void unmapSessionUserWithSessionCountGreaterThan1() {
// given
EzyZoneUserManagerImpl sut = newZoneUserManager();
EzySession session = mock(EzySession.class);
EzyUser user = mock(EzyUser.class);
when(user.getSessionCount()).thenReturn(1);
Map<EzySession, EzyUser> usersBySession = FieldUtil.getFieldValue(sut, "usersBySession");
usersBySession.put(session, user);
// when
sut.unmapSessionUser(session, mock(EzyConstant.class));
// then
Asserts.assertNull(sut.getUser(session));
}
use of com.tvd12.ezyfoxserver.entity.EzySession 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();
}
use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandlerTest method processRequestQueue0RemainTest.
@Test
public void processRequestQueue0RemainTest() {
// given
ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
EzySocketDataHandlerGroup handlerGroup = mock(EzySocketDataHandlerGroup.class);
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(handlerGroup);
EzySession session = spy(EzyAbstractSession.class);
when(session.isActivated()).thenReturn(Boolean.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);
sessionTicketsRequestQueues.addRequest(request);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
// when
handler.handleEvent();
// then
Asserts.assertEquals(sessionTicketsRequestQueues.getExtensionQueue().size(), 1);
}
use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandlerTest method handleGroupNullCaseTest.
@Test
public void handleGroupNullCaseTest() {
ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(null);
EzySession session = spy(EzyAbstractSession.class);
when(session.isActivated()).thenReturn(Boolean.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();
}
use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandlerTest method processRequestQueue0ExceptionCaseTest.
@Test
public void processRequestQueue0ExceptionCaseTest() {
ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenThrow(new IllegalArgumentException());
EzySession session = spy(EzyAbstractSession.class);
when(session.isActivated()).thenReturn(Boolean.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();
}
Aggregations