@Test
public void testGetDetectorsFromCache() throws IOException {

    //testing detector Mapper with actual cache
    this.detectorMapper = new DetectorMapper(detectorSource, config, new MetricRegistry());
    this.initTagsFromFile();
    //populate cache
    detectorMapper.isSuccessfulDetectorMappingLookup(listOfMetricTags);
    Map<String, List<Detector>> detectorResults = new HashMap<>();
    listOfMetricTags.forEach(tags -> {
        MetricData metricData = new MetricData(new MetricDefinition(new TagCollection(tags)), 0.0, 1L);
        List<Detector> detector = detectorMapper.getDetectorsFromCache(metricData.getMetricDefinition());
        if (!detector.isEmpty())
            detectorResults.put(CacheUtil.getKey(tags), detector);
    });
    assertThat(detectorResults.size(), is(3));
    assertThat(detectorResults, IsMapContaining.hasEntry("key->RHZGV1VodjI1aA==,name->NjFFS0JDcnd2SQ==", Collections.singletonList(buildDetector("cid", "2c49ba26-1a7d-43f4-b70c-c6644a2c1689"))));
    assertThat(detectorResults, IsMapContaining.hasEntry("key->ZEFxYlpaVlBaOA==,name->ZmJXVGlSbHhrdA==", Collections.singletonList(buildDetector("ad-manager", "5eaa54e9-7406-4a1d-bd9b-e055eca1a423"))));
    assertThat(detectorResults, IsMapContaining.hasEntry("name->aGl3,region->dXMtd2VzdC0y", Collections.singletonList(buildDetector("", "d86b798c-cfee-4a2c-a17a-aa2ba79ccf51"))));
}