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