@Test public void testGetTumorTypesByVersion() { Map<String, TumorType> returnedTumorTypes = cacheUtil.getTumorTypesByVersion(legacyVersion); String rootTumorTypeCode = returnedTumorTypes.keySet().iterator().next(); TumorType rootTumorType = returnedTumorTypes.get(rootTumorTypeCode); assertEquals("TISSUE", rootTumorTypeCode); assertEquals("TISSUE", rootTumorType.getCode()); assertEquals(32, rootTumorType.getChildren().size()); assertNoHistoryInChildren(rootTumorType.getChildren()); assertNoRevocationsInChildren(rootTumorType.getChildren()); assertNoPrecursorsInChildren(rootTumorType.getChildren()); returnedTumorTypes = cacheUtil.getTumorTypesByVersion(latestVersion); Boolean foundHistory = Boolean.FALSE; foundHistory = assertHistoryInChildren(returnedTumorTypes, foundHistory); assertTrue("Failed to find history for 'SS'", foundHistory); Boolean foundRevocations = Boolean.FALSE; foundRevocations = assertRevocationsInChildren(returnedTumorTypes, foundRevocations); assertTrue("Failed to find revocations for 'URMM'", foundRevocations); Boolean foundPrecursors = Boolean.FALSE; foundPrecursors = assertPrecursorsInChildren(returnedTumorTypes, foundPrecursors); assertTrue("Failed to find precursors for 'CLLSLL'", foundPrecursors); }
public Map<String, TumorType> getTumorTypesByVersion(Version version) throws InvalidVersionException, FailedCacheRefreshException { if (tumorTypesCache == null) { logger.error("getTumorTypesByVersion() -- called on expired cache"); throw new FailedCacheRefreshException("Cache has expired, resets must have failed"); } if (logger.isDebugEnabled()) { for (Version cachedVersion : tumorTypesCache.keySet()) { logger.debug("getTumorTypesByVersion() -- tumorTypes cache contains '" + cachedVersion.getVersion() + "'"); } } if (tumorTypesCache.containsKey(version)) { logger.debug("getTumorTypesByVersion() -- found '" + version.getVersion() + "' in cache"); return getUnmodifiableTumorTypesByVersion(tumorTypesCache.get(version)); } else { logger.debug("getTumorTypesByVersion() -- did NOT find '" + version.getVersion() + "' in cache, throwing exception"); throw new FailedCacheRefreshException("Unknown version '" + version.getVersion() + "'"); } }
CacheUtil { public Map<String, TumorType> getTumorTypesByVersion(Version version) throws InvalidVersionException, FailedCacheRefreshException { if (tumorTypesCache == null) { logger.error("getTumorTypesByVersion() -- called on expired cache"); throw new FailedCacheRefreshException("Cache has expired, resets must have failed"); } if (logger.isDebugEnabled()) { for (Version cachedVersion : tumorTypesCache.keySet()) { logger.debug("getTumorTypesByVersion() -- tumorTypes cache contains '" + cachedVersion.getVersion() + "'"); } } if (tumorTypesCache.containsKey(version)) { logger.debug("getTumorTypesByVersion() -- found '" + version.getVersion() + "' in cache"); return getUnmodifiableTumorTypesByVersion(tumorTypesCache.get(version)); } else { logger.debug("getTumorTypesByVersion() -- did NOT find '" + version.getVersion() + "' in cache, throwing exception"); throw new FailedCacheRefreshException("Unknown version '" + version.getVersion() + "'"); } } }
CacheUtil { public Map<String, TumorType> getTumorTypesByVersion(Version version) throws InvalidVersionException, FailedCacheRefreshException { if (tumorTypesCache == null) { logger.error("getTumorTypesByVersion() -- called on expired cache"); throw new FailedCacheRefreshException("Cache has expired, resets must have failed"); } if (logger.isDebugEnabled()) { for (Version cachedVersion : tumorTypesCache.keySet()) { logger.debug("getTumorTypesByVersion() -- tumorTypes cache contains '" + cachedVersion.getVersion() + "'"); } } if (tumorTypesCache.containsKey(version)) { logger.debug("getTumorTypesByVersion() -- found '" + version.getVersion() + "' in cache"); return getUnmodifiableTumorTypesByVersion(tumorTypesCache.get(version)); } else { logger.debug("getTumorTypesByVersion() -- did NOT find '" + version.getVersion() + "' in cache, throwing exception"); throw new FailedCacheRefreshException("Unknown version '" + version.getVersion() + "'"); } }  }
CacheUtil { public Map<String, TumorType> getTumorTypesByVersion(Version version) throws InvalidVersionException, FailedCacheRefreshException { if (tumorTypesCache == null) { logger.error("getTumorTypesByVersion() -- called on expired cache"); throw new FailedCacheRefreshException("Cache has expired, resets must have failed"); } if (logger.isDebugEnabled()) { for (Version cachedVersion : tumorTypesCache.keySet()) { logger.debug("getTumorTypesByVersion() -- tumorTypes cache contains '" + cachedVersion.getVersion() + "'"); } } if (tumorTypesCache.containsKey(version)) { logger.debug("getTumorTypesByVersion() -- found '" + version.getVersion() + "' in cache"); return getUnmodifiableTumorTypesByVersion(tumorTypesCache.get(version)); } else { logger.debug("getTumorTypesByVersion() -- did NOT find '" + version.getVersion() + "' in cache, throwing exception"); throw new FailedCacheRefreshException("Unknown version '" + version.getVersion() + "'"); } }  void resetCache(); Date getDateOfLastCacheRefresh(); void setDateOfLastCacheRefresh(Date date); List<Version> getCachedVersions(); Map<String, TumorType> getTumorTypesByVersion(Version version); boolean cacheIsStale(); }
CacheUtil { public Map<String, TumorType> getTumorTypesByVersion(Version version) throws InvalidVersionException, FailedCacheRefreshException { if (tumorTypesCache == null) { logger.error("getTumorTypesByVersion() -- called on expired cache"); throw new FailedCacheRefreshException("Cache has expired, resets must have failed"); } if (logger.isDebugEnabled()) { for (Version cachedVersion : tumorTypesCache.keySet()) { logger.debug("getTumorTypesByVersion() -- tumorTypes cache contains '" + cachedVersion.getVersion() + "'"); } } if (tumorTypesCache.containsKey(version)) { logger.debug("getTumorTypesByVersion() -- found '" + version.getVersion() + "' in cache"); return getUnmodifiableTumorTypesByVersion(tumorTypesCache.get(version)); } else { logger.debug("getTumorTypesByVersion() -- did NOT find '" + version.getVersion() + "' in cache, throwing exception"); throw new FailedCacheRefreshException("Unknown version '" + version.getVersion() + "'"); } }  void resetCache(); Date getDateOfLastCacheRefresh(); void setDateOfLastCacheRefresh(Date date); List<Version> getCachedVersions(); Map<String, TumorType> getTumorTypesByVersion(Version version); boolean cacheIsStale(); static final Integer MAXIMUM_CACHE_AGE_IN_DAYS; }