use of com.faforever.server.ice.IceServer in project faf-java-server by FAForever.
the class V2ServerMessageTransformerTest method iceServers.
@Test
public void iceServers() {
Instant createdAt = Instant.parse("2007-12-03T10:15:30.00Z");
String response = instance.transform(new IceServersResponse(Collections.singletonList(new IceServerList(3600, createdAt, Collections.singletonList(new IceServer(URI.create("http://localhost"), "anonymous", "123", "token"))))));
assertThat(response, is("{\"data\":{\"iceServerLists\":[{\"ttlSeconds\":3600,\"createdAt\":1196676930000,\"servers\":[{\"url\":\"http://localhost\",\"username\":\"anonymous\",\"credential\":\"123\",\"credentialType\":\"token\"}]}]},\"type\":\"iceServers\"}"));
}
use of com.faforever.server.ice.IceServer in project faf-java-server by FAForever.
the class ClientServiceTest method sendIceServers.
@Test
public void sendIceServers() throws Exception {
List<IceServerList> iceServers = Collections.singletonList(new IceServerList(60, Instant.now(), Arrays.asList(new IceServer(URI.create("turn:test1"), null, null, null), new IceServer(URI.create("turn:test2"), "username", "credential", "credentialType"))));
ConnectionAware connectionAware = new Player().setClientConnection(clientConnection);
instance.sendIceServers(iceServers, connectionAware);
verify(clientGateway).send(new IceServersResponse(iceServers), clientConnection);
}
use of com.faforever.server.ice.IceServer in project faf-java-server by FAForever.
the class ServersResponseTransformerTest method transform.
@Test
@SuppressWarnings("unchecked")
public void transform() throws Exception {
Instant now = Instant.now();
List<IceServerList> iceServersLists = Collections.singletonList(new IceServerList(60, now, Arrays.asList(new IceServer(URI.create("http://localhost:1234"), "junit1", "test1", "token"), new IceServer(URI.create("http://localhost:2345"), "junit2", "test2", "token"))));
Map<String, Serializable> result = IceServersResponseTransformer.INSTANCE.transform(new IceServersResponse(iceServersLists));
assertThat(result.get("command"), is("ice_servers"));
assertThat(result.get("date_created"), is(DateTimeFormatter.ISO_INSTANT.format(now)));
assertThat(result.get("ttl"), is(60));
List<Map<String, Object>> iceServers = (List<Map<String, Object>>) result.get("ice_servers");
assertThat(iceServers, hasSize(2));
assertThat(iceServers.get(0).get("url"), is("http://localhost:1234"));
assertThat(iceServers.get(0).get("username"), is("junit1"));
assertThat(iceServers.get(0).get("credential"), is("test1"));
assertThat(iceServers.get(1).get("url"), is("http://localhost:2345"));
assertThat(iceServers.get(1).get("username"), is("junit2"));
assertThat(iceServers.get(1).get("credential"), is("test2"));
}
Aggregations