Search in sources :

Example 6 with EzySimpleSocketRequest

use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketRequest 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());
}
Also used : EzySocketRequest(com.tvd12.ezyfoxserver.socket.EzySocketRequest) EzySessionTicketsRequestQueues(com.tvd12.ezyfoxserver.socket.EzySessionTicketsRequestQueues) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleSocketRequest(com.tvd12.ezyfoxserver.socket.EzySimpleSocketRequest) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyRequestQueue(com.tvd12.ezyfoxserver.socket.EzyRequestQueue) Test(org.testng.annotations.Test)

Example 7 with EzySimpleSocketRequest

use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketRequest in project ezyfox-server by youngmonkeys.

the class EzySimpleSocketRequestTest method test.

@Test
public void test() {
    EzyAbstractSession session = spy(EzyAbstractSession.class);
    EzyArray data = EzyEntityFactory.newArrayBuilder().append(EzyCommand.APP_ACCESS.getId()).build();
    EzySimpleSocketRequest request = new EzySimpleSocketRequest(session, data);
    assert request.isSystemRequest();
}
Also used : EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleSocketRequest(com.tvd12.ezyfoxserver.socket.EzySimpleSocketRequest) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

EzyArray (com.tvd12.ezyfox.entity.EzyArray)7 Test (org.testng.annotations.Test)7 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)6 EzySimpleSocketRequest (com.tvd12.ezyfoxserver.socket.EzySimpleSocketRequest)3 EzyRequestQueue (com.tvd12.ezyfoxserver.socket.EzyRequestQueue)2 EzySessionTicketsRequestQueues (com.tvd12.ezyfoxserver.socket.EzySessionTicketsRequestQueues)2 EzySocketRequest (com.tvd12.ezyfoxserver.socket.EzySocketRequest)2 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)1 BaseTest (com.tvd12.test.base.BaseTest)1