Search in sources :

Example 1 with TaskService

use of com.faforever.client.task.TaskService 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);
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Arrays(java.util.Arrays) UiService(com.faforever.client.theme.UiService) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) CompletableFuture(java.util.concurrent.CompletableFuture) ReportingService(com.faforever.client.reporting.ReportingService) LoadLocalReplaysTask(com.faforever.client.replay.LoadLocalReplaysTask) InvalidationListener(javafx.beans.InvalidationListener) Mockito.verifyZeroInteractions(org.mockito.Mockito.verifyZeroInteractions) Assert.assertThat(org.junit.Assert.assertThat) NotificationService(com.faforever.client.notification.NotificationService) TimeService(com.faforever.client.util.TimeService) Mockito.doAnswer(org.mockito.Mockito.doAnswer) TableView(javafx.scene.control.TableView) Mockito.doReturn(org.mockito.Mockito.doReturn) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Before(org.junit.Before) ReplayService(com.faforever.client.replay.ReplayService) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) ApplicationContext(org.springframework.context.ApplicationContext) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Matchers.any(org.mockito.Matchers.any) CountDownLatch(java.util.concurrent.CountDownLatch) ReplayInfoBeanBuilder(com.faforever.client.replay.ReplayInfoBeanBuilder) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) TaskService(com.faforever.client.task.TaskService) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest) Mockito.mock(org.mockito.Mockito.mock) LoadLocalReplaysTask(com.faforever.client.replay.LoadLocalReplaysTask) CountDownLatch(java.util.concurrent.CountDownLatch) TableView(javafx.scene.control.TableView) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

I18n (com.faforever.client.i18n.I18n)1 MapService (com.faforever.client.map.MapService)1 NotificationService (com.faforever.client.notification.NotificationService)1 LoadLocalReplaysTask (com.faforever.client.replay.LoadLocalReplaysTask)1 ReplayInfoBeanBuilder (com.faforever.client.replay.ReplayInfoBeanBuilder)1 ReplayService (com.faforever.client.replay.ReplayService)1 ReportingService (com.faforever.client.reporting.ReportingService)1 TaskService (com.faforever.client.task.TaskService)1 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)1 UiService (com.faforever.client.theme.UiService)1 TimeService (com.faforever.client.util.TimeService)1 Arrays (java.util.Arrays)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 InvalidationListener (javafx.beans.InvalidationListener)1 TableView (javafx.scene.control.TableView)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 CoreMatchers.nullValue (org.hamcrest.CoreMatchers.nullValue)1 Assert.assertThat (org.junit.Assert.assertThat)1