001/* 002 * Copyright (C) 2013 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License 010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 011 * or implied. See the License for the specific language governing permissions and limitations under 012 * the License. 013 */ 014 015package com.google.common.collect.testing.google; 016 017import static com.google.common.collect.testing.Helpers.assertEqualIgnoringOrder; 018import static com.google.common.collect.testing.Helpers.assertEqualInOrder; 019import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER; 020import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE; 021import static com.google.common.collect.testing.features.CollectionSize.ONE; 022 023import com.google.common.annotations.GwtCompatible; 024import com.google.common.collect.Lists; 025import com.google.common.collect.Multimap; 026import com.google.common.collect.testing.features.CollectionFeature; 027import com.google.common.collect.testing.features.CollectionSize; 028import java.util.Iterator; 029import java.util.List; 030import java.util.Map.Entry; 031import org.junit.Ignore; 032 033/** 034 * Tester for {@code Multimap.values}. 035 * 036 * @author Louis Wasserman 037 */ 038@GwtCompatible 039@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 040public class MultimapValuesTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> { 041 public void testValues() { 042 List<V> expected = Lists.newArrayList(); 043 for (Entry<K, V> entry : getSampleElements()) { 044 expected.add(entry.getValue()); 045 } 046 assertEqualIgnoringOrder(expected, multimap().values()); 047 } 048 049 @CollectionFeature.Require(KNOWN_ORDER) 050 public void testValuesInOrder() { 051 List<V> expected = Lists.newArrayList(); 052 for (Entry<K, V> entry : getOrderedElements()) { 053 expected.add(entry.getValue()); 054 } 055 assertEqualInOrder(expected, multimap().values()); 056 } 057 058 @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) 059 @CollectionSize.Require(ONE) 060 public void testValuesIteratorRemove() { 061 Iterator<V> valuesItr = multimap().values().iterator(); 062 valuesItr.next(); 063 valuesItr.remove(); 064 assertTrue(multimap().isEmpty()); 065 } 066}