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));
}
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());
}
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"));
}
Aggregations