@Test
public void insertAndDeletePlayerHistoryTest() {
final Player player = createPlayer();
final PlayerHistory playerHistory1 = createPlayerHistory(player);
playerHistory1.setPlayer(player);
em.getTransaction().begin();
playerService.insertPlayer(player);
playerHistoryService.insertPlayerHistory(playerHistory1);
em.getTransaction().commit();
List<Player> playerList = playerService.findAllPlayers();
Assert.assertNotNull(playerList);
Assert.assertFalse(playerList.isEmpty());
List<PlayerHistory> playerHistoryList = playerHistoryService.findPlayerHistoryByPlayer(player);
Assert.assertNotNull(playerHistoryList);
Assert.assertFalse(playerHistoryList.isEmpty());
Assert.assertTrue(playerHistoryList.size() == 1);
Assert.assertEquals("Player history does not match to player.", player, playerHistoryList.get(0).getPlayer());
// insert another history record
final PlayerHistory playerHistory2 = createPlayerHistory(player);
playerHistory2.setPlayer(player);
em.getTransaction().begin();
playerHistoryService.insertPlayerHistory(playerHistory2);
em.getTransaction().commit();