Package org.richfaces.fragment.common.picker.ChoicePickerHelper

Examples of org.richfaces.fragment.common.picker.ChoicePickerHelper.ByIndexChoicePicker


public class TestChoicePickerByIndex extends AbstractChoicePickerTest {

    @Test
    public void testPickEvery2nd() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex().everyNth(2);
        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("1", "3", "5"), getStringsFromElements(pickMultiple));
    }
View Full Code Here


        assertEquals(Lists.newArrayList("1", "3", "5"), getStringsFromElements(pickMultiple));
    }

    @Test
    public void testPickEvery2ndFromSecond() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex().everyNth(2, 1);
        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("2", "4", "6"), getStringsFromElements(pickMultiple));
    }
View Full Code Here

        assertEquals(Lists.newArrayList("2", "4", "6"), getStringsFromElements(pickMultiple));
    }

    @Test
    public void testPickEvery2ndFromTooHighIndex() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex().everyNth(2, 6);
        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertTrue(pickMultiple.isEmpty());
    }
View Full Code Here

        assertTrue(pickMultiple.isEmpty());
    }

    @Test
    public void testPickFromRange() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex().fromRange(Range.closed(0, 2));
        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("1", "2", "3"), getStringsFromElements(pickMultiple));

        picker = ChoicePickerHelper.byIndex().fromRange(Range.open(0, 2));
        pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("2"), getStringsFromElements(pickMultiple));

        picker = ChoicePickerHelper.byIndex().fromRange(Range.atLeast(3));
        pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("4", "5", "6"), getStringsFromElements(pickMultiple));

        picker = ChoicePickerHelper.byIndex().fromRange(Range.<Integer>all());
        pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("1", "2", "3", "4", "5", "6"), getStringsFromElements(pickMultiple));
    }
View Full Code Here

        assertEquals(Lists.newArrayList("1", "2", "3", "4", "5", "6"), getStringsFromElements(pickMultiple));
    }

    @Test
    public void testPickFromRanges() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex()
                .fromRange(Range.atLeast(5))
                .fromRange(Range.closed(1, 2));
        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("6", "2", "3"), getStringsFromElements(pickMultiple));
    }
View Full Code Here

        assertEquals(Lists.newArrayList("6", "2", "3"), getStringsFromElements(pickMultiple));
    }

    @Test
    public void testPickMultiple() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex().indexes(1, 2).first().last().beforeLast(1);
        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("2", "3", "1", "6", "5"), getStringsFromElements(pickMultiple));
    }
View Full Code Here

        assertEquals(Lists.newArrayList("2", "3", "1", "6", "5"), getStringsFromElements(pickMultiple));
    }

    @Test
    public void testPickMultipleTimesSameIndexes() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex()
                .first().index(0)// the first element
                .index(1).indexes(0, 1)// the first two elements
                .last().beforeLast(0).index(5);// the last element

        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("1", "2", "6"), getStringsFromElements(pickMultiple));
    }
View Full Code Here

        assertEquals(Lists.newArrayList("1", "2", "6"), getStringsFromElements(pickMultiple));
    }

    @Test
    public void testPickNotExistingElement() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex().index(15);
        assertNull(picker.pick(myFragment.getDivs()));

        picker = ChoicePickerHelper.byIndex().fromRange(Range.<Integer>atLeast(15));
        assertNull(picker.pick(myFragment.getDivs()));
    }
View Full Code Here

        assertNull(picker.pick(myFragment.getDivs()));
    }

    @Test
    public void testPickingPreservesOrder() {
        ByIndexChoicePicker picker = ChoicePickerHelper.byIndex()
                .last().first().beforeLast(1).index(1);

        List<WebElement> pickMultiple = picker.pickMultiple(myFragment.getDivs());
        assertEquals(Lists.newArrayList("6", "1", "5", "2"), getStringsFromElements(pickMultiple));
    }
View Full Code Here

        Preconditions.checkNotNull(weekDayPosition);
        for (Integer integer : weekDayPosition) {
            Preconditions.checkArgument(integer > 0 && integer < 8);
        }

        ByIndexChoicePicker indexPicker = ChoicePickerHelper.byIndex();
        for (Integer integer : weekDayPosition) {
            indexPicker.everyNth(7, integer - 1);
        }
        return getDays().getItems(indexPicker);
    }
View Full Code Here

TOP

Related Classes of org.richfaces.fragment.common.picker.ChoicePickerHelper.ByIndexChoicePicker

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.