use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server by youngmonkeys.
the class HelloController2 method greet.
@EzyDoHandle("Hello")
public void greet(GreetRequest request, EzyUser user, EzySession session) {
GreetResponse response = new GreetResponse("Hello " + request.getWho() + "!");
System.out.println("HelloController::Big/Hello response: " + response);
}
use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server by youngmonkeys.
the class EzyRequestAppEventImplTest method test.
@Test
public void test() {
EzyUser user = newUser();
EzyArray data = newArrayBuilder().append(100).build();
EzyUserRequestAppEvent event = new EzySimpleUserRequestAppEvent(user, null, data);
assert event.getData() == data;
assert event.getUser() == user;
}
use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server-android-client by youngmonkeys.
the class EzyLoginSuccessHandler method handle.
@Override
public void handle(EzyArray data) {
EzyData responseData = data.get(4, EzyData.class);
EzyUser user = newUser(data);
EzyZone zone = newZone(data);
((EzyMeAware) client).setMe(user);
((EzyZoneAware) client).setZone(zone);
handleLoginSuccess(responseData);
EzyLogger.debug("user: " + user + " logged in successfully");
}
use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server-android-client by youngmonkeys.
the class EzyLoginSuccessHandler method newUser.
protected EzyUser newUser(EzyArray data) {
long userId = data.get(2, long.class);
String username = data.get(3, String.class);
EzySimpleUser user = new EzySimpleUser(userId, username);
return user;
}
use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server by youngmonkeys.
the class EzyLoginProcessorTest method processUserSessionsButNotAllowToChangeSession.
@SuppressWarnings("rawtypes")
@Test
public void processUserSessionsButNotAllowToChangeSession() {
// given
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
zoneSetting.getUserManagement().setMaxSessionPerUser(1);
zoneSetting.getUserManagement().setAllowChangeSession(false);
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(zoneContext.getZone()).thenReturn(zone);
EzySimpleServer server = new EzySimpleServer();
EzySessionManager sessionManager = mock(EzySessionManager.class);
server.setSessionManager(sessionManager);
EzyZoneUserManager userManager = EzyZoneUserManagerImpl.builder().build();
EzyUser user = mock(EzyUser.class);
when(user.getName()).thenReturn("monkey");
when(user.getSessionCount()).thenReturn(1);
userManager.addUser(user);
zone.setUserManager(userManager);
EzyStatistics statistics = mock(EzyStatistics.class);
EzyUserStatistics userStatistics = mock(EzyUserStatistics.class);
when(statistics.getUserStats()).thenReturn(userStatistics);
server.setStatistics(statistics);
EzyServerContext serverContext = mock(EzyServerContext.class);
when(serverContext.getServer()).thenReturn(server);
EzyLoginProcessor sut = new EzyLoginProcessor(serverContext);
EzySessionDelegate sessionDelegate = mock(EzySessionDelegate.class);
EzyAbstractSession session = spy(EzyAbstractSession.class);
session.setDelegate(sessionDelegate);
EzyUserLoginEvent event = mock(EzyUserLoginEvent.class);
when(event.getUsername()).thenReturn("monkey");
when(event.getSession()).thenReturn(session);
// when
Throwable e = Asserts.assertThrows(() -> sut.apply(zoneContext, event));
// then
Asserts.assertEquals(EzyLoginErrorException.class, e.getClass());
}
Aggregations