Search in sources :

Example 1 with RatingHistoryDataPoint

use of com.faforever.client.domain.RatingHistoryDataPoint in project downlords-faf-client by FAForever.

the class UserInfoWindowControllerTest method setUp.

@Before
public void setUp() throws Exception {
    instance = new UserInfoWindowController(statisticsService, countryFlagService, achievementService, eventService, i18n, uiService, timeService, notificationService, playerService, leaderboardService);
    when(uiService.loadFxml("theme/achievement_item.fxml")).thenReturn(achievementItemController);
    when(achievementItemController.getRoot()).thenReturn(new HBox());
    when(playerService.getPlayersByIds(any())).thenReturn(CompletableFuture.completedFuture(Collections.emptyList()));
    when(statisticsService.getRatingHistory(any(), eq(PLAYER_ID))).thenReturn(CompletableFuture.completedFuture(Arrays.asList(new RatingHistoryDataPoint(OffsetDateTime.now(), 1500f, 50f), new RatingHistoryDataPoint(OffsetDateTime.now().plus(1, ChronoUnit.DAYS), 1500f, 50f))));
    loadFxml("theme/user_info_window.fxml", clazz -> instance);
}
Also used : HBox(javafx.scene.layout.HBox) RatingHistoryDataPoint(com.faforever.client.domain.RatingHistoryDataPoint) Before(org.junit.Before)

Example 2 with RatingHistoryDataPoint

use of com.faforever.client.domain.RatingHistoryDataPoint in project downlords-faf-client by FAForever.

the class UserInfoWindowController method ratingLabelFormatter.

@NotNull
private StringConverter<Number> ratingLabelFormatter(final List<RatingHistoryDataPoint> dataPoints) {
    return new StringConverter<Number>() {

        @Override
        public String toString(Number object) {
            int number = object.intValue();
            int numberOfDataPoints = dataPoints.size();
            int dataPointIndex = number >= numberOfDataPoints ? numberOfDataPoints - 1 : number;
            if (dataPointIndex >= dataPoints.size() || dataPointIndex < 0) {
                return "";
            }
            return DATE_FORMATTER.format(dataPoints.get(dataPointIndex).getInstant());
        }

        @Override
        public Number fromString(String string) {
            return null;
        }
    };
}
Also used : StringConverter(javafx.util.StringConverter) RatingHistoryDataPoint(com.faforever.client.domain.RatingHistoryDataPoint) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RatingHistoryDataPoint (com.faforever.client.domain.RatingHistoryDataPoint)2 HBox (javafx.scene.layout.HBox)1 StringConverter (javafx.util.StringConverter)1 NotNull (org.jetbrains.annotations.NotNull)1 Before (org.junit.Before)1