use of com.faforever.client.api.dto.GameReview 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.api.dto.GameReview 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.GameReview 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