Coverage Summary for Class: ListMultimapPutTester (com.google.common.collect.testing.google)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| ListMultimapPutTester | 0% (0/1) | 0% (0/3) | 0% (0/26) |
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.copyToList; 18 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 19 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT; 20 21 import com.google.common.annotations.GwtCompatible; 22 import com.google.common.collect.ListMultimap; 23 import com.google.common.collect.testing.Helpers; 24 import com.google.common.collect.testing.features.CollectionSize; 25 import com.google.common.collect.testing.features.MapFeature; 26 import java.util.List; 27 import java.util.Map.Entry; 28 import org.junit.Ignore; 29 30 /** 31 * Testers for {@link ListMultimap#put(Object, Object)}. 32 * 33 * @author Louis Wasserman 34 */ 35 @GwtCompatible 36 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 37 public class ListMultimapPutTester<K, V> extends AbstractListMultimapTester<K, V> { 38 // MultimapPutTester tests non-duplicate values, but ignores ordering 39 40 @MapFeature.Require(SUPPORTS_PUT) 41 public void testPutAddsValueAtEnd() { 42 for (K key : sampleKeys()) { 43 for (V value : sampleValues()) { 44 resetContainer(); 45 46 List<V> values = multimap().get(key); 47 List<V> expectedValues = Helpers.copyToList(values); 48 49 assertTrue(multimap().put(key, value)); 50 expectedValues.add(value); 51 52 assertGet(key, expectedValues); 53 assertEquals(value, values.get(values.size() - 1)); 54 } 55 } 56 } 57 58 @MapFeature.Require(SUPPORTS_PUT) 59 @CollectionSize.Require(absent = ZERO) 60 public void testPutDuplicateValue() { 61 List<Entry<K, V>> entries = copyToList(multimap().entries()); 62 63 for (Entry<K, V> entry : entries) { 64 resetContainer(); 65 66 K k = entry.getKey(); 67 V v = entry.getValue(); 68 69 List<V> values = multimap().get(k); 70 List<V> expectedValues = copyToList(values); 71 72 assertTrue(multimap().put(k, v)); 73 expectedValues.add(v); 74 assertGet(k, expectedValues); 75 assertEquals(v, values.get(values.size() - 1)); 76 } 77 } 78 }