Search in sources :

Example 1 with GameReview

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());
}
Also used : ModVersionReview(com.faforever.client.api.dto.ModVersionReview) MapVersionReview(com.faforever.client.api.dto.MapVersionReview) GameReview(com.faforever.client.api.dto.GameReview) Review(com.faforever.client.vault.review.Review) GameReview(com.faforever.client.api.dto.GameReview) Test(org.junit.Test)

Example 2 with GameReview

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));
}
Also used : Game(com.faforever.client.api.dto.Game) GameReview(com.faforever.client.api.dto.GameReview) Test(org.junit.Test)

Example 3 with 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);
}
Also used : Player(com.faforever.client.player.Player) Game(com.faforever.client.api.dto.Game) GameReview(com.faforever.client.api.dto.GameReview) Async(org.springframework.scheduling.annotation.Async)

Aggregations

GameReview (com.faforever.client.api.dto.GameReview)3 Game (com.faforever.client.api.dto.Game)2 Test (org.junit.Test)2 MapVersionReview (com.faforever.client.api.dto.MapVersionReview)1 ModVersionReview (com.faforever.client.api.dto.ModVersionReview)1 Player (com.faforever.client.player.Player)1 Review (com.faforever.client.vault.review.Review)1 Async (org.springframework.scheduling.annotation.Async)1