### Question:
HelixStorageUsageRefresher implements StorageUsageRefresher { @Override public Map<String, Map<String, Long>> getContainerStorageUsage() { return Collections.unmodifiableMap(containerStorageUsageRef.get()); } HelixStorageUsageRefresher(HelixPropertyStore<ZNRecord> helixStore, ScheduledExecutorService scheduler,
      StorageQuotaConfig config); @Override Map<String, Map<String, Long>> getContainerStorageUsage(); @Override void registerListener(Listener cb); static final String AGGREGATED_CONTAINER_STORAGE_USAGE_PATH; static final String VALID_SIZE_FILED_NAME; }### Answer:
@Test public void testStartRefresherWithEmptyStorageUsage() { storageUsageRefresher = new HelixStorageUsageRefresher(mockHelixStore, null, storageQuotaConfig); Map<String, Map<String, Long>> emptyMap = storageUsageRefresher.getContainerStorageUsage(); assertTrue(emptyMap.equals(Collections.EMPTY_MAP)); }
@Test public void testStartRefresherWithStorageUsage() throws Exception { Map<String, Map<String, Long>> expectedUsage = makeStorageUsageAndWriteToHelix(10, 10); storageUsageRefresher = new HelixStorageUsageRefresher(mockHelixStore, null, storageQuotaConfig); Map<String, Map<String, Long>> obtainedUsage = storageUsageRefresher.getContainerStorageUsage(); assertContainerUsageMap(expectedUsage, obtainedUsage); }
@Test public void testStartRefresherWithBadZNRecord() throws Exception { writeToHelix("BAD ZNRECORD"); storageUsageRefresher = new HelixStorageUsageRefresher(mockHelixStore, null, storageQuotaConfig); Map<String, Map<String, Long>> emptyMap = storageUsageRefresher.getContainerStorageUsage(); assertTrue(emptyMap.equals(Collections.EMPTY_MAP)); }
@Test public void testRefresherUpdateWithBadRecord() throws Exception { Map<String, Map<String, Long>> expectedUsage = makeStorageUsageAndWriteToHelix(10, 10); storageUsageRefresher = new HelixStorageUsageRefresher(mockHelixStore, null, storageQuotaConfig); Map<String, Map<String, Long>> obtainedUsage = storageUsageRefresher.getContainerStorageUsage(); assertContainerUsageMap(expectedUsage, obtainedUsage); writeToHelix("BAD ZNRECORD"); Thread.sleep(1000); obtainedUsage = storageUsageRefresher.getContainerStorageUsage(); assertContainerUsageMap(expectedUsage, obtainedUsage); }
@Test public void testStartRefresherWithScheduler() throws Exception { Map<String, Map<String, Long>> expectedUsage = makeStorageUsageAndWriteToHelix(10, 10); storageUsageRefresher = new HelixStorageUsageRefresher(mockHelixStore, scheduler, storageQuotaConfig); Map<String, Map<String, Long>> obtainedUsage = storageUsageRefresher.getContainerStorageUsage(); assertContainerUsageMap(expectedUsage, obtainedUsage); }