@Test protected void testPauseTimer() { List<Timer> returnedTimers = createTimers(3, true); when(this.timerStorage.getAll()).thenReturn(returnedTimers); when(this.env.getCurrentDateTime()).thenReturn(ZonedDateTime.of(2018, 2, 1, 4, 21, 55, 987, ZoneId.of("Z"))); Timer t2 = new Timer(3, LocalDateTime.of(2018, 9, 5, 12, 20, 0), null, false); assertThat(this.tlogic.pauseTimer(returnedTimers.get(2)).toString(), is(t2.toString())); }
public Timer pauseTimer(Timer timer) { if (timer.isActive()) { this.timerbeep.stopBeep(timer); timer.setActive(false); LocalDateTime current = LocalDateTime.now(); LocalDateTime future = timer.getTimerTime(); timer.duration(Duration.ofMillis(current.until(future, ChronoUnit.MILLIS))); this.timerStorage.save(timer); return timer; } throw new IllegalArgumentException("Timer is already inactive"); }
TimerLogic implements RunnableService { public Timer pauseTimer(Timer timer) { if (timer.isActive()) { this.timerbeep.stopBeep(timer); timer.setActive(false); LocalDateTime current = LocalDateTime.now(); LocalDateTime future = timer.getTimerTime(); timer.duration(Duration.ofMillis(current.until(future, ChronoUnit.MILLIS))); this.timerStorage.save(timer); return timer; } throw new IllegalArgumentException("Timer is already inactive"); } }
TimerLogic implements RunnableService { public Timer pauseTimer(Timer timer) { if (timer.isActive()) { this.timerbeep.stopBeep(timer); timer.setActive(false); LocalDateTime current = LocalDateTime.now(); LocalDateTime future = timer.getTimerTime(); timer.duration(Duration.ofMillis(current.until(future, ChronoUnit.MILLIS))); this.timerStorage.save(timer); return timer; } throw new IllegalArgumentException("Timer is already inactive"); }  }
TimerLogic implements RunnableService { public Timer pauseTimer(Timer timer) { if (timer.isActive()) { this.timerbeep.stopBeep(timer); timer.setActive(false); LocalDateTime current = LocalDateTime.now(); LocalDateTime future = timer.getTimerTime(); timer.duration(Duration.ofMillis(current.until(future, ChronoUnit.MILLIS))); this.timerStorage.save(timer); return timer; } throw new IllegalArgumentException("Timer is already inactive"); }  Runnable createTimerRunnable(Timer timer); Timer setTimer(LocalDateTime timerTime); int searchTimerId(); String deleteAllTimers(); String deleteTimer(int timerNumber); String stopRinging(); Timer getTimer(int timerNumber); List<Timer> getAllTimers(); Timer pauseTimer(Timer timer); Timer reactivateTimer(Timer timer); @Override void start(); @Override void stop(); }
TimerLogic implements RunnableService { public Timer pauseTimer(Timer timer) { if (timer.isActive()) { this.timerbeep.stopBeep(timer); timer.setActive(false); LocalDateTime current = LocalDateTime.now(); LocalDateTime future = timer.getTimerTime(); timer.duration(Duration.ofMillis(current.until(future, ChronoUnit.MILLIS))); this.timerStorage.save(timer); return timer; } throw new IllegalArgumentException("Timer is already inactive"); }  Runnable createTimerRunnable(Timer timer); Timer setTimer(LocalDateTime timerTime); int searchTimerId(); String deleteAllTimers(); String deleteTimer(int timerNumber); String stopRinging(); Timer getTimer(int timerNumber); List<Timer> getAllTimers(); Timer pauseTimer(Timer timer); Timer reactivateTimer(Timer timer); @Override void start(); @Override void stop();  }