@Test @RunWithCustomExecutor public void testCleaner(){ ConcurrentHashMap<Integer, Map<String , ProcessWorkflow>> map = new ConcurrentHashMap<>(); map.put(0, new ConcurrentHashMap<>()); map.put(1, new ConcurrentHashMap<>()); map.get(0).put("id1_tenant_0", new ProcessWorkflow()); map.get(0).put("id2_tenant_0", new ProcessWorkflow()); map.get(0).put("id3_tenant_0", new ProcessWorkflow()); map.get(1).put("id1_tenant_1", new ProcessWorkflow()); map.get(1).put("id2_tenant_1", new ProcessWorkflow()); map.get(1).put("id3_tenant_1", new ProcessWorkflow()); ProcessManagementImpl processManagement = mock(ProcessManagementImpl.class); ServerConfiguration serverConfiguration = mock(ServerConfiguration.class); map.get(0).get("id3_tenant_0").setState(ProcessState.COMPLETED); map.get(0).get("id3_tenant_0").setProcessCompletedDate(LocalDateUtil.now().minusHours(2)); map.get(1).get("id3_tenant_1").setState(ProcessState.COMPLETED); map.get(1).get("id3_tenant_1").setProcessCompletedDate(LocalDateUtil.now().minusHours(2)); map.get(0).get("id2_tenant_0").setState(ProcessState.COMPLETED); map.get(0).get("id2_tenant_0").setProcessCompletedDate(LocalDateUtil.now().minusHours(1).plusMinutes(50)); when(serverConfiguration.getProcessingCleanerPeriod()).thenReturn(2); when(processManagement.getConfiguration()).thenReturn(serverConfiguration); when(processManagement.getWorkFlowList()).thenReturn(map); ProcessDataManagement processDataManagement = mock(ProcessDataManagement.class); ProcessWorkFlowsCleaner processWorkFlowsCleaner = new ProcessWorkFlowsCleaner(processManagement, processDataManagement, TimeUnit.HOURS); processWorkFlowsCleaner.run(); assertThat(map.get(0).size()).isEqualTo(2); assertThat(map.get(1).size()).isEqualTo(2); }
@Override public void run() { timeLimit = LocalDateUtil.now().minusHours(period); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(VitamConfiguration.getAdminTenant())); this.cleanProcessingByTenants(); }
ProcessWorkFlowsCleaner implements Runnable { @Override public void run() { timeLimit = LocalDateUtil.now().minusHours(period); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(VitamConfiguration.getAdminTenant())); this.cleanProcessingByTenants(); } }
ProcessWorkFlowsCleaner implements Runnable { @Override public void run() { timeLimit = LocalDateUtil.now().minusHours(period); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(VitamConfiguration.getAdminTenant())); this.cleanProcessingByTenants(); } ProcessWorkFlowsCleaner(ProcessManagement processManagement, TimeUnit timeunit); @VisibleForTesting  ProcessWorkFlowsCleaner(ProcessManagement processManagement, ProcessDataManagement processDataManagement,
        TimeUnit timeunit); }
ProcessWorkFlowsCleaner implements Runnable { @Override public void run() { timeLimit = LocalDateUtil.now().minusHours(period); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(VitamConfiguration.getAdminTenant())); this.cleanProcessingByTenants(); } ProcessWorkFlowsCleaner(ProcessManagement processManagement, TimeUnit timeunit); @VisibleForTesting  ProcessWorkFlowsCleaner(ProcessManagement processManagement, ProcessDataManagement processDataManagement,
        TimeUnit timeunit); @Override void run(); }
ProcessWorkFlowsCleaner implements Runnable { @Override public void run() { timeLimit = LocalDateUtil.now().minusHours(period); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(VitamConfiguration.getAdminTenant())); this.cleanProcessingByTenants(); } ProcessWorkFlowsCleaner(ProcessManagement processManagement, TimeUnit timeunit); @VisibleForTesting  ProcessWorkFlowsCleaner(ProcessManagement processManagement, ProcessDataManagement processDataManagement,
        TimeUnit timeunit); @Override void run();  }