Search in sources :

Example 1 with SearchConfig

use of com.faforever.client.vault.search.SearchController.SearchConfig in project downlords-faf-client by FAForever.

the class OnlineReplayVaultControllerTest method testMoreButton.

@Test
public void testMoreButton() throws Exception {
    Consumer<SearchConfig> searchListener = searchListenerCaptor.getValue();
    List<Replay> list = new ArrayList<>();
    for (int i = 0; i != 100; i++) {
        list.add(new Replay());
    }
    CompletableFuture<List<Replay>> completableFuture = new CompletableFuture<>();
    completableFuture.complete(list);
    when(replayService.findByQuery(eq("query"), eq(MAX_RESULTS), anyInt(), eq(sortOrder))).thenReturn(completableFuture);
    searchListener.accept(standardSearchConfig);
    instance.onLoadMoreButtonClicked(new ActionEvent());
    WaitForAsyncUtils.waitForFxEvents();
    verify(replayService).findByQuery("query", MAX_RESULTS, 1, sortOrder);
    verify(replayService).findByQuery("query", MAX_RESULTS, 2, sortOrder);
    assertThat(instance.moreButton.isVisible(), is(true));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ActionEvent(javafx.event.ActionEvent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SearchConfig(com.faforever.client.vault.search.SearchController.SearchConfig) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 2 with SearchConfig

use of com.faforever.client.vault.search.SearchController.SearchConfig in project downlords-faf-client by FAForever.

the class OnlineReplayVaultControllerTest method setUp.

@Before
public void setUp() throws Exception {
    when(uiService.loadFxml("theme/vault/replay/replay_card.fxml")).thenAnswer(invocation -> {
        ReplayCardController controller = mock(ReplayCardController.class);
        when(controller.getRoot()).thenReturn(new Pane());
        return controller;
    });
    when(preferencesService.getPreferences()).thenReturn(new Preferences());
    sortOrder = preferencesService.getPreferences().getVaultPrefs().getOnlineReplaySortConfig();
    standardSearchConfig = new SearchConfig(sortOrder, "query");
    instance = new OnlineReplayVaultController(replayService, uiService, notificationService, i18n, preferencesService);
    loadFxml("theme/vault/replay/online_replays.fxml", clazz -> {
        if (SearchController.class.isAssignableFrom(clazz)) {
            return searchController;
        }
        if (SpecificationController.class.isAssignableFrom(clazz)) {
            return specificationController;
        }
        if (LogicalNodeController.class.isAssignableFrom(clazz)) {
            return logicalNodeController;
        }
        return instance;
    });
    verify(searchController).setSearchListener(searchListenerCaptor.capture());
}
Also used : SearchConfig(com.faforever.client.vault.search.SearchController.SearchConfig) Preferences(com.faforever.client.preferences.Preferences) Pane(javafx.scene.layout.Pane) Before(org.junit.Before)

Example 3 with SearchConfig

use of com.faforever.client.vault.search.SearchController.SearchConfig in project downlords-faf-client by FAForever.

the class SearchControllerTest method testSorting.

@Test
public void testSorting() throws Exception {
    instance.setSearchListener(searchListener);
    instance.queryTextField.setText("query");
    instance.sortOrderChoiceBox.getSelectionModel().select(SortOrder.ASC);
    instance.sortPropertyComboBox.getSelectionModel().select("game.title");
    instance.onSearchButtonClicked();
    SortConfig mapSortConfig = preferencesService.getPreferences().getVaultPrefs().getOnlineReplaySortConfig();
    assertEquals(mapSortConfig.getSortOrder(), SortOrder.ASC);
    verify(searchListener).accept(new SearchConfig(mapSortConfig, "query"));
}
Also used : SortConfig(com.faforever.client.vault.search.SearchController.SortConfig) SearchConfig(com.faforever.client.vault.search.SearchController.SearchConfig) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

SearchConfig (com.faforever.client.vault.search.SearchController.SearchConfig)3 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)2 Test (org.junit.Test)2 Preferences (com.faforever.client.preferences.Preferences)1 SortConfig (com.faforever.client.vault.search.SearchController.SortConfig)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ActionEvent (javafx.event.ActionEvent)1 Pane (javafx.scene.layout.Pane)1 Before (org.junit.Before)1