use of com.faforever.client.replay.LoadLocalReplaysTask in project downlords-faf-client by FAForever.
the class ReplayVaultControllerTest method testLoadLocalReplaysInBackground.
@Test
public void testLoadLocalReplaysInBackground() throws Exception {
LoadLocalReplaysTask task = mock(LoadLocalReplaysTask.class);
when(task.getFuture()).thenReturn(CompletableFuture.completedFuture(Arrays.asList(ReplayInfoBeanBuilder.create().get(), ReplayInfoBeanBuilder.create().get(), ReplayInfoBeanBuilder.create().get())));
when(applicationContext.getBean(LoadLocalReplaysTask.class)).thenReturn(task);
CountDownLatch loadedLatch = new CountDownLatch(1);
((TableView) instance.getRoot()).getItems().addListener((InvalidationListener) observable -> loadedLatch.countDown());
instance.loadLocalReplaysInBackground();
assertTrue(loadedLatch.await(5000, TimeUnit.MILLISECONDS));
assertThat(((TableView) instance.getRoot()).getItems().size(), is(3));
verify(taskService).submitTask(task);
verifyZeroInteractions(notificationService);
}
use of com.faforever.client.replay.LoadLocalReplaysTask in project downlords-faf-client by FAForever.
the class ReplayVaultControllerTest method setUp.
@Before
public void setUp() throws Exception {
instance = new ReplayVaultController(notificationService, replayService, mapService, taskService, i18n, timeService, reportingService, applicationContext, uiService);
doReturn(new LoadLocalReplaysTask(replayService, i18n)).when(applicationContext).getBean(eq(LoadLocalReplaysTask.class));
doAnswer(invocation -> invocation.getArgument(0)).when(taskService).submitTask(any());
loadFxml("theme/vault/replay/replay_vault.fxml", clazz -> instance);
}
use of com.faforever.client.replay.LoadLocalReplaysTask in project downlords-faf-client by FAForever.
the class ReplayVaultController method loadLocalReplaysInBackground.
public CompletableFuture<Void> loadLocalReplaysInBackground() {
// TODO use replay service
LoadLocalReplaysTask task = applicationContext.getBean(LoadLocalReplaysTask.class);
replayVaultRoot.getItems().clear();
return taskService.submitTask(task).getFuture().thenAccept(this::addLocalReplays).exceptionally(throwable -> {
logger.warn("Error while loading local replays", throwable);
notificationService.addNotification(new PersistentNotification(i18n.get("replays.loadingLocalTask.failed"), Severity.ERROR, asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
return null;
});
}
Aggregations