Coverage Summary for Class: ListMultimapRemoveTester (com.google.common.collect.testing.google)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| ListMultimapRemoveTester | 0% (0/1) | 0% (0/5) | 0% (0/33) |
1 /* 2 * Copyright (C) 2012 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.assertContentsInOrder; 18 import static com.google.common.collect.testing.Helpers.copyToList; 19 import static com.google.common.collect.testing.Helpers.mapEntry; 20 import static com.google.common.collect.testing.features.CollectionSize.SEVERAL; 21 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE; 22 23 import com.google.common.annotations.GwtCompatible; 24 import com.google.common.collect.ListMultimap; 25 import com.google.common.collect.testing.features.CollectionSize; 26 import com.google.common.collect.testing.features.MapFeature; 27 import java.util.Arrays; 28 import java.util.Collection; 29 import java.util.List; 30 import java.util.Map.Entry; 31 import org.junit.Ignore; 32 33 /** 34 * Testers for {@link ListMultimap#remove(Object, Object)}. 35 * 36 * @author Louis Wasserman 37 */ 38 @GwtCompatible 39 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 40 public class ListMultimapRemoveTester<K, V> extends AbstractListMultimapTester<K, V> { 41 @SuppressWarnings("unchecked") 42 @MapFeature.Require(SUPPORTS_REMOVE) 43 @CollectionSize.Require(SEVERAL) 44 public void testMultimapRemoveDeletesFirstOccurrence() { 45 resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0())); 46 47 List<V> list = multimap().get(k0()); 48 multimap().remove(k0(), v0()); 49 assertContentsInOrder(list, v1(), v0()); 50 } 51 52 @SuppressWarnings("unchecked") 53 @MapFeature.Require(SUPPORTS_REMOVE) 54 @CollectionSize.Require(SEVERAL) 55 public void testRemoveAtIndexFromGetPropagates() { 56 List<V> values = Arrays.asList(v0(), v1(), v0()); 57 58 for (int i = 0; i < 3; i++) { 59 resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0())); 60 List<V> expectedValues = copyToList(values); 61 62 multimap().get(k0()).remove(i); 63 expectedValues.remove(i); 64 65 assertGet(k0(), expectedValues); 66 } 67 } 68 69 @SuppressWarnings("unchecked") 70 @MapFeature.Require(SUPPORTS_REMOVE) 71 @CollectionSize.Require(SEVERAL) 72 public void testRemoveAtIndexFromAsMapPropagates() { 73 List<V> values = Arrays.asList(v0(), v1(), v0()); 74 75 for (int i = 0; i < 3; i++) { 76 resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0())); 77 List<V> expectedValues = copyToList(values); 78 79 List<V> asMapValue = (List<V>) multimap().asMap().get(k0()); 80 asMapValue.remove(i); 81 expectedValues.remove(i); 82 83 assertGet(k0(), expectedValues); 84 } 85 } 86 87 @SuppressWarnings("unchecked") 88 @MapFeature.Require(SUPPORTS_REMOVE) 89 @CollectionSize.Require(SEVERAL) 90 public void testRemoveAtIndexFromAsMapEntrySetPropagates() { 91 List<V> values = Arrays.asList(v0(), v1(), v0()); 92 93 for (int i = 0; i < 3; i++) { 94 resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0())); 95 List<V> expectedValues = copyToList(values); 96 97 Entry<K, Collection<V>> asMapEntry = multimap().asMap().entrySet().iterator().next(); 98 List<V> asMapValue = (List<V>) asMapEntry.getValue(); 99 asMapValue.remove(i); 100 expectedValues.remove(i); 101 102 assertGet(k0(), expectedValues); 103 } 104 } 105 }