@Test void TimerTest() throws DataClientException, DataServiceException, InterruptedException, KustoServiceError, IOException { Client clientMock = mock(Client.class); final ArrayList<Date> refreshTimestamps = new ArrayList<>(); when(clientMock.execute(Commands.IDENTITY_GET_COMMAND)) .thenReturn(generateIngestionAuthTokenResult()); when(clientMock.execute(Commands.INGESTION_RESOURCES_SHOW_COMMAND)).then((Answer) invocationOnMock -> { refreshTimestamps.add((new Date())); if(refreshTimestamps.size() != 1){ throw new Exception(); } return generateIngestionResourcesResult(); }); ResourceManager resourceManager = new ResourceManager(clientMock, 1000L,500L); Thread.sleep(100); assertEquals(1, refreshTimestamps.size()); Thread.sleep(1100); assertEquals(2, refreshTimestamps.size()); Thread.sleep(600); assertEquals(3, refreshTimestamps.size()); resourceManager.close(); }
@Override public void close() { timer.cancel(); timer.purge(); }
ResourceManager implements Closeable { @Override public void close() { timer.cancel(); timer.purge(); } }
ResourceManager implements Closeable { @Override public void close() { timer.cancel(); timer.purge(); } ResourceManager(Client client, long defaultRefreshTime, long refreshTimeOnFailure);   ResourceManager(Client client); }
ResourceManager implements Closeable { @Override public void close() { timer.cancel(); timer.purge(); } ResourceManager(Client client, long defaultRefreshTime, long refreshTimeOnFailure);   ResourceManager(Client client); @Override void close(); }
ResourceManager implements Closeable { @Override public void close() { timer.cancel(); timer.purge(); } ResourceManager(Client client, long defaultRefreshTime, long refreshTimeOnFailure);   ResourceManager(Client client); @Override void close();  }