Search in sources :

Example 1 with EzyBroadcastEventImpl

use of com.tvd12.ezyfoxserver.command.impl.EzyBroadcastEventImpl in project ezyfox-server by youngmonkeys.

the class EzyBroadcastEventImplTest method test.

@Test
public void test() {
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyZoneContext zoneContext1 = mock(EzyZoneContext.class);
    EzyZoneContext zoneContext2 = mock(EzyZoneContext.class);
    doThrow(new IllegalStateException()).when(zoneContext2).handleEvent(any(), any());
    when(serverContext.getZoneContexts()).thenReturn(Lists.newArrayList(zoneContext1, zoneContext2));
    EzyBroadcastEventImpl cmd = new EzyBroadcastEventImpl(serverContext);
    EzyServerInitializingEvent event = new EzySimpleServerInitializingEvent();
    cmd.fire(EzyEventType.SERVER_INITIALIZING, event, true);
    try {
        cmd.fire(EzyEventType.SERVER_INITIALIZING, event, false);
    } catch (Exception e) {
        assert e instanceof IllegalStateException;
    }
}
Also used : EzySimpleServerInitializingEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerInitializingEvent) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyServerInitializingEvent(com.tvd12.ezyfoxserver.event.EzyServerInitializingEvent) EzyBroadcastEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyBroadcastEventImpl) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

EzyBroadcastEventImpl (com.tvd12.ezyfoxserver.command.impl.EzyBroadcastEventImpl)1 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)1 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)1 EzyServerInitializingEvent (com.tvd12.ezyfoxserver.event.EzyServerInitializingEvent)1 EzySimpleServerInitializingEvent (com.tvd12.ezyfoxserver.event.EzySimpleServerInitializingEvent)1 BaseTest (com.tvd12.test.base.BaseTest)1 Test (org.testng.annotations.Test)1