@Test @RunWithCustomExecutor public void testReLoadingFromCache() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(3); GUID guid = GUIDFactory.newRequestIdGUID(3); VitamThreadUtils.getVitamSession().setRequestId(guid); ArchiveUnitProfileModel archiveUnitProfileModel1 = mock(ArchiveUnitProfileModel.class); ArchiveUnitProfileModel archiveUnitProfileModel2 = mock(ArchiveUnitProfileModel.class); doReturn(new RequestResponseOK<ArchiveUnitProfileModel>().addResult(archiveUnitProfileModel1)) .when(adminManagementClient).findArchiveUnitProfilesByID("MyAUP1"); doReturn(new RequestResponseOK<ArchiveUnitProfileModel>().addResult(archiveUnitProfileModel2)) .when(adminManagementClient).findArchiveUnitProfilesByID("MyAUP2"); CachedArchiveUnitProfileLoader archiveUnitProfileLoader = new CachedArchiveUnitProfileLoader(adminManagementClientFactory, 10, 60); Optional<ArchiveUnitProfileModel> result1 = null; Optional<ArchiveUnitProfileModel> result2 = null; for (int i = 0; i < 10; i++) { result1 = archiveUnitProfileLoader.loadArchiveUnitProfile("MyAUP1"); result2 = archiveUnitProfileLoader.loadArchiveUnitProfile("MyAUP2"); } assertThat(result1.get()).isEqualTo(archiveUnitProfileModel1); assertThat(result2.get()).isEqualTo(archiveUnitProfileModel2); verify(adminManagementClient, times(1)).findArchiveUnitProfilesByID("MyAUP1"); verify(adminManagementClient, times(1)).findArchiveUnitProfilesByID("MyAUP2"); }
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);  }