@Test public void testWork() throws Exception { TimeoutTimer ticker = getField(tactic, "ticker"); double timeout = getField(ticker, "timeout"); verify(tacticMock, times(0)).calculateTactics(); ticker.reset(); tactic.work(); verify(tacticMock, times(0)).calculateTactics(); TestUtils.setField(ticker, "lastTime", System.currentTimeMillis() - (long) timeout - 1L); tactic.work(); verify(tacticMock, times(1)).calculateTactics(); }
@Override protected final void work() throws InterruptedException { if (ticker.timeIsExceeded()) { ticker.reset(); Thread t = new Thread(this::calculateTactics); t.start(); workTimoutTimer.reset(); while (t.isAlive()) { if (workTimoutTimer.timeIsExceeded()) { t.interrupt(); } } } }
Tactic extends ManagedThread implements Subscriber { @Override protected final void work() throws InterruptedException { if (ticker.timeIsExceeded()) { ticker.reset(); Thread t = new Thread(this::calculateTactics); t.start(); workTimoutTimer.reset(); while (t.isAlive()) { if (workTimoutTimer.timeIsExceeded()) { t.interrupt(); } } } } }
Tactic extends ManagedThread implements Subscriber { @Override protected final void work() throws InterruptedException { if (ticker.timeIsExceeded()) { ticker.reset(); Thread t = new Thread(this::calculateTactics); t.start(); workTimoutTimer.reset(); while (t.isAlive()) { if (workTimoutTimer.timeIsExceeded()) { t.interrupt(); } } } }  }
Tactic extends ManagedThread implements Subscriber { @Override protected final void work() throws InterruptedException { if (ticker.timeIsExceeded()) { ticker.reset(); Thread t = new Thread(this::calculateTactics); t.start(); workTimoutTimer.reset(); while (t.isAlive()) { if (workTimoutTimer.timeIsExceeded()) { t.interrupt(); } } } }  Radar getRadar(); GPS getGps(); Engine getEngine(); Gun getGun(); Radio getRadio(); final void startTactic(); final void stopTactic(); @Override @Deprecated final void destroy(); @Override void receive(Object msg, MultipartCallbacks multipartCallbacks); final String getIdentifier(); final Set<String> getAvailableComponents(); }
Tactic extends ManagedThread implements Subscriber { @Override protected final void work() throws InterruptedException { if (ticker.timeIsExceeded()) { ticker.reset(); Thread t = new Thread(this::calculateTactics); t.start(); workTimoutTimer.reset(); while (t.isAlive()) { if (workTimoutTimer.timeIsExceeded()) { t.interrupt(); } } } }  Radar getRadar(); GPS getGps(); Engine getEngine(); Gun getGun(); Radio getRadio(); final void startTactic(); final void stopTactic(); @Override @Deprecated final void destroy(); @Override void receive(Object msg, MultipartCallbacks multipartCallbacks); final String getIdentifier(); final Set<String> getAvailableComponents();  }