Examples of PollItem


Examples of org.jtalks.jcommune.model.entity.PollItem

    /*===== Common methods =====*/

    @Test
    public void testGet() {
        PollItem expectedOption = PersistedObjectsFactory.createDefaultVotingOption();
        session.save(expectedOption);

        PollItem resultOption = pollOptionDao.get(expectedOption.getId());

        Assert.assertNotNull(resultOption);
        Assert.assertEquals(resultOption.getId(), expectedOption.getId());
    }
View Full Code Here

Examples of org.jtalks.jcommune.model.entity.PollItem

        Assert.assertEquals(resultOption.getId(), expectedOption.getId());
    }

    @Test
    public void testGetInvalidId() {
        PollItem option = pollOptionDao.get(-11111L);

        Assert.assertNull(option);
    }
View Full Code Here

Examples of org.jtalks.jcommune.model.entity.PollItem

    }

    @Test
    public void testUpdate() {
        String newName = "Changed name";
        PollItem option = PersistedObjectsFactory.createDefaultVotingOption();
        session.save(option);

        option.setName(newName);
        pollOptionDao.saveOrUpdate(option);
        session.flush();
        session.evict(option);

        PollItem changedOption = (PollItem) session.get(PollItem.class, option.getId());

        Assert.assertNotNull(changedOption);
        Assert.assertEquals(newName, changedOption.getName());
    }
View Full Code Here

Examples of org.jtalks.jcommune.model.entity.PollItem

        Poll poll = createPollWithOptions(POLL_ID, pollOptionIds, VOTES_COUNT, null);

        Mockito.when(pollDao.get(POLL_ID)).thenReturn(poll);

        Poll resultPoll = pollService.vote(POLL_ID, pollOptionIds);
        PollItem resultPollOption = resultPoll.getPollItems().get(0);

        Assert.assertEquals(resultPollOption.getVotesCount(), VOTES_COUNT + 1,
                "Count of votes should be increased.");
    }
View Full Code Here

Examples of org.jtalks.jcommune.model.entity.PollItem

        Poll poll = createPollWithOptions(POLL_ID, pollOptionIds, VOTES_COUNT, endingDate);

        Mockito.when(pollDao.get(POLL_ID)).thenReturn(poll);

        Poll resultPoll = pollService.vote(POLL_ID, pollOptionIds);
        PollItem resultPollOption = resultPoll.getPollItems().get(0);

        Assert.assertEquals(resultPollOption.getVotesCount(), VOTES_COUNT,
                "Count of votes should be the same.");
    }
View Full Code Here

Examples of org.jtalks.jcommune.model.entity.PollItem

                                       int initialVoteCount, DateTime endingDate) {
        Poll poll = new Poll("Poll");
        poll.setEndingDate(endingDate);
        poll.setId(pollId);
        for (Long id : pollOptionIds) {
            PollItem option = new PollItem("Option:" + String.valueOf(id));
            option.setId(id);
            option.setVotesCount(initialVoteCount);
            poll.addPollOptions(option);
        }
        return poll;
    }
View Full Code Here

Examples of org.jtalks.jcommune.model.entity.PollItem

    @Override
    public void mergePollItems(Poll poll, List<PollItem> newItems) {
        List<PollItem> existing = poll.getPollItems();
        ListIterator<PollItem> updated = newItems.listIterator();
        while (updated.hasNext()) {
            PollItem item = updated.next();
            for (PollItem old : existing) {
                if (item.getName().equals(old.getName())) {
                    updated.set(old);
                }
            }
        }
        existing.clear();
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        // After 10 msecs, send a ping message to output
        loop.addTimer(10, 1, timerEvent, input);

        // When we get the ping message, end the reactor
        PollItem pollInput = new PollItem(output, Poller.POLLIN);
        rc = loop.addPoller(pollInput, socketEvent, output);
        Assert.assertEquals(0, rc);
        loop.start();

        loop.removePoller(pollInput);
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        // After 10 msecs, fire a timer that registers
        // another timer that sends the ping message
        loop.addTimer(10, 1, timerEvent, input);

        // When we get the ping message, end the reactor
        PollItem pollInput = new PollItem(output, Poller.POLLIN);
        rc = loop.addPoller(pollInput, socketEvent, output);
        Assert.assertEquals(0, rc);

        loop.start();
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        // Fire a timer that sends the ping message
        loop.addTimer(0, 1, timerEvent, input);

        // When we get the ping message, end the reactor
        PollItem pollInput = new PollItem(output, Poller.POLLIN);
        rc = loop.addPoller(pollInput, socketEvent, output);
        Assert.assertEquals(0, rc);

        loop.start();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.