use of com.faforever.server.stats.ArmyStatistics in project faf-java-server by FAForever.
the class LegacyRequestTransformer method handleJsonStats.
private ClientMessage handleJsonStats(Map<String, Object> source) {
return noCatch(() -> {
JsonNode node = objectMapper.readTree((String) getArgs(source).get(0));
JsonNode stats = node.get("stats");
TypeReference<List<ArmyStatistics>> typeReference = new TypeReference<List<ArmyStatistics>>() {
};
JsonParser jsonParser = stats.traverse();
jsonParser.setCodec(objectMapper);
return new ArmyStatisticsReport(jsonParser.readValueAs(typeReference));
});
}
use of com.faforever.server.stats.ArmyStatistics in project faf-java-server by FAForever.
the class ArmyStatsMapper method map.
public List<ArmyStatistics> map(String string) {
return noCatch(() -> {
JsonNode node = objectMapper.readTree(string);
JsonNode stats = node.get("stats");
TypeReference<List<ArmyStatistics>> typeReference = new TypeReference<List<ArmyStatistics>>() {
};
JsonParser jsonParser = stats.traverse();
jsonParser.setCodec(objectMapper);
return jsonParser.readValueAs(typeReference);
});
}
use of com.faforever.server.stats.ArmyStatistics in project faf-java-server by FAForever.
the class GameServiceTest method reportArmyStatistics.
@Test
public void reportArmyStatistics() throws Exception {
Game game = hostGame(player1);
assertThat(game.getArmyStatistics(), is(empty()));
instance.reportArmyStatistics(player1, Arrays.asList(new ArmyStatistics(), new ArmyStatistics()));
assertThat(game.getArmyStatistics(), is(notNullValue()));
assertThat(game.getArmyStatistics(), hasSize(2));
}
Aggregations