Search in sources :

Example 1 with ModVersionReview

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

the class FafApiAccessorImplTest method testCreateModVersionReview.

@Test
public void testCreateModVersionReview() {
    ModVersionReview modVersionReview = new ModVersionReview();
    when(restOperations.postForEntity(eq("/data/modVersion/5/reviews"), eq(modVersionReview), eq(ModVersionReview.class))).thenReturn(new ResponseEntity<>(HttpStatus.OK));
    instance.createModVersionReview(modVersionReview.setModVersion(new com.faforever.client.api.dto.ModVersion().setId("5")));
    ArgumentCaptor<ModVersionReview> captor = ArgumentCaptor.forClass(ModVersionReview.class);
    verify(restOperations).postForEntity(eq("/data/modVersion/5/reviews"), captor.capture(), eq(ModVersionReview.class));
    ModVersionReview review = captor.getValue();
    assertThat(review, is(modVersionReview));
}
Also used : ModVersionReview(com.faforever.client.api.dto.ModVersionReview) Test(org.junit.Test)

Example 2 with ModVersionReview

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

the class FafServiceImpl method saveModVersionReview.

@Override
@Async
public CompletableFuture<Void> saveModVersionReview(Review review, String modVersionId) {
    ModVersionReview modVersionReview = (ModVersionReview) new ModVersionReview().setScore(review.getScore().byteValue()).setText(review.getText());
    if (review.getId() == null) {
        Assert.notNull(review.getPlayer(), "Player ID must be set");
        ModVersionReview updatedReview = fafApiAccessor.createModVersionReview((ModVersionReview) modVersionReview.setModVersion(new com.faforever.client.api.dto.ModVersion().setId(String.valueOf(modVersionId))).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.updateModVersionReview((ModVersionReview) modVersionReview.setId(String.valueOf(review.getId())));
    }
    return CompletableFuture.completedFuture(null);
}
Also used : ModVersion(com.faforever.client.mod.ModVersion) Player(com.faforever.client.player.Player) ModVersionReview(com.faforever.client.api.dto.ModVersionReview) Async(org.springframework.scheduling.annotation.Async)

Example 3 with ModVersionReview

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

the class FafServiceImplTest method createModVersion.

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

Aggregations

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