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

Class Class, % Method, % Line, %
SetMultimapPutTester 0% (0/1) 0% (0/4) 0% (0/20)


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.Helpers.copyToSet; 19 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 20 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES; 21 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT; 22  23 import com.google.common.annotations.GwtCompatible; 24 import com.google.common.collect.SetMultimap; 25 import com.google.common.collect.testing.features.CollectionSize; 26 import com.google.common.collect.testing.features.MapFeature; 27 import java.util.List; 28 import java.util.Map.Entry; 29 import java.util.Set; 30 import org.junit.Ignore; 31  32 /** 33  * Tests for {@link SetMultimap#replaceValues}. 34  * 35  * @author Louis Wasserman 36  */ 37 @GwtCompatible 38 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 39 public class SetMultimapPutTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> { 40  // Tests for non-duplicate values are in MultimapPutTester 41  42  @MapFeature.Require(SUPPORTS_PUT) 43  @CollectionSize.Require(absent = ZERO) 44  public void testPutDuplicateValuePreservesSize() { 45  assertFalse(multimap().put(k0(), v0())); 46  assertEquals(getNumElements(), multimap().size()); 47  } 48  49  @MapFeature.Require(SUPPORTS_PUT) 50  public void testPutDuplicateValue() { 51  List<Entry<K, V>> entries = copyToList(multimap().entries()); 52  53  for (Entry<K, V> entry : entries) { 54  resetContainer(); 55  K k = entry.getKey(); 56  V v = entry.getValue(); 57  58  Set<V> values = multimap().get(k); 59  Set<V> expectedValues = copyToSet(values); 60  61  assertFalse(multimap().put(k, v)); 62  assertEquals(expectedValues, values); 63  assertGet(k, expectedValues); 64  } 65  } 66  67  @MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) 68  @CollectionSize.Require(absent = ZERO) 69  public void testPutDuplicateValue_null() { 70  initMultimapWithNullValue(); 71  assertFalse(multimap().put(getKeyForNullValue(), null)); 72  expectContents(createArrayWithNullValue()); 73  } 74 }