Package com.totalchange.jizz.data.entity

Examples of com.totalchange.jizz.data.entity.JizzDj


    @Autowired
    private JizzDjDao jizzDjJpaDao;

    public static JizzDj createDefaultDj(JizzDjDao jizzDjDao,
            JizzStation station) {
        JizzDj dj = new JizzDj();
        dj.setName("Test DJ");
        dj.setStation(station);

        Set<JizzDjLogin> logins = new HashSet<JizzDjLogin>();
        JizzDjLogin login = new JizzDjLogin();
        login.setDj(dj);
        login.setLoginName("DJ@TEST");
        logins.add(login);
        dj.setLogins(logins);

        return jizzDjDao.createOrUpdateDj(dj);
    }
View Full Code Here


        return jizzDjDao.createOrUpdateDj(dj);
    }

    @Test
    public void testFindDjByLoginName() {
        JizzDj dj = jizzDjJpaDao.findDjByLoginName("DJ@TEST");
        assertNull("DJ shouldn't exist yet", dj);

        // Need a station in otherwise empty database to use on DJ
        JizzStation station = JizzStationJpaDaoTest
                .createDefaultStation(jizzStationJpaDao);
View Full Code Here

    public void testFindDjsByStation() {
        JizzStation station1 = JizzStationJpaDaoTest
                .createDefaultStation(jizzStationJpaDao);
        JizzStation station2 = JizzStationJpaDaoTest
                .createDefaultStation(jizzStationJpaDao);
        JizzDj dj1 = createDefaultDj(jizzDjJpaDao, station1);
        JizzDj dj2 = createDefaultDj(jizzDjJpaDao, station1);
        JizzDj dj3 = createDefaultDj(jizzDjJpaDao, station1);
        JizzDj dj4 = createDefaultDj(jizzDjJpaDao, station2);
        JizzDj dj5 = createDefaultDj(jizzDjJpaDao, station2);

        List<JizzDj> station1Djs = jizzDjJpaDao.findDjsByStation(station1);
        List<JizzDj> station2Djs = jizzDjJpaDao.findDjsByStation(station2);

        assertContains(station1Djs, dj1);
View Full Code Here

    public void testCreateOrUpdateDj() {
        JizzStation station = JizzStationJpaDaoTest
                .createDefaultStation(jizzStationJpaDao);
        createDefaultDj(jizzDjJpaDao, station);

        JizzDj dj = jizzDjJpaDao.findDjByLoginName("DJ@TEST");
        assertEquals("Test DJ", dj.getName());

        // TODO: Figure out why these lines throw a lazy initialisation
        // exception
        // assertEquals(1, dj.getLogins().size());
        // assertEquals("DJ@TEST",
        // dj.getLogins().iterator().next().getLoginName());

        assertEquals("Jizz Test", dj.getStation().getName());
    }
View Full Code Here

        station = jizzStationDao.createOrUpdateStation(station);

        if (isNewInstall) {
            logger.info("New install - making current user an admin of this "
                    + "new station");
            JizzDj dj = jizzDjServices.getCurrentDj();
            jizzDjServices.addRole(dj, JizzDjRole.Roles.Administrator);
        }

        logger.trace("Server settings saved");
        return new SetSettingsResult();
View Full Code Here

        logger.trace("Init-ed instance");
    }

    private void confirmEmail(String key) throws ServletException {
        JizzDj currentDj = jizzDjServices.getCurrentDj();
        try {
            jizzDjServices.confirmEmailAddress(currentDj, key);
        } catch (InvalidKeyException kEx) {
            logger.info("Received failed email confirm request for DJ "
                    + currentDj + " and key " + key, kEx);
View Full Code Here

            return result;
        }
        result.setStationName(station.getName());

        // Look for the DJ based on their login name
        JizzDj dj = jizzDjServices.getCurrentDj();
        result.setName(dj.getName());
        result.setEmail(dj.getEmail());
        if (dj.getEmail() != null && dj.getEmail().length() > 0 && dj.getEmailConfirmation() != null) {
            result.setEmailAwaitingConfirmation(true);
        } else {
            result.setEmailAwaitingConfirmation(false);
        }
        result.setLocale(dj.getLocale());

        // Look up the next broadcast and set in its details
        JizzBroadcast broadcast = jizzBroadcastServices
                .getNextBroadcast(station);
        if (broadcast.getActualStart() != null) {
View Full Code Here

    }

    @Override
    public UpdateProfileResult execute(UpdateProfileAction action,
            ExecutionContext context) throws DispatchException {
        JizzDj dj = jizzDjServices.getCurrentDj();
        JizzServerValidator.failIfInvalid(dj, action);

        if (action.getEmail() != null) {
            jizzDjServices.changeEmailAddress(dj, action.getEmail());
        }
View Full Code Here

                JizzDjRole.Roles.Administrator));
    }

    @Test
    public void testAddRole() {
        JizzDj mockDj = new JizzDj();
        expect(mockJizzDjDao.createOrUpdateDj(mockDj)).andReturn(mockDj);

        replay(mockJizzDjDao);
        jizzDjServices.addRole(mockDj, JizzDjRole.Roles.Administrator);
        assertEquals(1, mockDj.getRoles().size());
        assertTrue(jizzDjServices.isInRole(mockDj,
                JizzDjRole.Roles.Administrator));
        verify(mockJizzDjDao);

        reset(mockJizzDjDao);
        replay(mockJizzDjDao);
        jizzDjServices.addRole(mockDj, JizzDjRole.Roles.Administrator);
        assertEquals(1, mockDj.getRoles().size());
        assertTrue(jizzDjServices.isInRole(mockDj,
                JizzDjRole.Roles.Administrator));
        verify(mockJizzDjDao);
    }
View Full Code Here

        verify(mockJizzDjDao);
    }

    @Test
    public void testChangeEmailAddress() {
        JizzDj mockDj = new JizzDj();

        expect(mockJizzDjDao.getDj(mockDj.getId())).andReturn(mockDj);
        expect(mockJizzDjDao.createOrUpdateDj(mockDj)).andReturn(mockDj);
        mockJizzEmailServices.confirmEmailAddress(mockDj);

        replayAll();
        jizzDjServices.changeEmailAddress(mockDj, "test@test.com");
        verifyAll();

        assertEquals("test@test.com", mockDj.getEmail());
        assertTrue("6 character email confirmation key generated", mockDj
                .getEmailConfirmation().length() == 6);
    }
View Full Code Here

TOP

Related Classes of com.totalchange.jizz.data.entity.JizzDj

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.