Search in sources :

Example 1 with EzyILoginError

use of com.tvd12.ezyfoxserver.constant.EzyILoginError in project ezyfox-server by youngmonkeys.

the class EzyLoginController method newLoginErrorResponse.

protected EzyResponse newLoginErrorResponse(EzyILoginError error) {
    EzyErrorParams params = new EzyErrorParams();
    params.setError(error);
    return new EzyLoginErrorResponse(params);
}
Also used : EzyErrorParams(com.tvd12.ezyfoxserver.response.EzyErrorParams) EzyLoginErrorResponse(com.tvd12.ezyfoxserver.response.EzyLoginErrorResponse)

Example 2 with EzyILoginError

use of com.tvd12.ezyfoxserver.constant.EzyILoginError in project ezyfox-server by youngmonkeys.

the class EzyLoginController method responseLoginError.

protected void responseLoginError(EzyServerContext ctx, EzySession session, EzyILoginError error) {
    EzyResponse response = newLoginErrorResponse(error);
    ctx.send(response, session, false);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse)

Example 3 with EzyILoginError

use of com.tvd12.ezyfoxserver.constant.EzyILoginError in project ezyfox-server by youngmonkeys.

the class EzyLoginControllerTest method testExceptionCase.

@SuppressWarnings("rawtypes")
@Test(expectedExceptions = IllegalStateException.class)
public void testExceptionCase() {
    EzyServerContext ctx = mock(EzyServerContext.class);
    doThrow(new IllegalStateException("server maintain")).when(ctx).send(any(EzyResponse.class), any(EzySession.class), any(boolean.class));
    EzyStatistics userStats = new EzySimpleStatistics();
    EzySimpleServer server = new EzySimpleServer();
    server.setStatistics(userStats);
    when(ctx.getServer()).thenReturn(server);
    server.setResponseApi(mock(EzyResponseApi.class));
    EzySessionManager sessionManager = mock(EzySessionManager.class);
    server.setSessionManager(sessionManager);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(ctx.getZoneContext("example")).thenReturn(zoneContext);
    EzySimpleZone zone = new EzySimpleZone();
    EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
    zone.setSetting(zoneSetting);
    when(zoneContext.getZone()).thenReturn(zone);
    EzyZoneUserManager zoneUserManager = EzyZoneUserManagerImpl.builder().maxUsers(1).build();
    zone.setUserManager(zoneUserManager);
    EzySession session = newSession();
    session.setToken("abcdef");
    EzyArray data = newLoginData();
    EzyLoginController controller = new EzyLoginController() {

        @Override
        protected void responseLoginError(EzyServerContext ctx, EzySession session, EzyILoginError error) {
        }
    };
    EzySimpleLoginRequest request = new EzySimpleLoginRequest();
    request.deserializeParams(data);
    request.setSession(session);
    controller.handle(ctx, request);
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyStatistics(com.tvd12.ezyfoxserver.statistics.EzyStatistics) EzySessionManager(com.tvd12.ezyfoxserver.wrapper.EzySessionManager) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzyLoginController(com.tvd12.ezyfoxserver.controller.EzyLoginController) EzyZoneUserManager(com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleLoginRequest(com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest) EzyILoginError(com.tvd12.ezyfoxserver.constant.EzyILoginError) EzySimpleStatistics(com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) Test(org.testng.annotations.Test)

Aggregations

EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)2 EzyArray (com.tvd12.ezyfox.entity.EzyArray)1 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)1 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)1 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)1 EzyILoginError (com.tvd12.ezyfoxserver.constant.EzyILoginError)1 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)1 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)1 EzyLoginController (com.tvd12.ezyfoxserver.controller.EzyLoginController)1 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)1 EzySimpleLoginRequest (com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest)1 EzyErrorParams (com.tvd12.ezyfoxserver.response.EzyErrorParams)1 EzyLoginErrorResponse (com.tvd12.ezyfoxserver.response.EzyLoginErrorResponse)1 EzySimpleZoneSetting (com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting)1 EzySimpleStatistics (com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics)1 EzyStatistics (com.tvd12.ezyfoxserver.statistics.EzyStatistics)1 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)1 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)1 Test (org.testng.annotations.Test)1