use of com.faforever.client.vault.review.Review in project downlords-faf-client by FAForever.
the class ReplayDetailControllerTest method onDownloadMoreInfoClicked.
@Test
public void onDownloadMoreInfoClicked() throws Exception {
when(replayService.getSize(anyInt())).thenReturn(CompletableFuture.completedFuture(1024));
Replay replay = new Replay();
Review review = new Review();
review.setPlayer(new Player("junit"));
replay.getReviews().setAll(FXCollections.observableArrayList(review));
replay.setValidity(Validity.VALID);
replay.setFeaturedMod(new FeaturedMod());
instance.setReplay(replay);
Path tmpPath = Paths.get("foo.tmp");
when(replayService.downloadReplay(replay.getId())).thenReturn(CompletableFuture.completedFuture(tmpPath));
instance.onDownloadMoreInfoClicked();
verify(replayService).enrich(replay, tmpPath);
assertThat(instance.optionsTable.isVisible(), is(true));
assertThat(instance.chatTable.isVisible(), is(true));
}
use of com.faforever.client.vault.review.Review in project downlords-faf-client by FAForever.
the class FafServiceImplTest method createMapVersionReview.
@Test
public void createMapVersionReview() throws Exception {
Review review = createReview(null, "something", 3, 42);
when(fafApiAccessor.createMapVersionReview(any())).thenReturn((MapVersionReview) new MapVersionReview().setPlayer(player()).setId("1").setScore((byte) 1));
instance.saveMapVersionReview(review, "5");
verify(fafApiAccessor).createMapVersionReview(any());
}
use of com.faforever.client.vault.review.Review in project downlords-faf-client by FAForever.
the class FafServiceImplTest method createGameReview.
@Test
public void createGameReview() throws Exception {
Review review = createReview(null, "something", 3, 42);
when(fafApiAccessor.createGameReview(any())).thenReturn((GameReview) new GameReview().setPlayer(player()).setId("1").setScore((byte) 1));
instance.saveGameReview(review, 5);
verify(fafApiAccessor).createGameReview(any());
}
use of com.faforever.client.vault.review.Review in project downlords-faf-client by FAForever.
the class MapCardController method setMap.
public void setMap(MapBean map) {
this.map = map;
Image image;
if (map.getSmallThumbnailUrl() != null) {
image = mapService.loadPreview(map, PreviewSize.SMALL);
} else {
image = IdenticonUtil.createIdenticon(map.getId());
}
thumbnailImageView.setImage(image);
nameLabel.setText(map.getDisplayName());
authorLabel.setText(Optional.ofNullable(map.getAuthor()).orElse(i18n.get("map.unknownAuthor")));
numberOfPlaysLabel.setText(i18n.number(map.getNumberOfPlays()));
MapSize size = map.getSize();
sizeLabel.setText(i18n.get("mapPreview.size", size.getWidthInKm(), size.getHeightInKm()));
maxPlayersLabel.setText(i18n.number(map.getPlayers()));
ObservableList<MapBean> installedMaps = mapService.getInstalledMaps();
synchronized (installedMaps) {
installedMaps.addListener(new WeakListChangeListener<>(installedMapsChangeListener));
}
ObservableList<Review> reviews = map.getReviews();
reviews.addListener(new WeakInvalidationListener(reviewsChangedListener));
reviewsChangedListener.invalidated(reviews);
}
use of com.faforever.client.vault.review.Review in project downlords-faf-client by FAForever.
the class ReplayCardController method setReplay.
public void setReplay(Replay replay) {
this.replay = replay;
Optional<MapBean> optionalMap = Optional.ofNullable(replay.getMap());
if (optionalMap.isPresent()) {
MapBean map = optionalMap.get();
Image image = mapService.loadPreview(map, PreviewSize.SMALL);
mapThumbnailImageView.setImage(image);
onMapLabel.setText(i18n.get("game.onMapFormat", map.getDisplayName()));
} else {
onMapLabel.setText(i18n.get("game.onUnknownMap"));
}
gameTitleLabel.setText(replay.getTitle());
dateLabel.setText(timeService.asDate(replay.getStartTime()));
timeLabel.setText(timeService.asShortTime(replay.getStartTime()));
modLabel.setText(replay.getFeaturedMod().getDisplayName());
playerCountLabel.setText(i18n.number(replay.getTeams().values().stream().mapToInt(List::size).sum()));
qualityLabel.setText(i18n.get("percentage", (int) ratingService.calculateQuality(replay) * 100));
replay.getTeamPlayerStats().values().stream().flatMapToInt(playerStats -> playerStats.stream().mapToInt(stats -> RatingUtil.getRating(stats.getBeforeMean(), stats.getBeforeDeviation()))).average().ifPresent(averageRating -> ratingLabel.setText(i18n.number((int) averageRating)));
durationLabel.setText(Optional.ofNullable(replay.getEndTime()).map(endTime -> timeService.shortDuration(Duration.between(replay.getStartTime(), endTime))).orElse(i18n.get("notAvailable")));
String players = replay.getTeams().values().stream().map(team -> Joiner.on(i18n.get("textSeparator")).join(team)).collect(Collectors.joining(i18n.get("vsSeparator")));
playerListLabel.setText(players);
ObservableList<Review> reviews = replay.getReviews();
reviews.addListener(new WeakInvalidationListener(reviewsChangedListener));
reviewsChangedListener.invalidated(reviews);
}
Aggregations