Package org.newinstance.gucoach.model

Examples of org.newinstance.gucoach.model.PlayerHistory


     * Converts a data record of a player's history into a player history entity.
     *
     * @param record the record to convert
     */
    private void convertRecordToPlayerHistory(final String[] record) {
        final PlayerHistory playerHistory = new PlayerHistory();
        playerHistory.setPlayer(players.get(new Long(record[AttributePosition.ID])));
        // erase apostrophe in strength value
        final String strength = StringUtils.remove(record[AttributePosition.STRENGTH], '\'');
        playerHistory.setAverageStrength(new Float(strength));
        playerHistory.setForm(new Integer(record[AttributePosition.FORM]));
        playerHistory.setEnergy(new Integer(record[AttributePosition.ENERGY]));
        playerHistory.setEndurance(new Integer(record[AttributePosition.ENDURANCE]));
        playerHistory.setExperience(new Integer(record[AttributePosition.EXPERIENCE]));
        playerHistory.setSkillGoalkeeping(new Integer(record[AttributePosition.SKILL_GOALKEEPING]));
        playerHistory.setSkillTackling(new Integer(record[AttributePosition.SKILL_TACKLING]));
        playerHistory.setSkillPlaymaking(new Integer(record[AttributePosition.SKILL_PLAYMAKING]));
        playerHistory.setSkillPassing(new Integer(record[AttributePosition.SKILL_PASSING]));
        playerHistory.setSkillScoring(new Integer(record[AttributePosition.SKILL_SCORING]));
        playerHistory.setImportDate(importDate);
        history.put(playerHistory.getPlayer().getId(), playerHistory);
    }
View Full Code Here


    }

    @Test
    public void insertPlayerHistoryTest() {
        final Player player = createPlayer();
        final PlayerHistory playerHistory = createPlayerHistory(player);

        em.getTransaction().begin();
        playerService.insertPlayer(player);
        playerHistoryService.insertPlayerHistory(playerHistory);
        em.getTransaction().commit();

        final PlayerHistory result = playerHistoryService.findPlayerHistoryById(playerHistory.getId());
        Assert.assertNotNull(result);
        Assert.assertEquals(77, result.getEndurance().intValue());
        Assert.assertEquals(17, result.getSkillPlaymaking().intValue());
    }
View Full Code Here

    @Test
    public void findAllImportDatesTest() {
        final Player player = createPlayer();

        final Calendar cal = Calendar.getInstance();
        final PlayerHistory playerHistory1 = createPlayerHistory(player);
        playerHistory1.setPlayer(player);
        playerHistory1.setImportDate(cal.getTime());

        cal.roll(Calendar.MONTH, -1);
        final PlayerHistory playerHistory2 = createPlayerHistory(player);
        playerHistory2.setPlayer(player);
        playerHistory2.setImportDate(cal.getTime());

        em.getTransaction().begin();
        playerService.insertPlayer(player);
        playerHistoryService.insertPlayerHistory(playerHistory1);
        playerHistoryService.insertPlayerHistory(playerHistory2);
View Full Code Here

        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        final Date date1 = cal.getTime();
        final PlayerHistory playerHistory1 = createPlayerHistory(player);
        playerHistory1.setPlayer(player);
        playerHistory1.setImportDate(date1);

        // reduce import date by one day
        cal.set(Calendar.DAY_OF_MONTH, -1);
        final Date date2 = cal.getTime();
        final PlayerHistory playerHistory2 = createPlayerHistory(player);
        playerHistory2.setPlayer(player);
        playerHistory2.setImportDate(date2);

        em.getTransaction().begin();
        playerService.insertPlayer(player);
        playerHistoryService.insertPlayerHistory(playerHistory1);
        playerHistoryService.insertPlayerHistory(playerHistory2);
View Full Code Here

    @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();
View Full Code Here

     *
     * @param player the player the history record belongs to
     * @return a new entity
     */
    protected PlayerHistory createPlayerHistory(final Player player) {
        final PlayerHistory playerHistory = new PlayerHistory();
        playerHistory.setAverageStrength(3.4f);
        playerHistory.setEndurance(77);
        playerHistory.setEnergy(88);
        playerHistory.setExperience(100);
        playerHistory.setForm(90);
        playerHistory.setPlayer(player);
        playerHistory.setSkillGoalkeeping(3);
        playerHistory.setSkillPassing(19);
        playerHistory.setSkillPlaymaking(17);
        playerHistory.setSkillScoring(12);
        playerHistory.setSkillTackling(37);
        playerHistory.setImportDate(new Date());
        return playerHistory;
    }
View Full Code Here

TOP

Related Classes of org.newinstance.gucoach.model.PlayerHistory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.