### Question:
BeekeeperSchedulerApiary implements ApplicationContextAware { @VisibleForTesting public static void stop() { if (context == null) { throw new RuntimeException("Application context has not been started."); } if (runner == null) { throw new RuntimeException("Application runner has not been started."); } runner.destroy(); context.close(); }  static void main(String[] args); @VisibleForTesting static boolean isRunning(); @VisibleForTesting static void stop(); @VisibleForTesting static MeterRegistry meterRegistry(); @VisibleForTesting static void resetStaticContext(); @Override void setApplicationContext(ApplicationContext applicationContext);  }### Answer:
@Test public void typicalStop() { setupContextMock(true, true, true); BeekeeperSchedulerApiary.stop(); verify(runnerMock).destroy(); verify(contextMock).close(); }
@Test public void stopExceptionThrownWhenRunnerIsNull() { setupContextMock(true, true, false); Exception exception = assertThrows(RuntimeException.class, () -> BeekeeperSchedulerApiary.stop()); assertThat(exception.getMessage()).isEqualTo("Application runner has not been started."); }
@Test public void stopExceptionThrownWhenContextIsNull() { Exception exception = assertThrows(RuntimeException.class, () -> BeekeeperSchedulerApiary.stop()); assertThat(exception.getMessage()).isEqualTo("Application context has not been started."); }