Examples of PollItem


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

    private Poll createPoll(long pollId, List<Long> pollOptionIds) {
        Poll poll = new Poll("New poll");
        poll.setId(pollId);
        int voteCount = 10;
        for (Long optionId : pollOptionIds) {
            PollItem option = createPollOption("First option", optionId, voteCount);
            poll.addPollOptions(option);
        }
        return poll;
    }
View Full Code Here

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

        }
        return poll;
    }

    private PollItem createPollOption(String name, Long id, int voteCount) {
        PollItem option = new PollItem("New poll option");
        option.setVotesCount(voteCount);
        option.setId(id);
        return option;
    }
View Full Code Here

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

    }
   
    @Test
    public void testFilledTitleAndFilledItemsValid() {
        String title = "larks! Stands and deliver.";
        List<PollItem> items = Arrays.asList(new PollItem("larks"));
        Poll poll = new Poll(title);
        poll.setPollItems(items);
       
        boolean isValid = validator.isValid(poll, validatorContext);
       
View Full Code Here

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

    }
   
    @Test
    public void testFilledTitleAndFilledItemsValid() {
        String title = "larks! Stands and deliver.";
        List<PollItem> items = Arrays.asList(new PollItem("larks"));
        Poll poll = new Poll(title);
        poll.setPollItems(items);
       
        boolean isValid = validator.isValid(poll, validatorContext);
       
View Full Code Here

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

    }
   
    @Test
    public void testBlankTitleAndFilledItemsInvalid() {
        String title = " ";
        List<PollItem> items = Arrays.asList(new PollItem("name"));
        Poll poll = new Poll(title);
        poll.setPollItems(items);
        String defaultErrorMessage = "message";
        Mockito.when(validatorContext.getDefaultConstraintMessageTemplate())
            .thenReturn(defaultErrorMessage);
View Full Code Here

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

    }
   
    @Test
    public void testItemsWithoutDuplicates() {
        List<PollItem> pollItems = new ArrayList<PollItem>();
        pollItems.add(new PollItem("first"));
        pollItems.add(new PollItem("second"));
        pollItems.add(new PollItem("third"));
       
        boolean isValid = validator.isValid(pollItems, validatorContext);
       
        Assert.assertTrue(isValid, "The poll items without duplicates must be valid");
    }
View Full Code Here

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

    }
   
    @Test
    public void testItemsWithDuplicates() {
        List<PollItem> pollItems = new ArrayList<PollItem>();
        pollItems.add(new PollItem("not duplicate"));
        pollItems.add(new PollItem("duplicate"));
        pollItems.add(new PollItem("duplicate"));
       
        boolean isValid = validator.isValid(pollItems, validatorContext);
       
        Assert.assertFalse(isValid, "The poll items with duplicates must be invalid");
    }
View Full Code Here

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

    @Test
    public void testPollItemNameLengthBetweenMinAndMaxIsValid() {
        String pollItemName = "1234567";
        int min = 5;
        int max = 10;
        List<PollItem> pollItems = Arrays.asList(new PollItem(pollItemName));
        when(pollItemsNamesLength.min()).thenReturn(min);
        when(pollItemsNamesLength.max()).thenReturn(max);

        validator.initialize(pollItemsNamesLength);
        boolean isValid = validator.isValid(pollItems, validatorContext);
View Full Code Here

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

    @Test
    public void testPollItemNameLengthLessThanMinIsInvalid() {
        String pollItemName = "123";
        int min = 5;
        int max = 10;
        List<PollItem> pollItems = Arrays.asList(new PollItem(pollItemName));
        when(pollItemsNamesLength.min()).thenReturn(min);
        when(pollItemsNamesLength.max()).thenReturn(max);

        validator.initialize(pollItemsNamesLength);
        boolean isValid = validator.isValid(pollItems, validatorContext);
View Full Code Here

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

    @Test
    public void testPollItemNameLengthMoreThanMaxIsInvalid() {
        String pollItemName = "1234567890123456789";
        int min = 5;
        int max = 10;
        List<PollItem> pollItems = Arrays.asList(new PollItem(pollItemName));
        when(pollItemsNamesLength.min()).thenReturn(min);
        when(pollItemsNamesLength.max()).thenReturn(max);

        validator.initialize(pollItemsNamesLength);
        boolean isValid = validator.isValid(pollItems, validatorContext);
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.