ToRunQueuedCommand { public boolean canExecute(IBuycraftPlatform platform) { Integer requiredSlots = command.getConditions().get("slots"); if (requiredSlots != null || requireOnline) { if (!platform.isPlayerOnline(player)) { return false; } } if (requiredSlots != null) { int free = platform.getFreeSlots(player); if (free < requiredSlots) { return false; } } Integer delay = command.getConditions().get("delay"); return !(delay != null && delay > 0 && System.currentTimeMillis() - queueTime < TimeUnit.SECONDS.toMillis(delay)); } ToRunQueuedCommand(final QueuedPlayer player, final QueuedCommand command, final boolean requireOnline); boolean canExecute(IBuycraftPlatform platform); QueuedPlayer getPlayer(); QueuedCommand getCommand(); boolean isRequireOnline(); long getQueueTime(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void canExecuteInstant() throws Exception { assertTrue("Command that can run instantly is not being run", forOffline(TEST_INSTANT_COMMAND).canExecute(platform)); }
@Test public void canExecuteDenyOffline() throws Exception { assertFalse("Command that requires online player is being run", forOnline(TEST_REQUIRE_ONLINE_COMMAND).canExecute(platform)); }
@Test public void canExecuteAllowOnline() throws Exception { platform.getTestPlayerMap().put("TestOnline", new TestPlayer(0)); assertTrue("Command with online player is not being run", forOnline(TEST_REQUIRE_ONLINE_COMMAND).canExecute(platform)); }