Coverage Summary for Class: MultimapEntriesTester (com.google.common.collect.testing.google)

Class Class, % Method, % Line, %
MultimapEntriesTester 0% (0/1) 0% (0/11) 0% (0/41)


1 /* 2  * Copyright (C) 2013 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5  * in compliance with the License. You may obtain a copy of the License at 6  * 7  * http://www.apache.org/licenses/LICENSE-2.0 8  * 9  * Unless required by applicable law or agreed to in writing, software distributed under the License 10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11  * or implied. See the License for the specific language governing permissions and limitations under 12  * the License. 13  */ 14  15 package com.google.common.collect.testing.google; 16  17 import static com.google.common.collect.testing.Helpers.assertContains; 18 import static com.google.common.collect.testing.Helpers.assertEqualIgnoringOrder; 19 import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE; 20 import static com.google.common.collect.testing.features.CollectionSize.ONE; 21 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 22 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS; 23 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEY_QUERIES; 24 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES; 25 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUE_QUERIES; 26 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE; 27  28 import com.google.common.annotations.GwtCompatible; 29 import com.google.common.collect.Multimap; 30 import com.google.common.collect.testing.Helpers; 31 import com.google.common.collect.testing.features.CollectionFeature; 32 import com.google.common.collect.testing.features.CollectionSize; 33 import com.google.common.collect.testing.features.MapFeature; 34 import java.util.Collections; 35 import java.util.Iterator; 36 import java.util.Map.Entry; 37 import org.junit.Ignore; 38  39 /** 40  * Tester for {@code Multimap.entries}. 41  * 42  * @author Louis Wasserman 43  */ 44 @GwtCompatible 45 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 46 public class MultimapEntriesTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> { 47  public void testEntries() { 48  assertEqualIgnoringOrder(getSampleElements(), multimap().entries()); 49  } 50  51  @CollectionSize.Require(absent = ZERO) 52  @MapFeature.Require(ALLOWS_NULL_KEYS) 53  public void testContainsEntryWithNullKeyPresent() { 54  initMultimapWithNullKey(); 55  assertContains(multimap().entries(), Helpers.mapEntry((K) null, getValueForNullKey())); 56  } 57  58  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES) 59  public void testContainsEntryWithNullKeyAbsent() { 60  assertFalse(multimap().entries().contains(Helpers.mapEntry(null, v0()))); 61  } 62  63  @CollectionSize.Require(absent = ZERO) 64  @MapFeature.Require(ALLOWS_NULL_VALUES) 65  public void testContainsEntryWithNullValuePresent() { 66  initMultimapWithNullValue(); 67  assertContains(multimap().entries(), Helpers.mapEntry(getKeyForNullValue(), (V) null)); 68  } 69  70  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES) 71  public void testContainsEntryWithNullValueAbsent() { 72  assertFalse(multimap().entries().contains(Helpers.mapEntry(k0(), null))); 73  } 74  75  @CollectionSize.Require(absent = ZERO) 76  @MapFeature.Require(SUPPORTS_REMOVE) 77  public void testRemovePropagatesToMultimap() { 78  assertTrue(multimap().entries().remove(Helpers.mapEntry(k0(), v0()))); 79  expectMissing(Helpers.mapEntry(k0(), v0())); 80  assertEquals(getNumElements() - 1, multimap().size()); 81  assertFalse(multimap().containsEntry(k0(), v0())); 82  } 83  84  @CollectionSize.Require(absent = ZERO) 85  @MapFeature.Require(SUPPORTS_REMOVE) 86  public void testRemoveAllPropagatesToMultimap() { 87  assertTrue(multimap().entries().removeAll(Collections.singleton(Helpers.mapEntry(k0(), v0())))); 88  expectMissing(Helpers.mapEntry(k0(), v0())); 89  assertEquals(getNumElements() - 1, multimap().size()); 90  assertFalse(multimap().containsEntry(k0(), v0())); 91  } 92  93  @CollectionSize.Require(absent = ZERO) 94  @MapFeature.Require(SUPPORTS_REMOVE) 95  public void testRetainAllPropagatesToMultimap() { 96  multimap().entries().retainAll(Collections.singleton(Helpers.mapEntry(k0(), v0()))); 97  assertEquals(getSubjectGenerator().create(Helpers.mapEntry(k0(), v0())), multimap()); 98  assertEquals(1, multimap().size()); 99  assertTrue(multimap().containsEntry(k0(), v0())); 100  } 101  102  @CollectionSize.Require(ONE) 103  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) 104  public void testIteratorRemovePropagatesToMultimap() { 105  Iterator<Entry<K, V>> iterator = multimap().entries().iterator(); 106  assertEquals(Helpers.mapEntry(k0(), v0()), iterator.next()); 107  iterator.remove(); 108  assertTrue(multimap().isEmpty()); 109  } 110  111  @CollectionSize.Require(absent = ZERO) 112  @MapFeature.Require(SUPPORTS_REMOVE) 113  public void testEntriesRemainValidAfterRemove() { 114  Iterator<Entry<K, V>> iterator = multimap().entries().iterator(); 115  Entry<K, V> entry = iterator.next(); 116  K key = entry.getKey(); 117  V value = entry.getValue(); 118  multimap().removeAll(key); 119  assertEquals(key, entry.getKey()); 120  assertEquals(value, entry.getValue()); 121  } 122 }