// Path: src/test/java/org/cri/redmetrics/backend/Backends.java
// public class Backends {
// 
//     public static final EventBackend EVENT = new EventBackend();
//     public static final GameBackend GAME = new GameBackend();
//     public static final GameVersionBackend GAME_VERSION = new GameVersionBackend();
//     public static final GroupBackend GROUP = new GroupBackend();
//     public static final PlayerBackend PLAYER = new PlayerBackend();
//     public static final SnapshotBackend SNAPSHOT = new SnapshotBackend();
//     private static int gameNo = 0;
//     
//     public static TestGame newSavedGame() {
//         
//         try {
//             TestGame game = new TestGame();
//             game.setName("My Test Game " + gameNo);
//             ++gameNo;
//             TestGame savedGame = GAME.post(game);
//             return savedGame;
//         } catch (IOException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     public static TestGameVersion newSavedGameVersion() {
//         try {
//             TestGame game = newSavedGame();
//             TestGameVersion gameVersion = new TestGameVersion();
//             gameVersion.setGame(game.getId());
//             gameVersion.setName("version 1");
//             gameVersion = GAME_VERSION.post(gameVersion);
//             return gameVersion;
//         } catch (IOException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     public static TestPlayer newSavedPlayer() {
//         try {
//             TestPlayer player = Players.newJohnSnow();
//             TestPlayer savedPlayer = PLAYER.post(player);
//             return savedPlayer;
//         } catch (IOException e) {
//             throw new RuntimeException(e);
//         }
//     }
//     
// }
// 
// Path: src/test/java/org/cri/redmetrics/backend/PlayerBackend.java
// public class PlayerBackend extends HttpBackend<TestPlayer> {
// 
//     PlayerBackend() {
//         super("player", TestPlayer.class);
//     }
// }
// 
// Path: src/test/java/org/cri/redmetrics/model/Players.java
// public class Players {
// 
//     public static TestPlayer newJohnSnow() {
//         return new PlayerBuilder().withNewRandomExternalId().withGender(Gender.MALE).withRegion("South").withCountry("The North").build();
//     }
// 
// }
// 
// Path: src/test/java/org/cri/redmetrics/model/TestPlayer.java
// @Data
// @EqualsAndHashCode(callSuper = true)
// @ToString(callSuper = true)
// public class TestPlayer extends TestEntity {
// 
//     @Key
//     private String birthDate;
// 
//     @Key
//     private String region;
// 
//     @Key
//     private String country;
// 
//     @Key
//     private String gender;
// 
//     @Key
//     private String externalId;
// }


import com.google.api.client.http.HttpResponseException;
import org.cri.redmetrics.backend.Backends;
import org.cri.redmetrics.backend.PlayerBackend;
import org.cri.redmetrics.model.Players;
import org.cri.redmetrics.model.TestPlayer;
import org.testng.annotations.Test;
import java.io.IOException;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.failBecauseExceptionWasNotThrown;
package org.cri.redmetrics;




public class PlayerBackendTest {

    final PlayerBackend players = Backends.PLAYER;

    // CREATE

    @Test
    public void canCreatePlayer() throws IOException {
        TestPlayer johnSnow = Players.newJohnSnow();
        TestPlayer savedPlayer = players.post(johnSnow);
        assertThat(savedPlayer.getId()).isNotNull().hasSize(36);
        assertThat(savedPlayer.getBirthDate()).isEqualTo(johnSnow.getBirthDate());
        assertThat(savedPlayer.getGender()).isEqualTo(johnSnow.getGender());
        assertThat(savedPlayer.getRegion()).isEqualTo(johnSnow.getRegion());
        assertThat(savedPlayer.getCountry()).isEqualTo(johnSnow.getCountry());
        assertThat(savedPlayer.getExternalId()).isEqualTo(johnSnow.getExternalId());
    }

    // READ

/*    @Test
    public void canFindByEmail() throws IOException {
        TestPlayer savedPlayer = players.post(Players.newJohnSnow());
        TestPlayer foundPlayer = players.getById("email/" + savedPlayer.getEmail());
        assertThat(foundPlayer.getId()).isEqualTo(savedPlayer.getId());
    }
*/

    // UPDATE

    @Test
    public void canUpdatePlayer() throws IOException {
// Path: src/test/java/org/cri/redmetrics/backend/Backends.java
// public class Backends {
// 
//     public static final EventBackend EVENT = new EventBackend();
//     public static final GameBackend GAME = new GameBackend();
//     public static final GameVersionBackend GAME_VERSION = new GameVersionBackend();
//     public static final GroupBackend GROUP = new GroupBackend();
//     public static final PlayerBackend PLAYER = new PlayerBackend();
//     public static final SnapshotBackend SNAPSHOT = new SnapshotBackend();
//     private static int gameNo = 0;
//     
//     public static TestGame newSavedGame() {
//         
//         try {
//             TestGame game = new TestGame();
//             game.setName("My Test Game " + gameNo);
//             ++gameNo;
//             TestGame savedGame = GAME.post(game);
//             return savedGame;
//         } catch (IOException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     public static TestGameVersion newSavedGameVersion() {
//         try {
//             TestGame game = newSavedGame();
//             TestGameVersion gameVersion = new TestGameVersion();
//             gameVersion.setGame(game.getId());
//             gameVersion.setName("version 1");
//             gameVersion = GAME_VERSION.post(gameVersion);
//             return gameVersion;
//         } catch (IOException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     public static TestPlayer newSavedPlayer() {
//         try {
//             TestPlayer player = Players.newJohnSnow();
//             TestPlayer savedPlayer = PLAYER.post(player);
//             return savedPlayer;
//         } catch (IOException e) {
//             throw new RuntimeException(e);
//         }
//     }
//     
// }
// 
// Path: src/test/java/org/cri/redmetrics/backend/PlayerBackend.java
// public class PlayerBackend extends HttpBackend<TestPlayer> {
// 
//     PlayerBackend() {
//         super("player", TestPlayer.class);
//     }
// }
// 
// Path: src/test/java/org/cri/redmetrics/model/Players.java
// public class Players {
// 
//     public static TestPlayer newJohnSnow() {
//         return new PlayerBuilder().withNewRandomExternalId().withGender(Gender.MALE).withRegion("South").withCountry("The North").build();
//     }
// 
// }
// 
// Path: src/test/java/org/cri/redmetrics/model/TestPlayer.java
// @Data
// @EqualsAndHashCode(callSuper = true)
// @ToString(callSuper = true)
// public class TestPlayer extends TestEntity {
// 
//     @Key
//     private String birthDate;
// 
//     @Key
//     private String region;
// 
//     @Key
//     private String country;
// 
//     @Key
//     private String gender;
// 
//     @Key
//     private String externalId;
// }


// Path: src/test/java/org/cri/redmetrics/PlayerBackendTest.java
import com.google.api.client.http.HttpResponseException;
import org.cri.redmetrics.backend.Backends;
import org.cri.redmetrics.backend.PlayerBackend;
import org.cri.redmetrics.model.Players;
import org.cri.redmetrics.model.TestPlayer;
import org.testng.annotations.Test;
import java.io.IOException;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.failBecauseExceptionWasNotThrown;

package org.cri.redmetrics;




public class PlayerBackendTest {

    final PlayerBackend players = Backends.PLAYER;

    // CREATE

    @Test
    public void canCreatePlayer() throws IOException {
        TestPlayer johnSnow = Players.newJohnSnow();
        TestPlayer savedPlayer = players.post(johnSnow);
        assertThat(savedPlayer.getId()).isNotNull().hasSize(36);
        assertThat(savedPlayer.getBirthDate()).isEqualTo(johnSnow.getBirthDate());
        assertThat(savedPlayer.getGender()).isEqualTo(johnSnow.getGender());
        assertThat(savedPlayer.getRegion()).isEqualTo(johnSnow.getRegion());
        assertThat(savedPlayer.getCountry()).isEqualTo(johnSnow.getCountry());
        assertThat(savedPlayer.getExternalId()).isEqualTo(johnSnow.getExternalId());
    }

    // READ

/*    @Test
    public void canFindByEmail() throws IOException {
        TestPlayer savedPlayer = players.post(Players.newJohnSnow());
        TestPlayer foundPlayer = players.getById("email/" + savedPlayer.getEmail());
        assertThat(foundPlayer.getId()).isEqualTo(savedPlayer.getId());
    }
*/

    // UPDATE

    @Test
    public void canUpdatePlayer() throws IOException {
        TestPlayer savedPlayer = players.post(Players.newJohnSnow());