Search in sources :

Example 1 with IceServersResponse

use of com.faforever.server.client.IceServersResponse 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\"}"));
}
Also used : IceServersResponse(com.faforever.server.client.IceServersResponse) Instant(java.time.Instant) IceServer(com.faforever.server.ice.IceServer) IceServerList(com.faforever.server.ice.IceServerList) Test(org.junit.Test)

Example 2 with IceServersResponse

use of com.faforever.server.client.IceServersResponse 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"));
}
Also used : Serializable(java.io.Serializable) IceServersResponse(com.faforever.server.client.IceServersResponse) Instant(java.time.Instant) IceServer(com.faforever.server.ice.IceServer) IceServerList(com.faforever.server.ice.IceServerList) List(java.util.List) Map(java.util.Map) IceServerList(com.faforever.server.ice.IceServerList) Test(org.junit.Test)

Aggregations

IceServersResponse (com.faforever.server.client.IceServersResponse)2 IceServer (com.faforever.server.ice.IceServer)2 IceServerList (com.faforever.server.ice.IceServerList)2 Instant (java.time.Instant)2 Test (org.junit.Test)2 Serializable (java.io.Serializable)1 List (java.util.List)1 Map (java.util.Map)1