ElasticSearchCacheManager { public void cacheEnrichableData(GarmadonMessage msg) { if (GarmadonSerialization.TypeMarker.APPLICATION_EVENT == msg.getType()) addAppEventInCache(msg); addContainerComponentInCache(msg); }  void cacheEnrichableData(GarmadonMessage msg); void enrichEvent(Map<String, Object> eventMap);  }
@Test public void add_app_event_in_cache() { ResourceManagerEventProtos.ApplicationEvent body = createApplicationEvent(); GarmadonMessage msgAppEvent = generateGarmadonMessage(4000, component, body); AppEventEnrichment appEvent = new AppEventEnrichment(msgAppEvent.getHeader().getApplicationName(), msgAppEvent.getHeader().getFramework(), body.getAmContainerId(), msgAppEvent.getHeader().getUsername(), body.getYarnTagsList()); assertNull(elasticSearchCacheManager.cacheAppEvent.getIfPresent(applicationId)); elasticSearchCacheManager.cacheEnrichableData(msgAppEvent); assertEquals(appEvent, elasticSearchCacheManager.cacheAppEvent.getIfPresent(applicationId)); assertEquals(1, elasticSearchCacheManager.cacheAppEvent.size()); }
@Test public void add_container_component_in_cache() { DataAccessEventProtos.FsEvent body = createFsEvent(); GarmadonMessage msgFsEvent = generateGarmadonMessage(1, component, body); assertNull(elasticSearchCacheManager.cacheContainerComponent.getIfPresent(containerId)); elasticSearchCacheManager.cacheEnrichableData(msgFsEvent); assertEquals(component, elasticSearchCacheManager.cacheContainerComponent.getIfPresent(containerId)); }
@Test public void do_not_add_container_with_empty_component_in_cache() { DataAccessEventProtos.FsEvent body = createFsEvent(); GarmadonMessage msgFsEvent = generateGarmadonMessage(1, "", body); elasticSearchCacheManager.cacheEnrichableData(msgFsEvent); assertNull(elasticSearchCacheManager.cacheContainerComponent.getIfPresent(containerId)); }