Search in sources :

Example 1 with MapVersionReview

use of com.faforever.client.api.dto.MapVersionReview in project downlords-faf-client by FAForever.

the class FafServiceImplTest method createMapVersionReview.

@Test
public void createMapVersionReview() throws Exception {
    Review review = createReview(null, "something", 3, 42);
    when(fafApiAccessor.createMapVersionReview(any())).thenReturn((MapVersionReview) new MapVersionReview().setPlayer(player()).setId("1").setScore((byte) 1));
    instance.saveMapVersionReview(review, "5");
    verify(fafApiAccessor).createMapVersionReview(any());
}
Also used : MapVersionReview(com.faforever.client.api.dto.MapVersionReview) 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) Test(org.junit.Test)

Example 2 with MapVersionReview

use of com.faforever.client.api.dto.MapVersionReview 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);
}
Also used : Player(com.faforever.client.player.Player) MapVersionReview(com.faforever.client.api.dto.MapVersionReview) MapVersion(com.faforever.client.api.dto.MapVersion) Async(org.springframework.scheduling.annotation.Async)

Example 3 with MapVersionReview

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

Aggregations

MapVersionReview (com.faforever.client.api.dto.MapVersionReview)3 MapVersion (com.faforever.client.api.dto.MapVersion)2 Test (org.junit.Test)2 GameReview (com.faforever.client.api.dto.GameReview)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