use of com.faforever.client.api.dto.MapVersion in project downlords-faf-client by FAForever.
the class FafServiceImpl method saveMapVersionReview.
@Override
@Async
public CompletableFuture<Void> saveMapVersionReview(Review review, String mapVersionId) {
MapVersionReview mapVersionReview = (MapVersionReview) new MapVersionReview().setScore(review.getScore().byteValue()).setText(review.getText());
if (review.getId() == null) {
Assert.notNull(review.getPlayer(), "Player ID must be set");
MapVersionReview updatedReview = fafApiAccessor.createMapVersionReview((MapVersionReview) mapVersionReview.setMapVersion(new MapVersion().setId(mapVersionId)).setId(String.valueOf(review.getId())).setPlayer(new com.faforever.client.api.dto.Player().setId(String.valueOf(review.getPlayer().getId()))));
review.setId(updatedReview.getId());
} else {
fafApiAccessor.updateMapVersionReview((MapVersionReview) mapVersionReview.setId(String.valueOf(review.getId())));
}
return CompletableFuture.completedFuture(null);
}
use of com.faforever.client.api.dto.MapVersion in project downlords-faf-client by FAForever.
the class FafApiAccessorImplTest method testCreateMapVersionReview.
@Test
public void testCreateMapVersionReview() {
MapVersionReview mapVersionReview = new MapVersionReview().setMapVersion(new MapVersion().setId("5"));
when(restOperations.postForEntity(eq("/data/mapVersion/5/reviews"), eq(mapVersionReview), eq(MapVersionReview.class))).thenReturn(new ResponseEntity<>(HttpStatus.OK));
instance.createMapVersionReview(mapVersionReview);
ArgumentCaptor<MapVersionReview> captor = ArgumentCaptor.forClass(MapVersionReview.class);
verify(restOperations).postForEntity(eq("/data/mapVersion/5/reviews"), captor.capture(), eq(MapVersionReview.class));
MapVersionReview review = captor.getValue();
assertThat(review, is(mapVersionReview));
}
use of com.faforever.client.api.dto.MapVersion in project downlords-faf-client by FAForever.
the class MapBean method fromMapDto.
public static MapBean fromMapDto(com.faforever.client.api.dto.Map map) {
MapVersion mapVersion = map.getLatestVersion();
MapBean mapBean = new MapBean();
Optional.ofNullable(map.getAuthor()).ifPresent(author -> mapBean.setAuthor(author.getLogin()));
mapBean.setDescription(mapVersion.getDescription());
mapBean.setDisplayName(map.getDisplayName());
mapBean.setFolderName(mapVersion.getFolderName());
mapBean.setSize(MapSize.valueOf(mapVersion.getWidth(), mapVersion.getHeight()));
mapBean.setDownloads(map.getStatistics().getDownloads());
mapBean.setId(mapVersion.getId());
mapBean.setPlayers(mapVersion.getMaxPlayers());
mapBean.setVersion(mapVersion.getVersion());
mapBean.setDownloadUrl(mapVersion.getDownloadUrl());
mapBean.setSmallThumbnailUrl(mapVersion.getThumbnailUrlSmall());
mapBean.setLargeThumbnailUrl(mapVersion.getThumbnailUrlLarge());
mapBean.setCreateTime(mapVersion.getCreateTime().toLocalDateTime());
mapBean.setNumberOfPlays(map.getStatistics().getPlays());
mapBean.getReviews().setAll(map.getVersions().stream().filter(v -> v.getReviews() != null).flatMap(v -> v.getReviews().parallelStream()).map(Review::fromDto).collect(Collectors.toList()));
return mapBean;
}
Aggregations