use of com.tvd12.ezyfoxserver.delegate.EzySimpleAppUserDelegate in project ezyfox-server by youngmonkeys.
the class EzyAccessAppControllerTest method accessAppSuccessfully.
@Test
public void accessAppSuccessfully() {
// given
EzyServerContext serverContext = mock(EzyServerContext.class);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
EzyAppContext appContext = mock(EzyAppContext.class);
EzyApplication app = mock(EzyApplication.class);
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("test");
when(app.getSetting()).thenReturn(appSetting);
when(appContext.getApp()).thenReturn(app);
EzySimpleAppUserDelegate userDelegate = new EzySimpleAppUserDelegate();
userDelegate.setAppContext(appContext);
EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().appName("test").userDelegate(userDelegate).build();
when(app.getUserManager()).thenReturn(appUserManager);
when(zoneContext.getAppContext("test")).thenReturn(appContext);
EzySimpleAccessAppRequest request = newRequest(1);
EzyAccessAppController underTest = new EzyAccessAppController();
// when
underTest.handle(serverContext, request);
// then
verify(appContext, times(1)).handleEvent(eq(EzyEventType.USER_ACCESS_APP), any(EzySimpleUserAccessAppEvent.class));
verify(appContext, times(1)).handleEvent(eq(EzyEventType.USER_ACCESSED_APP), any(EzySimpleUserAccessedAppEvent.class));
verify(serverContext, times(1)).getZoneContext(1);
verify(zoneContext, times(1)).getAppContext("test");
verify(appContext, times(1)).getApp();
verify(app, times(1)).getSetting();
verify(app, times(1)).getUserManager();
verify(serverContext, times(1)).send(any(EzyResponse.class), any(EzySession.class), any(boolean.class));
}
use of com.tvd12.ezyfoxserver.delegate.EzySimpleAppUserDelegate in project ezyfox-server by youngmonkeys.
the class EzySimpleServerContextBuilder method newAppContext.
protected EzyAppContext newAppContext(EzyZoneContext parent, EzyAppSetting setting) {
EzySimpleAppUserDelegate userDelegate = new EzySimpleAppUserDelegate();
EzyAppUserManager appUserManager = newAppUserManager(setting, userDelegate);
EzyEventControllers eventControllers = newEventControllers();
EzySimpleApplication app = new EzySimpleApplication();
app.setSetting(setting);
app.setUserManager(appUserManager);
app.setEventControllers(eventControllers);
ScheduledExecutorService appExecutorService = newAppExecutorService(setting);
EzySimpleAppContext appContext = new EzySimpleAppContext();
userDelegate.setAppContext(appContext);
appContext.setApp(app);
appContext.setParent(parent);
appContext.setExecutorService(appExecutorService);
appContext.init();
return appContext;
}
Aggregations