@Test @RunWithCustomExecutor public void testLoading() { VitamThreadUtils.getVitamSession().setTenantId(3); GUID guid = GUIDFactory.newRequestIdGUID(3); VitamThreadUtils.getVitamSession().setRequestId(guid); List<OntologyModel> ontologyModels = Arrays.asList( new OntologyModel().setType(OntologyType.KEYWORD).setIdentifier("_id"), new OntologyModel().setType(OntologyType.TEXT).setIdentifier("Title") ); CachedOntologyLoader cachedOntologyLoader = new CachedOntologyLoader(10, 60, () -> ontologyModels); List<OntologyModel> result = cachedOntologyLoader.loadOntologies(); assertThat(result).isEqualTo(ontologyModels); }
@Override public List<OntologyModel> loadOntologies() { String id = StringUtils.isBlank(VitamThreadUtils.getVitamSession().getRequestId()) ? GET_FROM_SAME_CACHE : VitamThreadUtils.getVitamSession().getRequestId(); return this.cache.getUnchecked(id); }
CachedOntologyLoader implements OntologyLoader { @Override public List<OntologyModel> loadOntologies() { String id = StringUtils.isBlank(VitamThreadUtils.getVitamSession().getRequestId()) ? GET_FROM_SAME_CACHE : VitamThreadUtils.getVitamSession().getRequestId(); return this.cache.getUnchecked(id); } }
CachedOntologyLoader implements OntologyLoader { @Override public List<OntologyModel> loadOntologies() { String id = StringUtils.isBlank(VitamThreadUtils.getVitamSession().getRequestId()) ? GET_FROM_SAME_CACHE : VitamThreadUtils.getVitamSession().getRequestId(); return this.cache.getUnchecked(id); } CachedOntologyLoader(int maxEntriesInCache, int cacheTimeoutInSeconds, OntologyLoader loadOntology); }
CachedOntologyLoader implements OntologyLoader { @Override public List<OntologyModel> loadOntologies() { String id = StringUtils.isBlank(VitamThreadUtils.getVitamSession().getRequestId()) ? GET_FROM_SAME_CACHE : VitamThreadUtils.getVitamSession().getRequestId(); return this.cache.getUnchecked(id); } CachedOntologyLoader(int maxEntriesInCache, int cacheTimeoutInSeconds, OntologyLoader loadOntology); @Override List<OntologyModel> loadOntologies(); }
CachedOntologyLoader implements OntologyLoader { @Override public List<OntologyModel> loadOntologies() { String id = StringUtils.isBlank(VitamThreadUtils.getVitamSession().getRequestId()) ? GET_FROM_SAME_CACHE : VitamThreadUtils.getVitamSession().getRequestId(); return this.cache.getUnchecked(id); } CachedOntologyLoader(int maxEntriesInCache, int cacheTimeoutInSeconds, OntologyLoader loadOntology); @Override List<OntologyModel> loadOntologies();  }