use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.
the class V2ClientMessageTransformerTest method gameDesync.
@Test
public void gameDesync() throws Exception {
ClientMessage result = instance.transform(write(new GameDesyncClientMessage()));
assertThat(result, is(DesyncReport.INSTANCE));
}
use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.
the class V2ClientMessageTransformerTest method gameState.
@Test
public void gameState() throws Exception {
ClientMessage result = instance.transform(write(new GameStateClientMessage(PlayerGameState.LAUNCHING)));
assertThat(result, is(new GameStateReport(PlayerGameState.LAUNCHING)));
}
use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.
the class V2ClientMessageTransformer method transform.
@Override
@SneakyThrows
public ClientMessage transform(String source) {
try {
V2ClientMessageWrapper wrapper = objectMapper.readValue(source, V2ClientMessageWrapper.class);
V2ClientMessage message = wrapper.getData();
Requests.verify(message != null, ErrorCode.UNSUPPORTED_REQUEST, source);
Method mappingMethod = mapperMethods.get(message.getClass());
Requests.verify(mappingMethod != null, ErrorCode.UNSUPPORTED_REQUEST, source);
return (ClientMessage) mappingMethod.invoke(v2ClientMessageMapper, message);
} catch (JsonMappingException e) {
throw new RequestException(e, ErrorCode.UNSUPPORTED_REQUEST, source, e.getMessage());
}
}
use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.
the class V2ClientMessageTransformerTest method playerOption.
@Test
public void playerOption() throws Exception {
ClientMessage result = instance.transform(write(new PlayerOptionClientMessage(123, "key", "value")));
assertThat(result, is(new PlayerOptionReport(123, "key", "value")));
}
use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.
the class V2ClientMessageTransformerTest method armyOutcome.
@Test
public void armyOutcome() throws Exception {
ClientMessage result = instance.transform(write(new ArmyOutcomeClientMessage(1, Outcome.DEFEAT)));
assertThat(result, is(ArmyOutcomeReport.valueOf(1, Outcome.DEFEAT)));
}
Aggregations