TaskEvictionResultStoreStep { public void storeTaskEvictionResults(Map<String, TaskRelocationStatus> taskEvictionResults) { Stopwatch stopwatch = Stopwatch.createStarted(); try { int updates = execute(taskEvictionResults); metrics.onSuccess(updates, stopwatch.elapsed(TimeUnit.MILLISECONDS)); } catch (Exception e) { logger.error("Step processing error", e); metrics.onError(stopwatch.elapsed(TimeUnit.MILLISECONDS)); throw e; } } TaskEvictionResultStoreStep(RelocationConfiguration configuration,
                                       TaskRelocationResultStore store,
                                       RelocationTransactionLogger transactionLog,
                                       TitusRuntime titusRuntime); void storeTaskEvictionResults(Map<String, TaskRelocationStatus> taskEvictionResults);  }
@Test public void testSuccessfulStore() { TaskRelocationStatus relocationStatus = TaskRelocationPlanGenerator.oneSuccessfulRelocation(); when(store.createTaskRelocationStatuses(anyList())).thenReturn( Mono.just(Collections.singletonMap(relocationStatus.getTaskId(), Optional.empty())) ); step.storeTaskEvictionResults(Collections.singletonMap(relocationStatus.getTaskId(), relocationStatus)); verify(store, times(1)).createTaskRelocationStatuses(anyList()); }
@Test public void testStoreFailure() { when(store.createTaskRelocationStatuses(anyList())).thenReturn(Mono.error(new RuntimeException("Simulated store error"))); TaskRelocationStatus relocationStatus = TaskRelocationPlanGenerator.oneSuccessfulRelocation(); step.storeTaskEvictionResults(Collections.singletonMap(relocationStatus.getTaskId(), relocationStatus)); verify(store, times(1)).createTaskRelocationStatuses(anyList()); }