DetectorMapper { public boolean isSuccessfulDetectorMappingLookup(List<Map<String, String>> cacheMissedMetricTags) { DetectorMatchResponse matchingDetectorMappings = getMappingsFromElasticSearch(cacheMissedMetricTags); if (matchingDetectorMappings != null) { lastElasticLookUpLatency.set(matchingDetectorMappings.getLookupTimeInMillis()); Map<Integer, List<Detector>> groupedDetectorsByIndex = matchingDetectorMappings.getGroupedDetectorsBySearchIndex(); populateCache(groupedDetectorsByIndex, cacheMissedMetricTags); Set<Integer> searchIndexes = groupedDetectorsByIndex.keySet(); int i = 0; for (Map<String, String> tags : cacheMissedMetricTags) { if (!searchIndexes.contains(i)) { String cacheKey = CacheUtil.getKey(tags); cache.put(cacheKey, Collections.emptyList()); } i++; } } else { lastElasticLookUpLatency.set(-2); } return matchingDetectorMappings != null; } DetectorMapper(DetectorSource detectorSource, DetectorMapperCache cache, int detectorCacheUpdateTimePeriod);  DetectorMapper(DetectorSource detectorSource, Config config, MetricRegistry metricRegistry); int optimalBatchSize(); List<Detector> getDetectorsFromCache(MetricDefinition metricDefinition); boolean isSuccessfulDetectorMappingLookup(List<Map<String, String>> cacheMissedMetricTags); void detectorMappingCacheSync(long currentTime);  }
@Test(expected = RuntimeException.class) public void isSuccessfulDetectorMappingLookup_fail() { when(detectorSource.findDetectorMappings(tag_bigList)).thenThrow(new RuntimeException()); detectorMapper.isSuccessfulDetectorMappingLookup(tag_bigList); }