@Test public void testRun() { WorldClient worldClient = mock(WorldClient.class); Actor clientPlayer = mock(Actor.class); World world = mock(World.class); WorldObjectList worldObjectMap = new WorldObjectList(world); when(world.getWorldObjects()).thenReturn(worldObjectMap); when(worldClient.getWorld()).thenReturn(world); when(worldClient.getPlayer()).thenReturn(clientPlayer); WorldClientUpdater worldClientUpdater = new WorldClientUpdater(worldClient); int rand = (int) (Math.random() * 100); for (int i = 0; i < rand; i++) { worldClientUpdater.run(); } verify(world, times(rand)).update(); }
@Override public void run() { worldClient.getWorld().update(); if (player != null) { EventStack eventStack = player.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; List<MoveState> newStates = stateChangeStack.getStateChanges(); while (!newStates.isEmpty()) { MoveState moveState = newStates.remove(0); WorldClientMessageFactory messageFactory = worldClient.getMessageFactory(); Message stateChangeRequest = messageFactory.generateStateChangeRequest(moveState); worldClient.getMessageIO().queueOutgoingMessage(stateChangeRequest); } } } }
WorldClientUpdater implements Runnable { @Override public void run() { worldClient.getWorld().update(); if (player != null) { EventStack eventStack = player.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; List<MoveState> newStates = stateChangeStack.getStateChanges(); while (!newStates.isEmpty()) { MoveState moveState = newStates.remove(0); WorldClientMessageFactory messageFactory = worldClient.getMessageFactory(); Message stateChangeRequest = messageFactory.generateStateChangeRequest(moveState); worldClient.getMessageIO().queueOutgoingMessage(stateChangeRequest); } } } } }
WorldClientUpdater implements Runnable { @Override public void run() { worldClient.getWorld().update(); if (player != null) { EventStack eventStack = player.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; List<MoveState> newStates = stateChangeStack.getStateChanges(); while (!newStates.isEmpty()) { MoveState moveState = newStates.remove(0); WorldClientMessageFactory messageFactory = worldClient.getMessageFactory(); Message stateChangeRequest = messageFactory.generateStateChangeRequest(moveState); worldClient.getMessageIO().queueOutgoingMessage(stateChangeRequest); } } } } WorldClientUpdater(WorldClient wc); }
WorldClientUpdater implements Runnable { @Override public void run() { worldClient.getWorld().update(); if (player != null) { EventStack eventStack = player.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; List<MoveState> newStates = stateChangeStack.getStateChanges(); while (!newStates.isEmpty()) { MoveState moveState = newStates.remove(0); WorldClientMessageFactory messageFactory = worldClient.getMessageFactory(); Message stateChangeRequest = messageFactory.generateStateChangeRequest(moveState); worldClient.getMessageIO().queueOutgoingMessage(stateChangeRequest); } } } } WorldClientUpdater(WorldClient wc); @Override void run(); }
WorldClientUpdater implements Runnable { @Override public void run() { worldClient.getWorld().update(); if (player != null) { EventStack eventStack = player.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; List<MoveState> newStates = stateChangeStack.getStateChanges(); while (!newStates.isEmpty()) { MoveState moveState = newStates.remove(0); WorldClientMessageFactory messageFactory = worldClient.getMessageFactory(); Message stateChangeRequest = messageFactory.generateStateChangeRequest(moveState); worldClient.getMessageIO().queueOutgoingMessage(stateChangeRequest); } } } } WorldClientUpdater(WorldClient wc); @Override void run();  }