use of com.faforever.server.social.SocialRelationListResponse.SocialRelationResponse in project faf-java-server by FAForever.
the class SocialRelationResponseListResponseTransformerTest method transform.
@Test
public void transform() throws Exception {
Map<String, Serializable> result = SocialRelationListResponseTransformer.INSTANCE.transform(new SocialRelationListResponse(Arrays.asList(new SocialRelationResponse(1, RelationType.FRIEND), new SocialRelationResponse(2, RelationType.FOE), new SocialRelationResponse(3, RelationType.FOE), new SocialRelationResponse(4, RelationType.FRIEND))));
assertThat(result, is(ImmutableMap.of("command", "social", "friends", Arrays.asList(1, 4), "foes", Arrays.asList(2, 3))));
}
use of com.faforever.server.social.SocialRelationListResponse.SocialRelationResponse in project faf-java-server by FAForever.
the class SocialService method onPlayerOnlineEvent.
@EventListener
public void onPlayerOnlineEvent(PlayerOnlineEvent event) {
Player player = event.getPlayer();
List<SocialRelation> socialRelations = player.getSocialRelations();
if (socialRelations == null) {
return;
}
clientService.sendSocialRelations(new SocialRelationListResponse(socialRelations.stream().map(socialRelation -> new SocialRelationResponse(socialRelation.getSubjectId(), RelationType.valueOf(socialRelation.getStatus().toString()))).collect(Collectors.toList())), player);
}
use of com.faforever.server.social.SocialRelationListResponse.SocialRelationResponse in project faf-java-server by FAForever.
the class V2ServerMessageTransformerTest method socialRelationList.
@Test
public void socialRelationList() throws Exception {
String response = instance.transform(new SocialRelationListResponse(Arrays.asList(new SocialRelationResponse(1, RelationType.FRIEND), new SocialRelationResponse(2, RelationType.FOE))));
assertThat(response, is("{\"data\":{\"socialRelations\":[{\"playerId\":1,\"type\":\"FRIEND\"},{\"playerId\":2,\"type\":\"FOE\"}]},\"type\":\"socialRelations\"}"));
}
use of com.faforever.server.social.SocialRelationListResponse.SocialRelationResponse in project faf-java-server by FAForever.
the class SocialServiceTest method onAuthenticationSuccess.
@Test
public void onAuthenticationSuccess() throws Exception {
User user = (User) new User().setPlayer(new Player().setSocialRelations(Arrays.asList(new SocialRelation(1, null, 10, SocialRelationStatus.FRIEND), new SocialRelation(2, null, 11, SocialRelationStatus.FOE)))).setPassword("pw").setLogin("junit");
FafUserDetails userDetails = new FafUserDetails(user);
instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, userDetails.getPlayer()));
ArgumentCaptor<SocialRelationListResponse> captor = ArgumentCaptor.forClass(SocialRelationListResponse.class);
verify(clientService).sendSocialRelations(captor.capture(), any());
SocialRelationListResponse response = captor.getValue();
assertThat(response, instanceOf(SocialRelationListResponse.class));
assertThat(response.getSocialRelations(), hasSize(2));
assertThat(response.getSocialRelations().get(0), is(new SocialRelationResponse(10, RelationType.FRIEND)));
assertThat(response.getSocialRelations().get(1), is(new SocialRelationResponse(11, RelationType.FOE)));
}
Aggregations