@Test @RunWithCustomExecutor public void testCacheTimeout() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(3); GUID guid = GUIDFactory.newRequestIdGUID(3); VitamThreadUtils.getVitamSession().setRequestId(guid); ArchiveUnitProfileModel archiveUnitProfileModel = mock(ArchiveUnitProfileModel.class); doReturn(new RequestResponseOK<ArchiveUnitProfileModel>().addResult(archiveUnitProfileModel)) .when(adminManagementClient).findArchiveUnitProfilesByID("MyAUP"); CachedArchiveUnitProfileLoader archiveUnitProfileLoader = new CachedArchiveUnitProfileLoader(adminManagementClientFactory, 10, 1); archiveUnitProfileLoader.loadArchiveUnitProfile("MyAUP"); TimeUnit.SECONDS.sleep(2); Optional<ArchiveUnitProfileModel> result = archiveUnitProfileLoader.loadArchiveUnitProfile("MyAUP"); assertThat(result.get()).isEqualTo(archiveUnitProfileModel); verify(adminManagementClient, times(2)).findArchiveUnitProfilesByID("MyAUP"); }
public Optional<ArchiveUnitProfileModel> loadArchiveUnitProfile(String aupId) { String requestId = VitamThreadUtils.getVitamSession().getRequestId(); return this.archiveUnitProfileCache.getUnchecked(requestId + "/" + aupId); }
CachedArchiveUnitProfileLoader { public Optional<ArchiveUnitProfileModel> loadArchiveUnitProfile(String aupId) { String requestId = VitamThreadUtils.getVitamSession().getRequestId(); return this.archiveUnitProfileCache.getUnchecked(requestId + "/" + aupId); } }
CachedArchiveUnitProfileLoader { public Optional<ArchiveUnitProfileModel> loadArchiveUnitProfile(String aupId) { String requestId = VitamThreadUtils.getVitamSession().getRequestId(); return this.archiveUnitProfileCache.getUnchecked(requestId + "/" + aupId); } CachedArchiveUnitProfileLoader(
        AdminManagementClientFactory adminManagementClientFactory, int maxEntriesInCache, int cacheTimeoutInSeconds); }
CachedArchiveUnitProfileLoader { public Optional<ArchiveUnitProfileModel> loadArchiveUnitProfile(String aupId) { String requestId = VitamThreadUtils.getVitamSession().getRequestId(); return this.archiveUnitProfileCache.getUnchecked(requestId + "/" + aupId); } CachedArchiveUnitProfileLoader(
        AdminManagementClientFactory adminManagementClientFactory, int maxEntriesInCache, int cacheTimeoutInSeconds); Optional<ArchiveUnitProfileModel> loadArchiveUnitProfile(String aupId); }
CachedArchiveUnitProfileLoader { public Optional<ArchiveUnitProfileModel> loadArchiveUnitProfile(String aupId) { String requestId = VitamThreadUtils.getVitamSession().getRequestId(); return this.archiveUnitProfileCache.getUnchecked(requestId + "/" + aupId); } CachedArchiveUnitProfileLoader(
        AdminManagementClientFactory adminManagementClientFactory, int maxEntriesInCache, int cacheTimeoutInSeconds); Optional<ArchiveUnitProfileModel> loadArchiveUnitProfile(String aupId);  }