ServerEntityDataMapper { public Server transform(ServerEntity serverEntity) { if (serverEntity == null) { return null; } return Server.builder() .ssid(serverEntity.ssid()) .ip(serverEntity.ip()) .hostname(serverEntity.hostname()) .os(serverEntity.os()) .version(serverEntity.version()) .seed(serverEntity.seed()) .worldName(serverEntity.worldName()) .playerName(serverEntity.playerName()) .encodedWorldImage(serverEntity.encodedWorldImage()) .build(); } @Inject  ServerEntityDataMapper(); Server transform(ServerEntity serverEntity); ServerEntity transformInverse(Server server);  }
@Test public void shouldReturnNullValueGivenANullServerEntity() throws Exception { Server server = serverEntityDataMapper.transform(null); assertThat(server, nullValue()); }
@Test public void shouldProperlyMapServerEntityIntoServer() throws Exception { ServerEntity serverEntity = ServerEntity.builder() .ssid("WLAN_CCQ4") .ip("127.0.0.1") .hostname("iMac") .os("Mac OS X") .version("1.4.2") .seed("1234567890") .worldName("Etho's Server") .playerName("Etho") .encodedWorldImage("base64image") .build(); Server server = serverEntityDataMapper.transform(serverEntity); assertThat(server, notNullValue()); assertThat(server, instanceOf(Server.class)); assertThat(server.ssid(), is("WLAN_CCQ4")); assertThat(server.ip(), is("127.0.0.1")); assertThat(server.hostname(), is("iMac")); assertThat(server.os(), is("Mac OS X")); assertThat(server.version(), is("1.4.2")); assertThat(server.seed(), is("1234567890")); assertThat(server.worldName(), is("Etho's Server")); assertThat(server.playerName(), is("Etho")); assertThat(server.encodedWorldImage(), is("base64image")); }