DBVariablesCheck extends AbstractCrossDcIntervalCheck { protected void refreshInterestedDataSources() { Set<String> checkDataSources = consoleConfig.getVariablesCheckDataSources(); List<String> toRemove = new ArrayList<>(); interestedDataSources.forEach(datasourceName -> { if (!checkDataSources.contains(datasourceName)) toRemove.add(datasourceName); }); interestedDataSources.addAll(checkDataSources); toRemove.forEach(datasourceName -> { interestedDataSources.remove(datasourceName); DatabaseVariablesCheck check = databaseVariablesCheckMap.remove(datasourceName); if (null != check) check.release(); }); }  @PostConstruct @Override void postConstruct();  }
@Test public void testRefreshInterestedDataSources() { Assert.assertEquals(0, dbVariablesCheck.getInterestedDataSources().size()); dbVariablesCheck.refreshInterestedDataSources(); Assert.assertEquals(1, dbVariablesCheck.getInterestedDataSources().size()); Mockito.when(consoleConfig.getVariablesCheckDataSources()).thenReturn(Collections.emptySet()); dbVariablesCheck.refreshInterestedDataSources(); Assert.assertEquals(0, dbVariablesCheck.getInterestedDataSources().size()); }