Search in sources :

Example 1 with Game

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

Example 2 with Game

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

Example 3 with Game

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);
}
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

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