use of com.faforever.server.stats.ArmyStatisticsReport 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.ArmyStatisticsReport in project faf-java-server by FAForever.
the class LegacyRequestTransformerTest method transformJsonStats.
@Test
public void transformJsonStats() throws Exception {
String stats;
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream("/stats/game_stats_full_example.json"), StandardCharsets.UTF_8)) {
stats = CharStreams.toString(reader);
}
ArmyStatisticsReport armyStatisticsReport = (ArmyStatisticsReport) instance.transform(ImmutableMap.of(KEY_COMMAND, "JsonStats", KEY_ARGS, Collections.singletonList(stats)));
assertThat(armyStatisticsReport, is(notNullValue()));
assertThat(armyStatisticsReport.getArmyStatistics(), is(notNullValue()));
}
use of com.faforever.server.stats.ArmyStatisticsReport in project faf-java-server by FAForever.
the class GameServiceActivatorsTest method reportGameStatistics.
@Test
public void reportGameStatistics() throws Exception {
ArmyStatisticsReport report = new ArmyStatisticsReport(Collections.emptyList());
instance.reportGameStatistics(report, clientConnection.getAuthentication());
verify(gameService).reportArmyStatistics(player, report.getArmyStatistics());
}
Aggregations