Package org.apache.commons.collections15

Examples of org.apache.commons.collections15.TestBeanMap$BeanWithProperties


        assertEquals(confirmedFirst, ordered.firstKey());
    }

    public void testLastKey() {
        resetEmpty();
        OrderedMap ordered = (OrderedMap) map;
        try {
            ordered.lastKey();
            fail();
        } catch (NoSuchElementException ex) {
        }

        resetFull();
        ordered = (OrderedMap) map;
        Object confirmedLast = null;
        for (Iterator it = confirmed.keySet().iterator(); it.hasNext();) {
            confirmedLast = it.next();
        }
        assertEquals(confirmedLast, ordered.lastKey());
    }
View Full Code Here


    }

    //-----------------------------------------------------------------------   
    public void testNextKey() {
        resetEmpty();
        OrderedMap ordered = (OrderedMap) map;
        assertEquals(null, ordered.nextKey(getOtherKeys()[0]));
        if (isAllowNullKey() == false) {
            try {
                assertEquals(null, ordered.nextKey(null)); // this is allowed too
            } catch (NullPointerException ex) {
            }
        } else {
            assertEquals(null, ordered.nextKey(null));
        }

        resetFull();
        ordered = (OrderedMap) map;
        Iterator it = confirmed.keySet().iterator();
        Object confirmedLast = it.next();
        while (it.hasNext()) {
            Object confirmedObject = it.next();
            assertEquals(confirmedObject, ordered.nextKey(confirmedLast));
            confirmedLast = confirmedObject;
        }
        assertEquals(null, ordered.nextKey(confirmedLast));

        if (isAllowNullKey() == false) {
            try {
                ordered.nextKey(null);
                fail();
            } catch (NullPointerException ex) {
            }
        } else {
            assertEquals(null, ordered.nextKey(null));
        }
    }
View Full Code Here

        }
    }

    public void testPreviousKey() {
        resetEmpty();
        OrderedMap ordered = (OrderedMap) map;
        assertEquals(null, ordered.previousKey(getOtherKeys()[0]));
        if (isAllowNullKey() == false) {
            try {
                assertEquals(null, ordered.previousKey(null)); // this is allowed too
            } catch (NullPointerException ex) {
            }
        } else {
            assertEquals(null, ordered.previousKey(null));
        }

        resetFull();
        ordered = (OrderedMap) map;
        List list = new ArrayList(confirmed.keySet());
        Collections.reverse(list);
        Iterator it = list.iterator();
        Object confirmedLast = it.next();
        while (it.hasNext()) {
            Object confirmedObject = it.next();
            assertEquals(confirmedObject, ordered.previousKey(confirmedLast));
            confirmedLast = confirmedObject;
        }
        assertEquals(null, ordered.previousKey(confirmedLast));

        if (isAllowNullKey() == false) {
            try {
                ordered.previousKey(null);
                fail();
            } catch (NullPointerException ex) {
            }
        } else {
            if (isAllowNullKey() == false) {
                assertEquals(null, ordered.previousKey(null));
            }
        }
    }
View Full Code Here

            return;
        }

        super.testEmptyMapIterator();

        OrderedMapIterator it = makeEmptyOrderedMapIterator();
        Map map = getMap();
        assertEquals(false, it.hasPrevious());
        try {
            it.previous();
            fail();
        } catch (NoSuchElementException ex) {
        }
    }
View Full Code Here

            return;
        }

        super.testFullMapIterator();

        OrderedMapIterator it = makeFullOrderedMapIterator();
        Map map = getMap();

        assertEquals(true, it.hasNext());
        assertEquals(false, it.hasPrevious());
        Set set = new HashSet();
        while (it.hasNext()) {
            // getKey
            Object key = it.next();
            assertSame("it.next() should equals getKey()", key, it.getKey());
            assertTrue("Key must be in map", map.containsKey(key));
            assertTrue("Key must be unique", set.add(key));
           
            // getValue
            Object value = it.getValue();
            if (isGetStructuralModify() == false) {
                assertSame("Value must be mapped to key", map.get(key), value);
            }
            assertTrue("Value must be in map", map.containsValue(value));

            assertEquals(true, it.hasPrevious());

            verify();
        }
        while (it.hasPrevious()) {
            // getKey
            Object key = it.previous();
            assertSame("it.previous() should equals getKey()", key, it.getKey());
            assertTrue("Key must be in map", map.containsKey(key));
            assertTrue("Key must be unique", set.remove(key));
           
            // getValue
            Object value = it.getValue();
            if (isGetStructuralModify() == false) {
                assertSame("Value must be mapped to key", map.get(key), value);
            }
            assertTrue("Value must be in map", map.containsValue(value));

            assertEquals(true, it.hasNext());

            verify();
        }
    }
View Full Code Here

    public void testMapIteratorOrder() {
        if (supportsFullIterator() == false) {
            return;
        }

        OrderedMapIterator it = makeFullOrderedMapIterator();
        Map map = getMap();

        assertEquals("keySet() not consistent", new ArrayList(map.keySet()), new ArrayList(map.keySet()));

        Iterator it2 = map.keySet().iterator();
        assertEquals(true, it.hasNext());
        assertEquals(true, it2.hasNext());
        List list = new ArrayList();
        while (it.hasNext()) {
            Object key = it.next();
            assertEquals(it2.next(), key);
            list.add(key);
        }
        assertEquals(map.size(), list.size());
        while (it.hasPrevious()) {
            Object key = it.previous();
            assertEquals(list.get(list.size() - 1), key);
            list.remove(list.size() - 1);
        }
        assertEquals(0, list.size());
    }
View Full Code Here

    public void testOrderedMapIterator() {
        assertTrue(makeEmptyOrderedMapIterator() instanceof Unmodifiable);
    }

    public void testDecorateFactory() {
        OrderedMapIterator it = makeFullOrderedMapIterator();
        assertSame(it, UnmodifiableOrderedMapIterator.decorate(it));

        it = ((OrderedMap) getMap()).orderedMapIterator();
        assertTrue(it != UnmodifiableOrderedMapIterator.decorate(it));
View Full Code Here

       
        vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
       
        final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance();
        final Set exclusions = new HashSet();
        eif.setPredicate(new Predicate() {

      public boolean evaluate(Object e) {
       
        return exclusions.contains(e);
      }});
View Full Code Here

       
        vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
       
        final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance();
        final Set exclusions = new HashSet();
        eif.setPredicate(new Predicate() {

      public boolean evaluate(Object e) {
       
        return exclusions.contains(e);
      }});
View Full Code Here

            if (i % 6 == 0) {
                sixes.add(new Integer(i));
            }
        }

        truePred = new Predicate() {
            public boolean evaluate(Object x) {
                return true;
            }
        };

        falsePred = new Predicate() {
            public boolean evaluate(Object x) {
                return true;
            }
        };

        evenPred = new Predicate() {
            public boolean evaluate(Object x) {
                return (((Integer) x).intValue() % 2 == 0);
            }
        };

        oddPred = new Predicate() {
            public boolean evaluate(Object x) {
                return (((Integer) x).intValue() % 2 == 1);
            }
        };

        threePred = new Predicate() {
            public boolean evaluate(Object x) {
                return (((Integer) x).intValue() % 3 == 0);
            }
        };

        fourPred = new Predicate() {
            public boolean evaluate(Object x) {
                return (((Integer) x).intValue() % 4 == 0);
            }
        };
View Full Code Here

TOP

Related Classes of org.apache.commons.collections15.TestBeanMap$BeanWithProperties

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.