use of com.faforever.client.api.dto.Game in project downlords-faf-client by FAForever.
the class FafApiAccessorImplTest method testCreateGameReview.
@Test
public void testCreateGameReview() {
GameReview gameReview = new GameReview().setGame(new Game().setId("5"));
when(restOperations.postForEntity(eq("/data/game/5/reviews"), eq(gameReview), eq(GameReview.class))).thenReturn(new ResponseEntity<>(HttpStatus.OK));
instance.createGameReview(gameReview);
ArgumentCaptor<GameReview> captor = ArgumentCaptor.forClass(GameReview.class);
verify(restOperations).postForEntity(eq("/data/game/5/reviews"), captor.capture(), eq(GameReview.class));
GameReview review = captor.getValue();
assertThat(review, is(gameReview));
}
use of com.faforever.client.api.dto.Game in project downlords-faf-client by FAForever.
the class FafApiAccessorImplTest method testGetLastGameOnMap.
@Test
@SuppressWarnings("unchecked")
public void testGetLastGameOnMap() {
when(restOperations.getForObject(startsWith("/data/game"), eq(List.class))).thenReturn(Collections.singletonList(new Game())).thenReturn(emptyList());
instance.getLastGamesOnMap(4, "42", 3);
verify(restOperations).getForObject("/data/game?filter=mapVersion.id==\"42\";playerStats.player.id==\"4\"&sort=-endTime&page[size]=3&page[number]=1", List.class);
}
use of com.faforever.client.api.dto.Game in project downlords-faf-client by FAForever.
the class FafServiceImpl method saveGameReview.
@Override
@Async
public CompletableFuture<Void> saveGameReview(Review review, int gameId) {
GameReview gameReview = (GameReview) new GameReview().setScore(review.getScore().byteValue()).setText(review.getText());
if (review.getId() == null) {
Assert.notNull(review.getPlayer(), "Player ID must be set");
GameReview updatedReview = fafApiAccessor.createGameReview((GameReview) gameReview.setGame(new Game().setId(String.valueOf(gameId))).setPlayer(new com.faforever.client.api.dto.Player().setId(String.valueOf(review.getPlayer().getId()))));
review.setId(updatedReview.getId());
} else {
fafApiAccessor.updateGameReview((GameReview) gameReview.setId(String.valueOf(review.getId())));
}
return CompletableFuture.completedFuture(null);
}
Aggregations